MediaWiki:Timeless.js: Difference between revisions
From Ephinea PSO Wiki
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
/* All JavaScript here will be loaded for users of the Timeless skin */ | /* All JavaScript here will be loaded for users of the Timeless skin */ | ||
$(document).ready(function () { | |||
if (document.getElementsByClassName("stickyHeader").length > 0) { | |||
setStickyHeaderTop(); | |||
$(window).resize(setStickyHeaderTop); | |||
} | |||
const darkMode = localStorage.getItem("darkMode"); | |||
if (darkMode === "true") { | |||
document.body.classList.add("darkMode"); | |||
} else { | |||
document.body.classList.remove("darkMode"); | |||
} | |||
$("#personal-inner").append('<button onClick="toggleDarkMode();" style="margin:.5rem!important;">Toggle Dark Mode</button>'); | $("#personal-inner").append('<button onClick="toggleDarkMode();" style="margin:.5rem!important;">Toggle Dark Mode</button>'); | ||
}); | }); | ||
function toggleDarkMode() { | function toggleDarkMode() { |
Revision as of 05:40, 17 November 2021
/* All JavaScript here will be loaded for users of the Timeless skin */ $(document).ready(function () { if (document.getElementsByClassName("stickyHeader").length > 0) { setStickyHeaderTop(); $(window).resize(setStickyHeaderTop); } const darkMode = localStorage.getItem("darkMode"); if (darkMode === "true") { document.body.classList.add("darkMode"); } else { document.body.classList.remove("darkMode"); } $("#personal-inner").append('<button onClick="toggleDarkMode();" style="margin:.5rem!important;">Toggle Dark Mode</button>'); }); function toggleDarkMode() { const darkMode = localStorage.getItem("darkMode"); if (darkMode !== "true") { localStorage.setItem("darkMode", true); document.body.classList.add("darkMode"); } else { localStorage.setItem("darkMode", false); document.body.classList.remove("darkMode"); } }