aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/templates/-base.html.tmpl
blob: 2e78a7c9f0011b5cebb823816be31d996a680f02 (plain) (blame)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="{{ .Printer.Bcp }}">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		{{ if .Debugp }}
		<link href="/style-2.css" type="text/css" rel="stylesheet">
		{{ else }}
		<link href="/style.min.css" type="text/css" rel="stylesheet">
		{{ end }}
		<title>{{ .Get "Euro Cash Wiki" }}</title>
		<script type="text/javascript">
			const $  = q => document.querySelector(q);
			const $$ = q => document.querySelectorAll(q);

			(() => {
				document.addEventListener("DOMContentLoaded", _ => {
					const root = $("html");
					const icons = {
						light: $("#nav-icon-theme-light"),
						dark:  $("#nav-icon-theme-dark"),
					};

					const toggle = theme =>
						  theme === "light" ? "dark" : "light"

					const setTheme = theme => {
						localStorage.setItem("theme", theme);
						root.setAttribute("data-theme", theme);
						icons[theme].style.display = "";
						icons[toggle(theme)].style.display = "none";
					};

					/* Double toggle to handle invalid theme */
					setTheme(toggle(toggle(localStorage.getItem("theme"))));
					$("#theme-button").onclick = () => {
						const theme = toggle(localStorage.getItem("theme"));
						if (document.startViewTransition)
							document.startViewTransition(() => setTheme(theme));
						else
							setTheme(theme);
					};
				});
			})();
		</script>

		{{ template "header" . }}
  </head>
  <body>
		{{ template "content" . }}
		<footer class="container">
			<p>
				<small>
					{{ .Get "Found a mistake or want to contribute missing information?" }}
					<a href="/about">{{ .Get "Feel free to contact us!" }}</a>
				</small>
			</p>
		</footer>
	</body>
</html>