-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
377 lines (363 loc) · 20.6 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" type="image/png" href="favicon.png" />
<link rel="icon" type="image/png" href="favicon.png" />
<title>CrEval</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lexend:wght@100;300&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<link rel="stylesheet" href="style.css">
<script src="https://unpkg.com/bowser@2.4.0/es5.js"></script>
</head>
<header>
<h1 class="my-3">CrEval</h1>
</header>
<main>
<div class="container">
<div class="toast-container position-fixed bottom-0 end-0 p-3">
<div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true" data-bs-autohide="false">
<div class="toast-header">
<!-- <img src="..." class="rounded me-2" alt="..."> -->
<strong class="me-auto">CrEval</strong>
<small id="toastTime" data-event-time=""></small>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
Network change detected
</div>
</div>
</div>
<script>
function updateToastTime() {
const eventTime = new Date(document.getElementById('toastTime').getAttribute('data-event-time'));
const now = new Date();
const diffInMinutes = Math.floor((now - eventTime) / 60000);
const timeText = diffInMinutes === 0 ? 'just now' : `${diffInMinutes} ${1 === diffInMinutes ? 'min' : 'mins'} ago`;
document.getElementById('toastTime').textContent = timeText;
}
// Set the initial event time
function setEventTime() {
const now = new Date();
document.getElementById('toastTime').setAttribute('data-event-time', now.toISOString());
updateToastTime();
}
// Call the function to set the initial event time when the toast is displayed
document.addEventListener('DOMContentLoaded', (event) => {
setEventTime();
// Update the time every minute
setInterval(updateToastTime, 60000);
});
</script>
<script>
let type = navigator.connection.effectiveType;
const toastLiveExample = document.getElementById('liveToast')
function updateConnectionStatus() {
console.log(
`Connection type changed from ${type} to ${navigator.connection.effectiveType}`,
);
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
toastBootstrap.show()
type = navigator.connection.effectiveType;
}
navigator.connection.addEventListener("change", updateConnectionStatus);
</script>
<div class="row">
<div class="col-6">
<div class="card">
<h2 class="card-header">System Information</h2>
<div class="card-body">
<script>
var result = bowser.getParser(window.navigator.userAgent);
console.log(result);
document.write("You are using " + result.parsedResult.browser.name +
" v" + result.parsedResult.browser.version.split('.')[0] +
" on " + result.parsedResult.os.name);
</script>
<br/>
<script>document.write("Screen Size: " + screen.width + " X " + screen.height + " pixels");</script>
</div>
</div>
</div>
<div class="col-6">
<div class="card">
<h2 class="card-header">Battery</h2>
<div class="card-body">
<!-- battery.js writes its output to these divs -->
<div id="battery-status" style="text-align: center;">
<div id="battery-charging-status"></div>
<div id="battery-level" class="progress" role="progressbar" aria-label="Battery level" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar" style="width: 0%"></div>
</div>
<div id="battery-charging-time"></div>
<div id="battery-discharging-time"></div>
</div>
<!-- call battery.js *after* adding the above divs-->
<script src="battery.js"></script>
</div>
</div>
</div>
</div>
<div class="row my-3">
<div class="col-6">
<div class="card">
<h2 class="card-header">Speaker Test</h2>
<div class="card-body">
<script>
function playLeftSound(a){
var sound = new Audio(a);
sound.play();
}
function playRightSound(a){
var sound = new Audio(a);
sound.play();
}
</script>
<div id="sound-buttons">
<div id="semantron-buttons" style="display:flex; justify-content: center; column-gap: 16px;">
<button type="button" class="btn btn-primary" id="play-left" onclick="playLeftSound('audio/semantron-left.ogg')">
Left Speaker (Semantron, 3s)
</button>
<button type="button" class="btn btn-primary" id="play-right" onclick="playRightSound('audio/semantron-right.ogg')">
Right Speaker (Semantron, 3s)
</button>
</div>
<div id="ede-buttons" style="display:flex; justify-content: center; column-gap: 16px;">
<button type="button" class="btn btn-primary" id="play-left" onclick="playLeftSound('audio/ede-left.ogg')">
Left Speaker (Ede, 2s)
</button>
<button type="button" class="btn btn-primary" id="play-right" onclick="playRightSound('audio/ede-right.ogg')">
Right Speaker (Ede, 2s)
</button>
</div>
<div id="mallet-buttons" style="display:flex; justify-content: center; column-gap: 16px;">
<button type="button" class="btn btn-primary" id="play-left" onclick="playLeftSound('audio/mallet-left.ogg')">
Left Speaker (Mallet, 2s)
</button>
<button type="button" class="btn btn-primary" id="play-right" onclick="playRightSound('audio/mallet-right.ogg')">
Right Speaker (Mallet, 2s)
</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-6">
<div class="card">
<h2 class="card-header">Camera & Microphone Test</h2>
<div class="card-body text-center">
<video controls muted></video>
<canvas id="meter" width="500" height="50" style="z-index: 99999;"></canvas>
<button type="button" class="btn btn-primary">Resume/suspend volume meter</button>
<script src="volume-meter.js"></script>
<script src="main.js"></script>
</div>
</div>
</div>
</div>
<div class="card">
<h2 class="card-header">Keyboard Test</h2>
<div class="card-body d-flex justify-content-center">
<div class="keyboard">
<div style="display: flex;">
<div class="key" style="width: 1em; height: 1em;" id="escape"><span>Esc</span></div>
<div style="width: 1em; height: 1em; margin: 5px;"></div>
<div class="key" style="width: 1em; height: 1em;" id="f1"><span>F1</span></div>
<div class="key" style="width: 1em; height: 1em;" id="f2"><span>F2</span></div>
<div class="key" style="width: 1em; height: 1em;" id="f3"><span>F3</span></div>
<div class="key" style="width: 1em; height: 1em;" id="f4"><span>F4</span></div>
<div style="width: .5em; height: 1em; margin: 2.5px;"></div>
<div class="key" style="width: 1em; height: 1em;" id="f5"><span>F5</span></div>
<div class="key" style="width: 1em; height: 1em;" id="f6"><span>F6</span></div>
<div class="key" style="width: 1em; height: 1em;" id="f7"><span>F7</span></div>
<div class="key" style="width: 1em; height: 1em;" id="f8"><span>F8</span></div>
<div style="width: .5em; height: 1em; margin: 2.5px;"></div>
<div class="key" style="width: 1em; height: 1em;" id="f9"><span>F9</span></div>
<div class="key" style="width: 1em; height: 1em;" id="f10"><span>F10</span></div>
<div class="key" style="width: 1em; height: 1em;" id="f11"><span>F11</span></div>
<div class="key" style="width: 1em; height: 1em;" id="f12"><span>F12</span></div>
</div>
<div style="width: 1em; height: .2em; margin: 5px;"></div>
<div style="display: flex;">
<div class="key" style="width: 1em; height: 1em;" id="`"><span>~<br />`</span></div>
<div class="key" style="width: 1em; height: 1em;" id="1"><span>!<br />1</span></div>
<div class="key" style="width: 1em; height: 1em;" id="2"><span>@<br />2</span></div>
<div class="key" style="width: 1em; height: 1em;" id="3"><span>#<br />3</span></div>
<div class="key" style="width: 1em; height: 1em;" id="4"><span>$<br />4</span></div>
<div class="key" style="width: 1em; height: 1em;" id="5"><span>%<br />5</span></div>
<div class="key" style="width: 1em; height: 1em;" id="6"><span>^<br />6</span></div>
<div class="key" style="width: 1em; height: 1em;" id="7"><span>&<br />7</span></div>
<div class="key" style="width: 1em; height: 1em;" id="8"><span>*<br />8</span></div>
<div class="key" style="width: 1em; height: 1em;" id="9"><span>(<br />9</span></div>
<div class="key" style="width: 1em; height: 1em;" id="0"><span>)<br />0</span></div>
<div class="key" style="width: 1em; height: 1em;" id="-"><span>_<br />-</span></div>
<div class="key" style="width: 1em; height: 1em;" id="="><span>+<br />=</span></div>
<div class="key" style="width: calc(2em + 10px); height: 1em;" id="backspace"><span>Backspace</span></div>
</div>
<div style="display: flex; position: relative;">
<div class="key" style="width: calc(1.5em + 5px); height: 1em;" id="tab"><span>Tab</span></div>
<div class="key" style="width: 1em; height: 1em;" id="q"><span>Q</span></div>
<div class="key" style="width: 1em; height: 1em;" id="w"><span>W</span></div>
<div class="key" style="width: 1em; height: 1em;" id="e"><span>E</span></div>
<div class="key" style="width: 1em; height: 1em;" id="r"><span>R</span></div>
<div class="key" style="width: 1em; height: 1em;" id="t"><span>T</span></div>
<div class="key" style="width: 1em; height: 1em;" id="y"><span>Y</span></div>
<div class="key" style="width: 1em; height: 1em;" id="u"><span>U</span></div>
<div class="key" style="width: 1em; height: 1em;" id="i"><span>I</span></div>
<div class="key" style="width: 1em; height: 1em;" id="o"><span>O</span></div>
<div class="key" style="width: 1em; height: 1em;" id="p"><span>P</span></div>
<div class="key" style="width: 1em; height: 1em;" id="["><span>{<br />[</span></div>
<div class="key" style="width: 1em; height: 1em;" id="]"><span>}<br />]</span></div>
<div class="key" style="width: calc(1.5em + 5px); height: 1em;" id="\"><span>|<br />\</span></div>
</div>
<div style="display: flex;">
<div class="key" style="width: calc(1.7em + 10px); height: 1em;" id="lmeta"><span>🔍</span></div>
<div class="key" style="width: 1em; height: 1em;" id="a"><span>A</span></div>
<div class="key" style="width: 1em; height: 1em;" id="s"><span>S</span></div>
<div class="key" style="width: 1em; height: 1em;" id="d"><span>D</span></div>
<div class="key" style="width: 1em; height: 1em;" id="f"><span>F</span></div>
<div class="key" style="width: 1em; height: 1em;" id="g"><span>G</span></div>
<div class="key" style="width: 1em; height: 1em;" id="h"><span>H</span></div>
<div class="key" style="width: 1em; height: 1em;" id="j"><span>J</span></div>
<div class="key" style="width: 1em; height: 1em;" id="k"><span>K</span></div>
<div class="key" style="width: 1em; height: 1em;" id="l"><span>L</span></div>
<div class="key" style="width: 1em; height: 1em;" id=";"><span>:<br />;</span></div>
<div class="key" style="width: 1em; height: 1em;" id="'"><span>"<br />'</span></div>
<div class="key" style="width: calc(2.3em + 10px); height: 1em;" id="enter"><span>Enter</span></div>
</div>
<div style="display: flex; position: relative;">
<div class="key" style="width: calc(2.2em + 15px); height: 1em;" id="lshift"><span>Shift</span></div>
<div class="key" style="width: 1em; height: 1em;" id="z"><span>Z</span></div>
<div class="key" style="width: 1em; height: 1em;" id="x"><span>X</span></div>
<div class="key" style="width: 1em; height: 1em;" id="c"><span>C</span></div>
<div class="key" style="width: 1em; height: 1em;" id="v"><span>V</span></div>
<div class="key" style="width: 1em; height: 1em;" id="b"><span>B</span></div>
<div class="key" style="width: 1em; height: 1em;" id="n"><span>N</span></div>
<div class="key" style="width: 1em; height: 1em;" id="m"><span>M</span></div>
<div class="key" style="width: 1em; height: 1em;" id=","><span><br />,</span></div>
<div class="key" style="width: 1em; height: 1em;" id="."><span>><br />.</span></div>
<div class="key" style="width: 1em; height: 1em;" id="/"><span>?<br />/</span></div>
<div class="key" style="width: calc(2.8em + 15px); height: 1em;" id="rshift"><span>Shift</span></div>
<div style="width: .2em; height: 1em; margin: 1px;"></div>
<div style="width: 1em; height: 1em; margin: 5px;"></div>
</div>
<div style="display: flex;">
<div class="key" style="width: calc(2.2em + 10px); height: 1em;" id="lcontrol"><span>Control</span></div>
<div class="key" style="width: calc(2.2em + 7px); height: 1em;" id="lalt"><span>Alt</span></div>
<div class="key" style="width: calc(5.3em + 10px); height: 1em;" id=" "><span>Space</span></div>
<div class="key" style="width: calc(1.2em + 8px); height: 1em;" id="ralt"><span>Alt</span></div>
<div class="key" style="width: calc(1.2em + 5px); height: 1em;" id="rcontrol"><span>Control</span></div>
<div style="width: .2em; height: 1em; margin: 1px;"></div>
<div class="key" style="width: 1em; height: 1em;" id="arrowleft"><span>⭠</span></div>
<div style="display: flex; flex-direction: column; height: .75em;">
<div class="key" style="width: 1em; height: .45em;" id="arrowup"><span>⭡</span></div>
<div class="key" style="width: 1em; height: .45em;" id="arrowdown"><span>⭣</span></div>
</div>
<div class="key" style="width: 1em; height: 1em;" id="arrowright"><span>⭢</span></div>
</div>
</div>
</div>
</div>
<div class="card mt-3">
<h2 class="card-header">Attribution</h2>
<div class="card-body text-center">
<p>Camera & Microphone Test based on <a href="https://github.com/escarlson/VideoStreamVolumeMeterSample">VideoStreamVolumeMeterSample</a> by Steven Carlson, itself based on <a href="https://github.com/SergeyZaligin/VideoStreamVolumeMeterSample">a work</a> by Sergey Zaligin</a></p>
<p>Keyboard Test based on <a href="https://github.com/Tarocch1/keyboard-tester">Keyboard Tester by Tarocch1</a> released under the MIT License</p>
<p>Favicon by <a href="https://commons.wikimedia.org/wiki/File:Electron_shell_024_Chromium_-_no_label.svg">Pumbaa (original work by Greg Robson)</a>, <a href="https://creativecommons.org/licenses/by-sa/2.0/uk/deed.en">CC BY-SA 2.0 UK</a>, via Wikimedia Commons</p>
<p>Mallet sound copyright 2013, Canonical Ltd. CC-BY-SA-3.0</p>
</div>
</div>
</div>
<script>
const numMap = {
home: 'num7',
end: 'num1',
pageup: 'num9',
pagedown: 'num3',
arrowup: 'num8',
arrowdown: 'num2',
arrowleft: 'num4',
arrowright: 'num6',
clear: 'num5',
insert: 'num0',
delete: 'num.',
};
const keyInstBg = '#ffff00';
const keyPressedBg = "#227ae5";
const lrMap = ['l', 'r'];
window.addEventListener('keydown', onKeyDownHandle);
window.addEventListener('keyup', onKeyUpHandle);
function onKeyDownHandle(e) {
e.preventDefault();
console.log(e.key);
const keyName = e.key.toLowerCase();
if (['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.', '/', '-', 'enter'].indexOf(keyName) !== -1) {
if (e.location === 3) {
const key = document.getElementById("num" + keyName);
key.style.background = keyInstBg;
return;
}
}
if (['BrowserForward', 'home', 'end', 'pageup', 'pagedown', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright', 'clear', 'insert', 'delete'].indexOf(keyName) !== -1) {
if (e.location === 3) {
const key = document.getElementById(numMap[keyName]);
key.style.background = keyInstBg;
return;
}
}
if (['shift', 'control', 'alt', 'meta'].indexOf(keyName) !== -1) {
const key = document.getElementById(lrMap[e.location - 1] + keyName);
key.style.background = keyInstBg;
return;
}
const key = document.getElementById(keyName);
key.style.background = keyInstBg;
}
function onKeyUpHandle(e) {
e.preventDefault();
console.log(e.key);
const keyName = e.key.toLowerCase();
if (['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.', '/', '-', 'enter'].indexOf(keyName) !== -1) {
if (e.location === 3) {
const key = document.getElementById("num" + keyName);
//key.style.background = 'initial';
key.style.background = keyPressedBg;
return;
}
}
if (['home', 'end', 'pageup', 'pagedown', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright', 'clear', 'insert', 'delete'].indexOf(keyName) !== -1) {
if (e.location === 3) {
const key = document.getElementById(numMap[keyName]);
// key.style.background = 'initial';
key.style.background = keyPressedBg;
return;
}
}
if (['shift', 'control', 'alt', 'meta'].indexOf(keyName) !== -1) {
const key = document.getElementById(lrMap[e.location - 1] + keyName);
// key.style.background = 'initial';
key.style.background = keyPressedBg;
return;
}
if (keyName === 'printscreen') {
const key = document.getElementById(keyName);
key.style.background = keyInstBg;
const timer = setTimeout(function() {
// key.style.background = 'initial';
clearTimeout(timer);
}, 100);
return;
}
const key = document.getElementById(keyName);
// key.style.background = 'initial';
key.style.background = keyPressedBg;
}
</script>
</div>
</container>
</main>
</html>