-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
42 lines (34 loc) · 1.1 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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Thelm</title>
<meta name="description" content="Save small notes and link on your browser">
<meta name="theme-color" content="#34495e">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css2?family=Karla&display=swap" rel="stylesheet">
<link rel="stylesheet" href="./styles.css">
</head>
<body>
<div id="app"></div>
<script src="./app.js"></script>
<script>
var storageKey = 'thelm';
// Restore data from localStorage, if present
var storedState = localStorage.getItem(storageKey);
var startingState = storedState ? JSON.parse(storedState) : null;
// Initialise app
var appContainer = document.getElementById('app');
var app = Elm.Main.init({
node: appContainer,
flags: startingState,
});
// Save data in localStorage
app.ports.storeReferences.subscribe(function (references) {
if (references.length === 0) return;
var referencesJson = JSON.stringify(references);
localStorage.setItem(storageKey, referencesJson);
});
</script>
</body>
</html>