summaryrefslogtreecommitdiff
path: root/share/html_detail_start
blob: 2cd32ec86d8b1d7739a3b3246bd5903bb19755f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html>
<head>
	<title><!-- $title --></title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" type="text/css" href=".data/css/main.css"/>
	<link rel="stylesheet" type="text/css" href=".data/css/light.css" id="theme"/>
	<script>
		function addStyleSheet(name, id) {
			var path = '.data/css/' + name + '.css';
			var old = document.getElementById(id);
			if (old && (old.href != path)) {
				old.href = path;
			}
		}
		var otherTheme = {
			'dark': 'light',
			'light': 'dark',
		};
		var currentTheme = localStorage.getItem('theme');
		if (!otherTheme.hasOwnProperty(currentTheme)) {
			currentTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
		}
		addStyleSheet(currentTheme, 'theme');

		function toggleTheme() {
			currentTheme = otherTheme[currentTheme] || 'light';
			localStorage.setItem('theme', currentTheme);
			addStyleSheet(currentTheme, 'theme');
		}
	</script>
</head>
<body>