summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-12-12 20:35:12 +0300
committerAndrew Dolgov <[email protected]>2019-12-12 20:35:12 +0300
commitbafd0b747449e0d1814389ddc3d528e0ca8b6ed2 (patch)
tree33665e6a95de41b9d32a293bbdc8863c4d32ea78 /js
parentd462303ce923e15b596eac41d69abfefb66caa90 (diff)
enable automatic night mode for index pages
Diffstat (limited to 'js')
-rw-r--r--js/common.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/js/common.js b/js/common.js
index b42491d..ecc8206 100644
--- a/js/common.js
+++ b/js/common.js
@@ -32,4 +32,21 @@ function offline_remove(id, callback) {
}
}
+function init_night_mode() {
+ if (window.matchMedia) {
+ const mql = window.matchMedia('(prefers-color-scheme: dark)');
+ mql.addEventListener("change", () => {
+ apply_night_mode(mql.matches);
+ });
+
+ apply_night_mode(mql.matches);
+ }
+}
+
+function apply_night_mode(is_night) {
+ console.log("night mode changed to", is_night);
+
+ $("#theme_css").attr("href",
+ "lib/bootstrap/v3/css/" + (is_night ? "theme-dark.min.css" : "bootstrap-theme.min.css"));
+}