-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
52 lines (52 loc) · 1.46 KB
/
app.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
42
43
44
45
46
47
48
49
50
51
52
const date_parser = (d) => {
let date = d.split('.')
return new Date(parseInt(date[2]), parseInt(date[1])-1, parseInt(date[0]))
}
window.onload = function() {
const app = new Vue({
el: '#app',
data: {
schedules: schedules,
messages: messages
},
methods: {
haslink: (meeting) => {
return meeting.link === null ? false : true
},
isAnnouncementValid: (announcement) => {
const today = new Date()
return date_parser(announcement.termination) <= today ? false : true
}
},
computed: {
validMessages: function () {
return messages.filter(this.isAnnouncementValid)
},
events: () => {
const f = (rule) => {
return (meeting) => {
date = date_parser(meeting.date)
const today = new Date()
today.setHours(0, 0, 0, 0) // only compare date
return rule(date, today)
}
}
const compare = (m1, m2) => {
let date1 = date_parser(m1.date)
let date2 = date_parser(m2.date)
return (date1 > date2) ? -1 : (date1 < date2 ? 1 : 0)
}
return [
{
header: 'Upcoming',
schedules: schedules.filter(f((a, b) => a >= b ? true : false)).sort(compare)
},
{
header: 'Finished',
schedules: schedules.filter(f((a, b) => a < b ? true : false)).sort(compare)
}
]
}
}
})
}