1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-24 07:53:00 +01:00
actix-extras/settings.js
2021-01-03 22:38:26 +00:00

1 line
1.0 KiB
JavaScript

(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 setEvents(){var elems={toggles:document.getElementsByClassName("slider"),selects:document.getElementsByClassName("select-wrapper")};var i;if(elems.toggles&&elems.toggles.length>0){for(i=0;i<elems.toggles.length;++i){var toggle=elems.toggles[i].previousElementSibling;var settingId=toggle.id;var settingValue=getSettingValue(settingId);if(settingValue!==null){toggle.checked=settingValue==="true"}toggle.onchange=function(){changeSetting(this.id,this.checked)}}}if(elems.selects&&elems.selects.length>0){for(i=0;i<elems.selects.length;++i){var select=elems.selects[i].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)}}}}setEvents()})()