Added function "setDebug"

This commit is contained in:
CommanderRedYT
2020-11-15 12:09:02 +01:00
parent d6ce850cac
commit 1b382a8554
2 changed files with 14 additions and 6 deletions

View File

@@ -1,16 +1,17 @@
var applyDarkmode = false; var applyDarkmode = false;
var state = false; var state = false;
var debug = "false";
if (getCookie("darkmode") == null) { if (getCookie("darkmode") == null) {
applyDarkmode = false; applyDarkmode = false;
console.log('Cookie "darkmode" empty'); if(debug == "true") console.log('Cookie "darkmode" empty');
} else { } else {
applyDarkmode = getCookie("darkmode"); applyDarkmode = getCookie("darkmode");
console.log("Cookie darkmode:" + applyDarkmode); if(debug == "true") console.log("Cookie darkmode:" + applyDarkmode);
} }
var isDark = false; var isDark = false;
function setdarkMode(state) { function setdarkMode(state) {
console.log( if(debug == "true") console.log(
'function "setdarkMode" was initiated with value "state" as ' + state 'function "setdarkMode" was initiated with value "state" as ' + state
); );
var elements = document.getElementsByClassName("couldDark"); var elements = document.getElementsByClassName("couldDark");
@@ -35,7 +36,7 @@ function setdarkMode(state) {
} }
function setNavbar(state) { function setNavbar(state) {
console.log( if(debug == "true") console.log(
'function "setNavbar" was initiated with value "state" as ' + state 'function "setNavbar" was initiated with value "state" as ' + state
); );
if (state) { if (state) {
@@ -54,7 +55,7 @@ function setNavbar(state) {
function darkMode() { function darkMode() {
applyDarkmode = !applyDarkmode; applyDarkmode = !applyDarkmode;
console.log("applyDarkmode:" + applyDarkmode); if(debug == "true") console.log("applyDarkmode:" + applyDarkmode);
setdarkMode(applyDarkmode); setdarkMode(applyDarkmode);
setNavbar(applyDarkmode); setNavbar(applyDarkmode);
return; return;
@@ -93,6 +94,7 @@ function checkDarkmode() {
} }
function load() { function load() {
debug = getCookie("debug");
if(getCookie("darkmode") == "") { if(getCookie("darkmode") == "") {
setCookie("darkmode", false, 999); setCookie("darkmode", false, 999);
} }
@@ -125,3 +127,9 @@ function getCookie(cname) {
return ""; return "";
} }
/*End Cookie scripts*/ /*End Cookie scripts*/
function setDebug(debugval) {
setCookie("debug", debugval, 999);
debug = getCookie("debug");
return debug;
}

View File

@@ -3,7 +3,7 @@ function setactivePage() {
var tmp = path.split("/").pop(); var tmp = path.split("/").pop();
var page = tmp.replace(".html", ""); var page = tmp.replace(".html", "");
if (page == "") page = "home"; if (page == "") page = "home";
console.log("page:" + page); if(debug == "true") console.log("page:" + page);
var site = document.getElementsByClassName("canactive"); var site = document.getElementsByClassName("canactive");
len = site !== null ? site.length : 0; len = site !== null ? site.length : 0;
i = 0; i = 0;