-
-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathindex.html
67 lines (57 loc) · 1.51 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
<!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>Elm-flatris</title>
<style>
html,
head,
body {
padding: 0;
margin: 0;
}
body {
font-family: sans-serif;
background: #fff;
}
a {
color: inherit;
font-weight: 700;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</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-flatris'));
} catch (e) {
}
var app = Elm.Flatris.init({
node: document.getElementById('elm'),
flags: initialState
});
app.ports.save.subscribe(function (state) {
// Save game state to localStorage
localStorage.setItem('elm-flatris', 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>