-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
41 lines (35 loc) · 1.19 KB
/
index.js
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
// import './main.css';
import {
Main
} from './Main.elm';
import registerServiceWorker from './registerServiceWorker';
import bannerSrc from "./Images/skyline.jpg";
const pack = require('../package.json');
const packElm = require('../elm-package.json');
registerServiceWorker();
const elmSpa = Main.fullscreen({
localStorage: (localStorage.getItem("spa") || ""),
packVersion: pack.version,
packElmVersion: packElm.version,
bannerSrc: bannerSrc,
width: window.innerWidth,
height: window.innerHeight
});
elmSpa.ports.urlChange.subscribe(function(title) {
document.body.classList.add("urlChange");
setTimeout(function() {
document.body.classList.remove("urlChange");
}, 100)
window.requestAnimationFrame(function() {
document.title = title;
document.querySelector('meta[name="description"]').setAttribute("content", title);
});
});
elmSpa.ports.storeLocalStorage.subscribe(function(value) {
localStorage.setItem("spa", value);
});
window.addEventListener("storage", function(event) {
if (event.storageArea === localStorage && event.key === "spa") {
elmSpa.ports.onLocalStorageChange.send(event.newValue);
}
}, false);;