You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
Commands-Creator/public/scripts/main.js

36 lines
881 B

q = document.querySelector.bind(document)
function onLoad() {
try {
q("#dark-mode").checked = JSON.parse(localStorage.getItem("dark-mode"));
darkMode(JSON.parse(localStorage.getItem("dark-mode")));
} catch (error) {
localStorage.setItem("dark-mode", false)
}
}
document.addEventListener("click", element => {
if (!q(".settings").contains(element.target) && element.target !== q(".settings-icon")) {
closeSettings()
}
})
q(".settings-icon").addEventListener("click", showSettings)
function closeSettings() {
$(".settings").hide()
}
function showSettings() {
$(".settings").show()
}
q("#dark-mode").addEventListener("click", () => {
localStorage.setItem("dark-mode", q("#dark-mode").checked)
darkMode(q("#dark-mode").checked)
})
function darkMode(isOn) {
q(".night-mode-link").disabled = !isOn
}
onLoad()