forked from JesperDramsch/python-deadlines
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalendar.js
More file actions
222 lines (200 loc) · 7.91 KB
/
Copy pathcalendar.js
File metadata and controls
222 lines (200 loc) · 7.91 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
// calendar data template
var calendar_data = {
clickDay: function (e) {
if (e.events.length > 0) {
for (var i in e.events) {
window.open("{{site.baseurl}}/conference/" + e.events[i].abbreviation, "_self")
}
}
},
mouseOnDay: function (e) {
if (e.events.length > 0) {
var content = "";
for (var i in e.events) {
var headline_color = "";
var break_html = '<hr>';
var location_html = '<img src="/static/img/072-location.svg" className="own-badge" alt="Location icon" width="16" height="16"/> ' + e.events[i].location;
var date_html = '<img src="/static/img/084-calendar.svg" className="own-badge" alt="Calendar icon" width="16" height="16"/> ' + e.events[i].date;
var badges_html = "";
var subs = e.events[i].subject.split(',');
for (let i = 0; i < subs.length; i++) {
var sub = subs[i].replace(" ", "");
badges_html += '<span class="conf-sub conf-badge-small">' + sub + '</span>'
}
if (i == e.events.length - 1) {
break_html = '';
}
if (e.events[i].id.endsWith("deadline")) {
headline_color = 'deadline-text';
} else {
}
content +=
'<div class="event-tooltip-content position-relative">' +
'<div class="event-name ' + headline_color + '">' +
'<b><a href="{{site.baseurl}}/conference/' + e.events[i].abbreviation + '" class="stretched-link">' + e.events[i].name + '</a></b>' +
'</div>' +
'<div class="event-location">' +
location_html +
'<br>' +
date_html +
'<br>' +
badges_html +
'</div>' +
break_html +
'</div>';
}
$(e.element).popover({
trigger: "manual",
container: "body",
html: true,
content: content,
});
$(e.element).popover("show");
timeoutPopover(e);
}
},
focusoutDay: function (e) {
// if (e.events.length > 0) {
// $(e.element).popover("hide");
// }
timeoutPopover(e);
},
customDayRenderer: function (cellContent, currentDate) {
var today = new Date();
// render today
if (today.getFullYear() === currentDate.getFullYear() && today.getMonth() === currentDate.getMonth() && today.getDate() === currentDate.getDate()) {
cellContent.style = "background-color: gray;";
}
},
dayContextMenu: function (e) {
// $(e.element).popover("hide");
timeoutPopover(e);
},
dataSource: conf_list_all
}
// Function to show the popover
function timeoutPopover(e) {
// Ensure e has a property to store the timeout if it doesn't already exist
if (!e.hidePopoverTimeout) {
e.hidePopoverTimeout = null;
}
// Mouse enter event for the calendar item to show the popover
$(e.element).mouseover(function() {
clearTimeout(e.hidePopoverTimeout); // Cancel any pending hide operation
$(e.element).popover('show');
});
// Mouse leave event for the calendar item to hide the popover
$(e.element).mouseout(function() {
// Start a timeout when leaving the element, gives a buffer time to move to the popover
e.hidePopoverTimeout = setTimeout(function() {
$(e.element).popover('hide');
}, 300); // Adjust delay as needed
});
// Prevent popover from hiding when mouse is over the popover
$("body").on('mouseover', '.popover', function() {
clearTimeout(e.hidePopoverTimeout);
}).on('mouseout', '.popover', function() {
// Hide the popover when leaving it after a delay, allows returning to the calendar item
e.hidePopoverTimeout = setTimeout(function() {
$(e.element).popover('hide');
}, 300); // Adjust delay as needed
});
}
function load_conference_list() {
// Gather data
var conf_list_all = [];
{% for conf in site.data.conferences + site.data.archive %}
{% if conf.cfp_ext %}
{% assign cfp = conf.cfp_ext %}
{% assign extended = "(extended)" %}
{% else %}
{% assign cfp = conf.cfp %}
{% endif %}
{% capture conf_date %}{%- translate_file dates/pretty_dates.html start=conf.start end=conf.end -%}{% endcapture %}
// add deadlines in red
conf_list_all.push({
id: "{{conf.conference | slugify: "latin"}}-{{conf.year}}-deadline",
abbreviation: "{{conf.conference | slugify: "latin"}}-{{conf.year}}",
name: "{{conf.conference}} {{conf.year}} CfP {{extended}}",
color: "red",
location: "{{conf.place}}",
date: "{{conf_date | strip}}",
subject: "{{conf.sub}}",
startDate: Date.parse("{{cfp}}"),
endDate: Date.parse("{{cfp}}"),
});
{% if conf.workshop_deadline %}
conf_list_all.push({
id: "{{conf.conference | slugify: "latin"}}-{{conf.year}}-deadline",
abbreviation: "{{conf.conference | slugify: "latin"}}-{{conf.year}}",
name: "{{conf.conference}} {{conf.year}} Workshop Deadline",
color: "red",
location: "{{conf.place}}",
date: "{{ conf_date | strip }}",
subject: "{{conf.sub}}",
startDate: Date.parse("{{conf.workshop_deadline}}"),
endDate: Date.parse("{{conf.workshop_deadline}}"),
});
{% endif %}
{% if conf.tutorial_deadline %}
conf_list_all.push({
id: "{{conf.conference | slugify: "latin"}}-{{conf.year}}-deadline",
abbreviation: "{{conf.conference | slugify: "latin"}}-{{conf.year}}",
name: "{{conf.conference}} {{conf.year}} Tutorial Deadline",
color: "red",
location: "{{conf.place}}",
date: "{{ conf_date | strip }}",
subject: "{{conf.sub}}",
startDate: Date.parse("{{cfp}}"),
endDate: Date.parse("{{cfp}}"),
});
{% endif %}
// add Conferences in chosen color
{% if conf.start != "" %}
var color = "black";
{% assign conf_sub = conf.sub | split: ',' | first | strip %} // use first sub to choose color
{% for type in site.data.types %}
{% if conf_sub == type.sub %}
color = "{{type.color}}";
{% endif %}
{% endfor %}
conf_list_all.push({
id: "{{conf.conference | slugify: "latin"}}-{{conf.year}}-conference",
abbreviation: "{{conf.conference | slugify: "latin"}}-{{conf.year}}",
name: "{{conf.conference}} {{conf.year}}",
color: color,
location: "{{conf.place}}",
date: "{{ conf_date | strip }}",
subject: "{{conf.sub}}",
startDate: Date.parse("{{conf.start}}"),
endDate: Date.parse("{{conf.end}}"),
});
{% endif %}
{% endfor %}
return conf_list_all;
}
function update_filtering(data) {
// Defensive check for data parameter
if (!data || typeof data !== 'object' || !data.subs || !Array.isArray(data.subs)) {
console.error('calendar update_filtering called with invalid data:', data);
return;
}
store.set('{{site.domain}}-subs', {subs: data.subs, timestamp: new Date().getTime()});
conf_list = conf_list_all.filter(v => {
var commonValues = data.subs.filter(function (value) {
return v.subject.indexOf(value) > -1;
});
var subject_match = commonValues.length > 0;
return subject_match;
});
// rerender calendar
calendar_data['dataSource'] = conf_list; // need to update only this
calendar_data['language'] = "{{site.lang}}";
calendar = new Calendar("#calendar-page", calendar_data);
if (data.subs.length === 0 || data.subs.length == data.all_subs.length) {
window.history.pushState('', '', page_url);
} else {
// Join the selected values into a query parameter
window.history.pushState('', '', page_url + '?sub=' + data.subs.join());
}
}