-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
36 lines (34 loc) · 1.03 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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Time Cube</title>
<script type="text/javascript" src="timer.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body></body>
<script type="text/javascript">
var storedState = localStorage.getItem('timer-state');
var thingy = Elm.Timer.fullscreen(storedState ? JSON.parse(storedState) : null);
thingy.ports.setStorage.subscribe(function(state) {
localStorage.setItem('timer-state', JSON.stringify(state));
});
thingy.ports.scrollBottom.subscribe(function(selector) {
setTimeout(function() {
var s = document.querySelector(selector);
s.scrollTop = s.scrollHeight;
}, 50);
});
thingy.ports.alert.subscribe(function(msg) {
alert(msg);
})
var scrambleworker = new Worker("scramble.js");
thingy.ports.scrambleReq.subscribe(function({len, val: type}) {
console.log("getting scramble", len, type)
scrambleworker.postMessage({len, type});
});
scrambleworker.onmessage = ({data}) => {
thingy.ports.scrambleRes.send(data.scramble);
};
</script>
</html>