-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
61 lines (56 loc) · 1.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cubik</title>
<style>
html,
head,
body {
padding: 0;
margin: 0;
}
body {
background: #010140;
}
</style>
</head>
<body>
<div id="elm"></div>
<script src="elm.js"></script>
<script>
// Load initial state from localStorage
var initialState;
try {
initialState = JSON.parse(localStorage.getItem('elm-cubik')) || {};
} catch (e) {
initialState = {};
}
var app = Elm.Main.init({
node: document.getElementById('elm'),
flags: Object.assign(
{
width: innerWidth,
height: innerHeight,
devicePixelRatio: devicePixelRatio
},
initialState || {}
)
});
app.ports.save.subscribe(function (state) {
// Save game state to localStorage
localStorage.setItem('elm-cubik', state)
});
// Prevent scrolling with arrow and space keys
window.addEventListener('keydown', function (e) {
if ([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) {
e.preventDefault();
}
}, false);
// Capture focus
window.focus();
</script>
</body>
</html>