MediaWiki:Timeless.js

From Ephinea PSO Wiki
Revision as of 05:40, 17 November 2021 by Matt (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* 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");
	}
}