17,097
edits
(Rework dark mode implementation, prevents FOUC on page load) |
(Ensure darkModeNoticeElem always defined regardless of previous dismissal of prompt (in case user clicks 'Dark Mode' links)) |
||
Line 603: | Line 603: | ||
// Dark mode | // Dark mode | ||
// Initialize element | |||
var newDiv = document.createElement('div'); | |||
newDiv.classList.toggle('noticebox'); | |||
newDiv.style.cssText = 'display:none; max-width:100%; width:100%; text-align:center;'; | |||
darkModeNoticeElem = newDiv; | |||
if (!darkModeNoticeDismissed) { | if (!darkModeNoticeDismissed) { | ||
const cnElem = document.getElementById('mw-content'); | |||
const cnElem = document.getElementById('mw-content'); | |||
if (cnElem !== null) { | if (cnElem !== null) { | ||
cnElem.insertBefore(darkModeNoticeElem, cnElem.firstChild); | cnElem.insertBefore(darkModeNoticeElem, cnElem.firstChild); | ||
} | } | ||