Hello, I was wondering if someone could help me.
A while ago, I asked for a code to change my Forumactif forum to dark mode by default. @Ace 1 kindly provided the code (thank you very much!) However, the code never worked for me and then the support forum got closed. Now I am trying to address this problem again.
I tried many things, but nothing worked. I managed to impove it slightly, but I am still having a problem with the light theme. The problem is that it is displaying the dark theme background colour in the body of the forum when I switch to light:
Picture
My current default theme code:
My dark theme code:
I thought maybe someone could help. Thanks in advance.
A while ago, I asked for a code to change my Forumactif forum to dark mode by default. @Ace 1 kindly provided the code (thank you very much!) However, the code never worked for me and then the support forum got closed. Now I am trying to address this problem again.
I tried many things, but nothing worked. I managed to impove it slightly, but I am still having a problem with the light theme. The problem is that it is displaying the dark theme background colour in the body of the forum when I switch to light:
Picture
My current default theme code:
- Code:
// Dark Mode Default
(function() {
var footer = '.footer-links.left',
customCSS = '#page-body { background:#333; }';
my_setcookie('fae_light-switch-mode', 'light', true);
if (window.sessionStorage && window.sessionStorage.DarkDefault) {
$('head').append('<style type="text/css" id="dark-mode-css">' + window.sessionStorage.DarkDefault + customCSS + '</style>');
} else {
$.get('https://raw.githubusercontent.com/SethClydesdale/forumactif-edge/master/css/dark-mode/dark-mode.min.css', function(d) {
$('head').append('<style type="text/css" id="dark-mode-css">' + d + '</style>');
if (window.sessionStorage) window.sessionStorage.DarkDefault = d;
});
}
})();
My dark theme code:
- Code:
(function() {
window.fae_lightSwitchMode = my_getcookie('fae_light-switch-mode') || 'dark';
document.write('<style type="text/css">#fae_light-switch-container{margin:6px 0}#fae_light-switch-label{font-weight:700;vertical-align:middle}#fae_light-switch{background-color:rgba(0,0,0,.25);vertical-align:middle;display:inline-block;position:relative;height:26px;width:56px;border-radius:20px;cursor:pointer;overflow:hidden}#fae_light-switch>input{display:none}#fae_light-switch>div{background-color:rgba(255,255,255,.5);position:absolute;top:3px;left:3px;height:20px;width:20px;border-radius:20px;transition:.4s;font-size:13px;font-weight:700;line-height:22px}#fae_light-switch>div:before{content:"ON";margin-left:-24px;color:transparent;transition:.4s}#fae_light-switch>div:after{content:"OFF";margin-left:30px;color:rgba(255,255,255,.5);transition:.4s}#fae_light-switch>input:checked+div{background-color:#FFF;left:33px}#fae_light-switch>input:checked+div:before{color:#FFF}#fae_light-switch>input:checked+div:after{color:transparent}</style>');
var footer = '.footer-links.left',
customCSS = '#page-body { background:#333; }',
light = '#pagebody { background:#ffffff; }',
cookie = my_getcookie('fae_light-switch'),
rgb,
button,
container,
changeTheme = function (cookie) {
var button = document.querySelector('#fae_light-switch input');
if ((button && button.checked) || cookie == 'on') {
my_setcookie('fae_light-switch', 'on', true);
if (window.sessionStorage && window.sessionStorage.faeLightSwitch) {
$('head').append('<style type="text/css" id="fae_light-switch-css">' + window.sessionStorage.faeLightSwitch + customCSS + '</style>');
} else {
$.get('https://raw.githubusercontent.com/SethClydesdale/forumactif-edge/master/css/dark-mode/' + fae_lightSwitchMode + '-mode.min.css', function (d) {
$('head').append('<style type="text/css" id="fae_light-switch-css">' + d + customCSS + '</style>');
if (window.sessionStorage) {
window.sessionStorage.faeLightSwitch = d;
}
});
}
} else {
var css = document.getElementById('fae_light-switch-css');
my_setcookie('fae_light-switch', 'off', true);
if (css) {
document.head.removeChild(css);
}
}
};
cookie && changeTheme(cookie);
$(function() {
if (!my_getcookie('fae_light-switch-mode')) {
rgb = window.getComputedStyle(document.body, null).getPropertyValue('background-color').replace(/rgb\(|\)|\s/g, '').split(',');
fae_lightSwitchMode = Math.round(((parseInt(rgb[0]) * 299) + (parseInt(rgb[1]) * 587) + (parseInt(rgb[2]) * 114)) /1000) > 125 ? 'dark' : 'light';
my_setcookie('fae_light-switch-mode', fae_lightSwitchMode, true);
}
footer = document.querySelector(footer);
if (footer) {
button = document.createElement('LABEL');
button.id = 'fae_light-switch';
button.innerHTML = '<input type="checkbox" ' + (cookie == 'on' ? 'checked="true"' : '') + '/><div></div>';
button.firstChild.onchange = changeTheme;
container = document.createElement('DIV');
container.id = 'fae_light-switch-container';
container.innerHTML = '<span id="fae_light-switch-label">' + (fae_lightSwitchMode == 'dark' ? 'Dark Mode : ' : 'Light Mode : ') + '</span>';
container.appendChild(button);
footer.appendChild(container);
}
});
}());
I thought maybe someone could help. Thanks in advance.
Last edited by Aileena on April 6th 2018, 5:01 pm; edited 3 times in total