summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/colors.js16
-rw-r--r--js/toggle.js8
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