1
0
Fork 0
mirror of https://github.com/Kunsi/pretalx-plugin-broadcast-tools synced 2024-11-01 02:25:49 +00:00
pretalx-plugin-broadcast-tools/pretalx_broadcast_tools/static/pretalx_broadcast_tools/generic.js

70 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-11-20 08:05:08 +00:00
schedule = null;
event_info = null;
2021-11-20 08:05:08 +00:00
function get_current_talk() {
room_name = get_room_name();
2021-11-20 08:05:08 +00:00
if (!room_name) {
return null;
2021-11-20 08:05:08 +00:00
}
current_talk = null;
for (let offset = 0; offset <= 5; offset++) {
time_start = new Date(Date.now() + offset*60000).getTime();
time_end = new Date(Date.now() - offset*60000).getTime();
2021-11-20 08:05:08 +00:00
for (talk_i in schedule['talks']) {
talk = schedule['talks'][talk_i]
if (schedule['rooms'].length > 1 && talk['room'] != room_name) {
// not in this room
continue;
}
2021-11-20 08:05:08 +00:00
talk_start = new Date(talk['start']).getTime();
talk_end = new Date(talk['end']).getTime();
if (talk_start < time_start && talk_end > time_end) {
current_talk = talk;
break;
}
}
2021-11-20 08:05:08 +00:00
if (current_talk) {
break;
2021-11-20 08:05:08 +00:00
}
}
return current_talk;
}
2021-11-20 08:22:16 +00:00
function get_room_name() {
room_name = null;
try {
hash = decodeURIComponent(window.location.hash.substring(1));
room_name = hash;
} catch (e) {
console.error(e);
2021-11-20 08:05:08 +00:00
}
return room_name;
2021-11-20 08:05:08 +00:00
}
function update_schedule() {
$.getJSON('../event.json', function(data) {
event_info = data;
});
$.getJSON('../schedule.json', function(data) {
if ('error' in data) {
console.error(data['error']);
} else {
console.info('schedule updated with ' + data['talks'].length + ' talks in ' + data['rooms'].length + ' rooms');
}
2021-11-20 08:05:08 +00:00
schedule = data;
window.setTimeout(update_schedule, 30000);
});
}
update_schedule();