2019-09-23 18:37:02 +00:00
|
|
|
const storageName = 'darkmode'
|
|
|
|
|
|
|
|
const Darkmode = {
|
|
|
|
darkIsOn: false,
|
|
|
|
|
|
|
|
setDarkMode: function(setOn) {
|
|
|
|
if (setOn) {
|
|
|
|
localStorage.setItem(storageName, true)
|
2021-01-05 19:12:10 +00:00
|
|
|
document.body.className = 'darkmodeon' + ' ' + (window.supportsavif ? 'avifsupport' : 'jpegonly')
|
2019-09-23 18:37:02 +00:00
|
|
|
Darkmode.darkIsOn = true
|
|
|
|
} else {
|
|
|
|
localStorage.removeItem(storageName)
|
2021-01-05 19:12:10 +00:00
|
|
|
document.body.className = 'daymode' + ' ' + (window.supportsavif ? 'avifsupport' : 'jpegonly')
|
2019-09-23 18:37:02 +00:00
|
|
|
Darkmode.darkIsOn = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
isOn: function() {
|
|
|
|
return Darkmode.darkIsOn
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
Darkmode.darkIsOn = localStorage.getItem(storageName)
|
|
|
|
|
|
|
|
module.exports = Darkmode
|