From f2a3c23634c7a5f8c23f68f24ff5dde95d472e16 Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Mon, 3 Feb 2025 16:24:25 -0600 Subject: Working on assets --- js/colors.js | 16 ++++++++++++++++ js/toggle.js | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 js/colors.js create mode 100644 js/toggle.js (limited to 'js') 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 -- cgit v1.2.3