-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·37 lines (37 loc) · 1.37 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link href="pub/screen.css" type="text/css" rel="stylesheet" />
</head>
<body id="app">
<div id='hpDiv'></div>
<script src="pub/HolidayPlan.js"></script>
<script>
var app = Elm.HolidayPlan.init({node : document.getElementById('hpDiv')});
app.ports.getDimOfElement.subscribe(function (id) {
var width = document.getElementById(id).offsetWidth;
var height = document.getElementById(id).offsetHeight;
app.ports.setDimOfElement.send({height:height, width:width});
});
app.ports.pushDataToStore.subscribe(function (obj) {
var min=10000;
var max=2147483647;
var random = Math.floor(Math.random() * (+max - +min)) + +min
if(!obj.init) {
window.localStorage.setItem('HolidayPlan', JSON.stringify(obj));
}
var HolObj = JSON.parse(window.localStorage.getItem('HolidayPlan'));
if(HolObj == null) {
HolObj = obj;
}
var config = HolObj.config;
config.random = random;
if (typeof config !== 'undefined') {
app.ports.setDataFromStore.send(HolObj);
}
});
</script>
</body>
</html>