-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom.js
71 lines (62 loc) · 2.17 KB
/
custom.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
$(function() {
var range = {
start: moment(new Date().setDate(new Date().getDate() - beforeDay)).format('YYYY-MM-DD'),
end: moment(new Date().setDate(new Date().getDate() + afterDay + 1)).format('YYYY-MM-DD')
};
var lastUpdate;
setInterval(function() {
// Check connectivity to Google calendars APIs
var key = googleApiKey;
var account = events[0]['googleCalendarId'];
$.ajax({
url : 'https://www.googleapis.com/calendar/v3/calendars/' + account + '/events',
type : 'GET',
data : 'key=' + key,
timeout: 3000,
success : function(result) {
lastUpdate = new Date();
$('#info').hide();
$('#info').html('');
//Update events on calendars
$('#calendar').fullCalendar('refetchEvents');
},
error : function(error) {
function addZ(n) { return n < 10 ? '0' + n : '' + n; }
var date = addZ(lastUpdate.getDate()) + "." + addZ(lastUpdate.getMonth() + 1) + "." + lastUpdate.getFullYear();
var time = addZ(lastUpdate.getHours()) + ":" + addZ(lastUpdate.getMinutes());
$('#info').show();
$('#info').html('Dernière actualisation ' + date + ' ' + time);
}
});
// Update range of visibility
var newRange = {
start: moment(new Date().setDate(new Date().getDate() - beforeDay)).format('YYYY-MM-DD'),
end: moment(new Date().setDate(new Date().getDate() + afterDay + 1)).format('YYYY-MM-DD')
};
if(!(JSON.stringify(range) === JSON.stringify(newRange))) {
range = newRange;
$('#calendar').fullCalendar('option', 'visibleRange', range);
}
}, refreshDelay * 1000);
$('#calendar').fullCalendar({
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
height: 'auto',
themeSystem: 'bootstrap4',
header: false,
weekNumbers: false,
defaultView: 'agenda',
visibleRange: range,
allDaySlot: false,
minTime: "08:00:00",
maxTime: "23:00:00",
nowIndicator: true,
displayEventTime: false,
slotLabelFormat: 'H:mm',
selectable: true,
selectHelper: true,
editable: false,
googleCalendarApiKey: googleApiKey,
eventSources: events
});
lastUpdate = new Date();
});