forked from evancz/elm-todomvc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
34 lines (27 loc) · 849 Bytes
/
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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Elm • TodoMVC</title>
<script type="text/javascript" src="elm.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
</body>
<script type="text/javascript">
var storedState = localStorage.getItem('elm-todo-state');
var startingState = storedState ? JSON.parse(storedState) : null;
var todomvc = Elm.fullscreen(Elm.Todo, { getStorage: startingState });
todomvc.ports.focus.subscribe(function(selector) {
setTimeout(function() {
var nodes = document.querySelectorAll(selector);
if (nodes.length === 1 && document.activeElement !== nodes[0]) {
nodes[0].focus()
}
}, 50);
});
todomvc.ports.setStorage.subscribe(function(state) {
localStorage.setItem('elm-todo-state', JSON.stringify(state));
});
</script>
</html>