about summary refs log tree commit diff stats
path: root/login.php
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2025-11-09 21:14:29 +0300
committerAndrew Dolgov <fox@fakecake.org>2025-11-09 21:14:29 +0300
commitf445eee5c71a3d21ac799f8ee7f21b58ea747953 (patch)
treed291d1ff37c1baf1e6248a968da15ff61467f18b /login.php
parent179820c6ee66011c01a44ed171939c23059b3d27 (diff)
downloadthe-epube-f445eee5c71a3d21ac799f8ee7f21b58ea747953.tar.gz
the-epube-f445eee5c71a3d21ac799f8ee7f21b58ea747953.tar.xz
enable night mode on login screen
Diffstat (limited to 'login.php')
-rw-r--r--login.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/login.php b/login.php
index 4817965..5d7d546 100644
--- a/login.php
+++ b/login.php
@@ -97,7 +97,7 @@
 	<head>
 		<meta name="viewport" content="width=device-width, initial-scale=1.0">
 		<link href="lib/bootstrap/v3/css/bootstrap.min.css" rel="stylesheet" media="screen">
-		<link href="lib/bootstrap/v3/css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
+		<link id="theme_css" href="lib/bootstrap/v3/css/theme-dark.min.css" rel="stylesheet" media="screen">
 		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 		<script src="dist/app-libs.min.js"></script>
 		<title>The Epube</title>
@@ -111,6 +111,23 @@
 				return false;
 			}
 
+			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"));
+			}
+
+			if (window.matchMedia) {
+				const mql = window.matchMedia('(prefers-color-scheme: dark)');
+
+				mql.addEventListener("change", () => {
+					apply_night_mode(mql.matches);
+				});
+
+				apply_night_mode(mql.matches);
+			}
+
 			$(document).ready(function() {
 					/* global EpubeApp */