diff options
author | johannst <johannst@users.noreply.github.com> | 2022-04-16 20:25:59 +0000 |
---|---|---|
committer | johannst <johannst@users.noreply.github.com> | 2022-04-16 20:25:59 +0000 |
commit | 74d1b6fd9991d1fb7dc19f09b06f7b2277874ece (patch) | |
tree | 3957a793425ffe1ad5d7aa40e855ff60aac60b3b /settings.js | |
parent | 8e43cf83e971d34f6272110300461fe48031ee36 (diff) | |
download | mini-kvm-rs-74d1b6fd9991d1fb7dc19f09b06f7b2277874ece.tar.gz mini-kvm-rs-74d1b6fd9991d1fb7dc19f09b06f7b2277874ece.zip |
deploy: 38cd31ed203999122c500d389de38bb051ce979e
Diffstat (limited to 'settings.js')
-rw-r--r-- | settings.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/settings.js b/settings.js index b4d6fdc..8047189 100644 --- a/settings.js +++ b/settings.js @@ -1 +1 @@ -(function(){function changeSetting(settingName,value){updateLocalStorage("rustdoc-"+settingName,value);switch(settingName){case"preferred-dark-theme":case"preferred-light-theme":case"use-system-theme":updateSystemTheme();break}}function handleKey(ev){if(ev.ctrlKey||ev.altKey||ev.metaKey){return}switch(getVirtualKey(ev)){case"Enter":case"Return":case"Space":ev.target.checked=!ev.target.checked;ev.preventDefault();break}}function setEvents(){onEachLazy(document.getElementsByClassName("slider"),function(elem){var toggle=elem.previousElementSibling;var settingId=toggle.id;var settingValue=getSettingValue(settingId);if(settingValue!==null){toggle.checked=settingValue==="true"}toggle.onchange=function(){changeSetting(this.id,this.checked)};toggle.onkeyup=handleKey;toggle.onkeyrelease=handleKey});onEachLazy(document.getElementsByClassName("select-wrapper"),function(elem){var select=elem.getElementsByTagName("select")[0];var settingId=select.id;var settingValue=getSettingValue(settingId);if(settingValue!==null){select.value=settingValue}select.onchange=function(){changeSetting(this.id,this.value)}})}window.addEventListener("DOMContentLoaded",setEvents)})()
\ No newline at end of file +(function(){function changeSetting(settingName,value){updateLocalStorage(settingName,value);switch(settingName){case"theme":case"preferred-dark-theme":case"preferred-light-theme":case"use-system-theme":updateSystemTheme();updateLightAndDark();break}}function handleKey(ev){if(ev.ctrlKey||ev.altKey||ev.metaKey){return}switch(getVirtualKey(ev)){case"Enter":case"Return":case"Space":ev.target.checked=!ev.target.checked;ev.preventDefault();break}}function showLightAndDark(){addClass(document.getElementById("theme").parentElement,"hidden");removeClass(document.getElementById("preferred-light-theme").parentElement,"hidden");removeClass(document.getElementById("preferred-dark-theme").parentElement,"hidden")}function hideLightAndDark(){addClass(document.getElementById("preferred-light-theme").parentElement,"hidden");addClass(document.getElementById("preferred-dark-theme").parentElement,"hidden");removeClass(document.getElementById("theme").parentElement,"hidden")}function updateLightAndDark(){if(getSettingValue("use-system-theme")!=="false"){showLightAndDark()}else{hideLightAndDark()}}function setEvents(){updateLightAndDark();onEachLazy(document.getElementsByClassName("slider"),function(elem){var toggle=elem.previousElementSibling;var settingId=toggle.id;var settingValue=getSettingValue(settingId);if(settingValue!==null){toggle.checked=settingValue==="true"}toggle.onchange=function(){changeSetting(this.id,this.checked)};toggle.onkeyup=handleKey;toggle.onkeyrelease=handleKey});onEachLazy(document.getElementsByClassName("select-wrapper"),function(elem){var select=elem.getElementsByTagName("select")[0];var settingId=select.id;var settingValue=getSettingValue(settingId);if(settingValue!==null){select.value=settingValue}select.onchange=function(){changeSetting(this.id,this.value)}});onEachLazy(document.querySelectorAll("input[type=\"radio\"]"),function(elem){const settingId=elem.name;const settingValue=getSettingValue(settingId);if(settingValue!==null&&settingValue!=="null"){elem.checked=settingValue===elem.value}elem.addEventListener("change",function(ev){changeSetting(ev.target.name,ev.target.value)})});document.getElementById("back").addEventListener("click",function(){history.back()})}window.addEventListener("DOMContentLoaded",setEvents)})()
\ No newline at end of file |