-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeCalc.html
47 lines (47 loc) · 1.99 KB
/
TimeCalc.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
</head>
<body>
<script src="TimeCalc.js"></script>
<div id="timeCalcDiv" style="margin-bottom:10px; position:relative;border:1px solid #BCBCBC;width:180px;text-align:center;font-family:arial,verdana;"></div>
<script>
var app = Elm.TimeCalc.init({node : document.getElementById('timeCalcDiv')});
app.ports.openWindow.subscribe(function (goTo) {
var url = goTo[0];
var asNewTab = goTo[1];
if(asNewTab) {
window.open(url, "_blank");
} else {
window.open(url);
}
});
app.ports.pushDataToClipboard.subscribe(function(text){
var span = document.querySelector('#'+text);
span.select();
document.execCommand('copy');
});
app.ports.pushDataToStore.subscribe(function (to2) {
var TimeCalcObject = {taskList: to2.tasks, showTaskNameForm: to2.showTaskNameForm, showCalcForm: to2.showCalcForm, apiList: to2.apiList};
if(!to2.initialise) {
window.localStorage.setItem('TimeCalc', JSON.stringify(TimeCalcObject));
}
TimeCalcObject = JSON.parse(window.localStorage.getItem('TimeCalc'));
if(TimeCalcObject != null) {
taskList = TimeCalcObject.taskList;
showTaskNameForm = TimeCalcObject.showTaskNameForm;
showCalcForm = TimeCalcObject.showCalcForm;
apiList = TimeCalcObject.apiList;
}
var min=10000;
var max=2147483647;
var random = Math.floor(Math.random() * (+max - +min)) + +min
if (typeof taskList !== 'undefined') {
app.ports.setDataFromStore.send({tasks: taskList, showTaskNameForm: showTaskNameForm, showCalcForm: showCalcForm, random: random, apiList: apiList});
}
});
</script>
</body>
</html>