-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
72 lines (69 loc) · 2.26 KB
/
index.html
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
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Rust 2048</title>
<link rel="icon shortcut" type="image/png" href="favicon.png" />
<link rel="stylesheet" href="tailwind.css">
{style_include}
<style>
html,body { width: 100%; }
#main { min-height: 100vh; width: 100%; }
</style>
</head>
<body>
<div id="main"></div>
<script type="module">
import init from "/{base_path}/assets/dioxus/{app_name}.js";
init("/{base_path}/assets/dioxus/{app_name}_bg.wasm").then((wasm) => {
if (wasm.__wbindgen_start == undefined) {
wasm.main();
}
});
</script>
{script_include}
<script>
// PLEASE HELP ME FIX THIS SHIT !!!
let counter = 1;
document.addEventListener('keydown', function(e) {
if (!document.getElementById('gamearea')) {
return
}
if (counter === 1) {
e.preventDefault();
counter = 0
new_e = new e.constructor(e.type, e);
gamearea.dispatchEvent(new_e);
setTimeout(function() { counter = 1 }, 20);
}
});
</script>
<script>
try {
const theme = localStorage.getItem('theme')
if (theme === 'dark') {
document.documentElement.setAttribute('data-theme', 'black');
}
if (theme === 'light') {
document.documentElement.setAttribute('data-theme', 'lofi');
}
if (theme === 'system') {
var preference_query = window.matchMedia('(prefers-color-scheme: dark)');
function checkPreference(query) {
if (query.matches) {
document.documentElement.setAttribute('data-theme', 'black');
localStorage.setItem('theme', 'system');
} else {
document.documentElement.setAttribute('data-theme', 'lofi');
localStorage.setItem('theme', 'system');
}
}
checkPreference(preference_query);
preference_query.addEventListener("change", checkPreference);
}
} catch (error) {}
</script>
</body>
</html>