-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.html
executable file
·99 lines (91 loc) · 3.11 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='utf-8'>
<meta n:00ame="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>VueJS Calender</title>
<link href='demo.css' rel='stylesheet'>
<script src="https://momentjs.com/downloads/moment.js"></script>
</head>
<body>
<div id='demo-control'>
<p id="p1">Debug Panel - <span></span></p>
<input id="cb1" type="checkbox">
<label for="cb1">show half hour label</label>
<br>
<input type="button" id="btn1" value="show view data">
<input type="button" id="btn2" value="clear view">
<input type="button" id="btn3" value="jump to date">
<input type="button" id="btn4" value="show all cached data">
<!-- <input type="button" id="btn5" value="save current week"> -->
<!-- <input type="button" id="btn6" value="load current week"> -->
</div>
<div id="demo-container">
<calender
@push="push"
@pull="pull"
@pull_overlay="pull_overlay"
></calender>
</div> <!-- container -->
</body>
<script src="https://vuejs.org/js/vue.js"></script>
<script src="calender.vue" type="vue"></script>
<script src="vueify.js/vueify.js"></script>
<script>
Vue.use(Vueify);
var app = new Vue({
el: '#demo-container',
methods: {
// pull overlay data from server
pull_overlay: function(from_date, to_date, resolve, reject) {
from_date = from_date.format('YYYY-MM-DD');
to_date = to_date.format('YYYY-MM-DD');
var xhr = new XMLHttpRequest();
xhr.onload = function() {
if (this.status>=200 && this.status<=300) {
var spans_remote = JSON.parse(this.responseText);
console.log("fetched overlay", spans_remote);
resolve(spans_remote);
} else {
reject(this.status);
}
};
xhr.open("GET", `api/calendar_overlay?from=${from_date}&to=${to_date}`);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send();
},
// push to server
push: function(spans) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
// one-way sync, we don't care about server's return
console.log("pushed", JSON.parse(this.responseText));
};
xhr.open("PUT", "api/calendar");
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(spans));
},
// pull from server
pull: function(from_date, to_date, resolve, reject) {
from_date = from_date.format('YYYY-MM-DD');
to_date = to_date.format('YYYY-MM-DD');
var xhr = new XMLHttpRequest();
xhr.onload = function() {
if (this.status>=200 && this.status<=300) {
var spans_remote = JSON.parse(this.responseText);
console.log("fetched", spans_remote);
resolve(spans_remote);
} else {
reject(this.status);
}
};
xhr.open("GET", `api/calendar?from=${from_date}&to=${to_date}`);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send();
}
}
});
</script>
<script src="demo.js"></script>
</html>