diff options
| author | Chris Wells <chris@mathematicaster.org> | 2025-02-03 16:24:25 -0600 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2025-02-03 16:24:25 -0600 |
| commit | f2a3c23634c7a5f8c23f68f24ff5dde95d472e16 (patch) | |
| tree | d60ac3cb766075a4d16a496a90f2726ef7b4d132 /js | |
| parent | c9cc52175073c5e690ea7eb30aad23d0d1776435 (diff) | |
| download | assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar.gz assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar.bz2 assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar.lz assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar.xz assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar.zst assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.zip | |
Working on assets
Diffstat (limited to 'js')
| -rw-r--r-- | js/colors.js | 16 | ||||
| -rw-r--r-- | js/toggle.js | 8 |
2 files changed, 24 insertions, 0 deletions
diff --git a/js/colors.js b/js/colors.js new file mode 100644 index 0000000..158ad52 --- /dev/null +++ b/js/colors.js @@ -0,0 +1,16 @@ +// @license http://www.wtfpl.net/txt/copying/" WTFPL + +if ( localStorage.getItem("color-mode") === "dark" || + ( !localStorage.getItem("color-mode") && window.matchMedia('(prefers-color-scheme: dark)').matches ) +) { + document.documentElement.setAttribute("color-mode", "dark"); +}; + +function toggleColorMode() { + var doc = document.documentElement; + var color = doc.getAttribute("color-mode") == "dark" ? "light" : "dark"; + doc.setAttribute("color-mode", color); + localStorage.setItem("color-mode", color); +}; + +// @license-end diff --git a/js/toggle.js b/js/toggle.js new file mode 100644 index 0000000..884e0bf --- /dev/null +++ b/js/toggle.js @@ -0,0 +1,8 @@ +// @license http://www.wtfpl.net/txt/copying/" WTFPL + +function toggle(divid) { + var cont = document.getElementById(divid); + cont.style.display = cont.style.display == 'none' ? 'block' : 'none'; +} + +// @license-end |
