Anonymous

MediaWiki:Common.js: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 545: Line 545:
}
}
$(document).ready(function () {
$(document).ready(function () {
  if (document.getElementsByClassName('stickyHeader').length > 0) {
if (document.getElementsByClassName("stickyHeader").length > 0) {
    setStickyHeaderTop();
setStickyHeaderTop();
    $(window).resize(setStickyHeaderTop);
$(window).resize(setStickyHeaderTop);
  }
}
});
 
function setItem(key, value) {
localStorage.setItem(key, JSON.stringify(value));
}
 
function getItem(key) {
let keydata = localStorage.getItem(key);
if (keydata == "undefined") return undefined;
return JSON.parse(keydata);
}
function toggleDarkMode() {
const darkMode = getItem("darkMode");
if (darkMode !== true) {
setItem("darkMode", true);
document.body.classList.add("darkMode");
} else {
setItem("darkMode", false);
document.body.classList.remove("darkMode");
}
}
}
);