-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
286 lines (247 loc) · 8.53 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Disable zooming: -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<head>
<!-- change this to your project name -->
<title>Hyperspeedcube</title>
<!-- config for our rust wasm binary. go to https://trunkrs.dev/assets/#rust for more customization -->
<link data-trunk rel="rust" data-wasm-opt="2" />
<link data-trunk rel="icon" href="assets/favicon.ico">
<link data-trunk rel="copy-file" href="assets/sw.js" />
<link data-trunk rel="copy-file" href="assets/manifest.json" />
<link data-trunk rel="copy-file" href="assets/icon-1024.png" />
<link data-trunk rel="copy-file" href="assets/icon-256.png" />
<link data-trunk rel="copy-file" href="assets/icon_ios_touch_192.png" />
<link data-trunk rel="copy-file" href="assets/maskable_icon_x512.png" />
<link rel="manifest" href="manifest.json">
<link rel="apple-touch-icon" href="icon_ios_touch_192.png">
<meta name="theme-color" media="(prefers-color-scheme: light)" content="white">
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#404040">
<style>
html {
/* Remove touch delay: */
touch-action: manipulation;
}
body {
/* Light mode background color for what is not covered by the egui canvas,
or where the egui canvas is translucent. */
background: #909090;
}
@media (prefers-color-scheme: dark) {
body {
/* Dark mode background color for what is not covered by the egui canvas,
or where the egui canvas is translucent. */
background: #404040;
}
}
/* Allow canvas to fill entire web page: */
html,
body {
overflow: hidden;
margin: 0 !important;
padding: 0 !important;
height: 100%;
width: 100%;
}
/* Position canvas in center-top: */
canvas {
margin-right: auto;
margin-left: auto;
display: block;
position: absolute;
top: 0%;
left: 0%;
}
.centered {
margin-right: auto;
margin-left: auto;
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #f0f0f0;
font-size: 24px;
font-family: Ubuntu-Light, Helvetica, sans-serif;
text-align: center;
}
/* ---------------------------------------------- */
/* Loading animation from https://loading.io/css/ */
.lds-grid {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.lds-grid div {
position: absolute;
width: 16px;
height: 16px;
border-radius: 50%;
background: #fff;
animation: lds-grid 1.2s linear infinite;
}
.lds-grid div:nth-child(1) {
top: 8px;
left: 8px;
animation-delay: 0s;
}
.lds-grid div:nth-child(2) {
top: 8px;
left: 32px;
animation-delay: -0.4s;
}
.lds-grid div:nth-child(3) {
top: 8px;
left: 56px;
animation-delay: -0.8s;
}
.lds-grid div:nth-child(4) {
top: 32px;
left: 8px;
animation-delay: -0.4s;
}
.lds-grid div:nth-child(5) {
top: 32px;
left: 32px;
animation-delay: -0.8s;
}
.lds-grid div:nth-child(6) {
top: 32px;
left: 56px;
animation-delay: -1.2s;
}
.lds-grid div:nth-child(7) {
top: 56px;
left: 8px;
animation-delay: -0.8s;
}
.lds-grid div:nth-child(8) {
top: 56px;
left: 32px;
animation-delay: -1.2s;
}
.lds-grid div:nth-child(9) {
top: 56px;
left: 56px;
animation-delay: -1.6s;
}
@keyframes lds-grid {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
@keyframes lds-dual-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
<style>
#modal {
position: absolute;
top: 20%;
left: 20%;
height: 60%;
width: 60%;
font-family: monospace;
padding: 10px;
overflow: scroll;
background-color: white;
}
.div-button {
background-color: #e0e0e0;
user-select: none;
}
#hidemodal {
position: fixed;
opacity: 1;
top: calc(20% + 10px);
right: calc(20% + 10px);
height: 15px;
width: 15px;
font-size: 20px;
line-height: 15px;
padding: 1px;
}
.hidden {
display: none;
}
#pastein {
width: 100%;
height: 100%;
}
#copyout {
margin: 0px;
}
</style>
<script>
// read the log file from localstorage and put it in the modal
window.requestCopyText = function(log){
const modal = document.getElementById("modal");
const copyOut = document.getElementById("copyout");
const pasteIn = document.getElementById("pastein");
const hideButton = document.getElementById("hidemodal");
hideButton.innerHTML = "X";
modal.classList.remove("hidden");
copyOut.classList.remove("hidden");
pasteIn.classList.add("hidden");
copyOut.innerHTML = log
.replaceAll("<", "<")
.replaceAll(">", ">");
}
// read a log file from the modal and send it to rust via magic (wasm binding)
window.requestPasteText = function(){
const modal = document.getElementById("modal");
const copyOut = document.getElementById("copyout");
const pasteIn = document.getElementById("pastein");
const hideButton = document.getElementById("hidemodal");
hideButton.innerHTML = "√";
modal.classList.remove("hidden");
copyOut.classList.add("hidden");
pasteIn.classList.remove("hidden");
pasteIn.value = "";
return new Promise((resolve, reject) => {
let intervalId = setInterval(() => {
if (modal.classList.contains("hidden")){
resolve(pasteIn.value);
clearInterval(intervalId);
}
}, 100);
});
}
// close the modal
function hideModal(){
const modal = document.getElementById("modal");
modal.classList.add("hidden")
}
</script>
</head>
<body>
<div class="lds-grid centered" display><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
<!-- The WASM code will resize the canvas dynamically -->
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="hyperspeedcube_canvas" oncontextmenu="return false;"></canvas>
<!-- the div that holds the text to be copied or pasted -->
<div id="modal" class="hidden">
<pre id="copyout" class="hidden"></pre>
<textarea id="pastein" class="hidden" placeholder="Paste text here"></textarea>
<div id="hidemodal" class="div-button" onclick="hideModal();">X</div>
</div>
<!--Register Service Worker. this will cache the wasm / js scripts for offline use (for PWA functionality). -->
<!-- Force refresh (Ctrl + F5) to load the latest files instead of cached files -->
<script>
// We disable caching during development so that we always view the latest version.
if ('serviceWorker' in navigator && window.location.hash !== "#dev") {
window.addEventListener('load', function () {
navigator.serviceWorker.register('sw.js');
});
}
</script>
</body>
</html>
<!-- Powered by egui: https://github.com/emilk/egui/ -->