MediaWiki:Cosmos.js

/* All JavaScript here will be loaded for users of the Cosmos skin */ $(document).ready(function {

document.getElementById("discordwidget").innerHTML = ' '; if (localStorage.getItem('darkmode') === '1') { document.documentElement.classList.add('client-darkmode'); } });/*Show discord widget*/

/*dark mode*/ $(window).load(function {

var html = document.getElementsByTagName('html')[0]; var dropdown = document.getElementById('p-more'); var buttonGroup = dropdown.parentNode; // Place darkmode button var darkModeButton = document.createElement('a'); darkModeButton.classList.add('wds-button', 'wds-is-secondary'); darkModeButton.href = '#'; darkModeButton.title = 'Switch to Dark Mode'; var moonSVG = '  '; var sunSVG = ' <path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z" fill="white"> '; buttonGroup.insertBefore(darkModeButton, dropdown); console.log('this works?'); if (html.classList.contains('client-darkmode')) { darkModeButton.innerHTML = sunSVG; } else { darkModeButton.innerHTML = moonSVG; }

darkModeButton.onclick = function { html.classList.toggle('client-darkmode'); if (darkModeButton.innerHTML == moonSVG) { darkModeButton.innerHTML = sunSVG; darkModeButton.title = 'Switch to Light Mode'; console.log('switching to light mode!'); //saving light mode setting localStorage.setItem("darkmode",0); } else { darkModeButton.innerHTML = moonSVG; darkModeButton.title = 'Switch to Dark Mode'; console.log('switching to dark mode!'); //saving dark mode setting localStorage.setItem('darkmode','1'); }   }; });