mirror of
https://github.com/Kunsi/pretalx-plugin-broadcast-tools
synced 2024-11-24 02:51:07 +00:00
fix all the javascript i broke
This commit is contained in:
parent
90c50c9652
commit
410ca28b79
3 changed files with 62 additions and 57 deletions
|
@ -1,5 +1,6 @@
|
||||||
schedule = null;
|
schedule = null;
|
||||||
event_info = null;
|
event_info = null;
|
||||||
|
req = {};
|
||||||
|
|
||||||
function get_current_talk(max_offset) {
|
function get_current_talk(max_offset) {
|
||||||
room_name = get_room_name();
|
room_name = get_room_name();
|
||||||
|
@ -88,27 +89,31 @@ function format_time_from_pretalx(from_pretalx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function xhr_get(url, callback_func) {
|
function xhr_get(url, callback_func) {
|
||||||
req = new XMLHttpRequest();
|
req[url] = new XMLHttpRequest();
|
||||||
req.timeout = 10000;
|
req[url].timeout = 10000;
|
||||||
req.open('GET', url);
|
req[url].onreadystatechange = () => {
|
||||||
req.setRequestHeader('Accept', 'application/json');
|
if (req[url].readyState === 4) {
|
||||||
req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
if (req[url].status != 200) {
|
||||||
req.addEventListener('load', function(event) {
|
|
||||||
if (req.status != 200) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback_func(event);
|
callback_func(req[url].responseText);
|
||||||
});
|
}
|
||||||
req.send();
|
};
|
||||||
|
req[url].open('GET', url);
|
||||||
|
req[url].setRequestHeader('Accept', 'application/json');
|
||||||
|
req[url].setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||||
|
req[url].send();
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_schedule() {
|
function update_schedule() {
|
||||||
xhr_get('../event.json', function() {
|
xhr_get('../event.json', function(text) {
|
||||||
event_info = JSON.parse(req.responseText);
|
console.log("events: " + text);
|
||||||
|
event_info = JSON.parse(text);
|
||||||
});
|
});
|
||||||
xhr_get('../schedule.json', function() {
|
xhr_get('../schedule.json', function(text) {
|
||||||
data = JSON.parse(req.responseText);
|
console.log("schedule: " + text);
|
||||||
|
data = JSON.parse(text);
|
||||||
if ('error' in data) {
|
if ('error' in data) {
|
||||||
console.error(data['error']);
|
console.error(data['error']);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,40 +7,40 @@ function update_lower_third() {
|
||||||
}
|
}
|
||||||
|
|
||||||
box = document.getElementById('broadcast_tools_lower_thirds_box');
|
box = document.getElementById('broadcast_tools_lower_thirds_box');
|
||||||
title = document.getElementById('broadcast_tools_lower_thirds_title').innerHTML;
|
title = document.getElementById('broadcast_tools_lower_thirds_title');
|
||||||
speaker = document.getElementById('broadcast_tools_lower_thirds_speaker').innerHTML;
|
speaker = document.getElementById('broadcast_tools_lower_thirds_speaker');
|
||||||
infoline = document.getElementById('broadcast_tools_lower_thirds_infoline').innerHTML;
|
infoline = document.getElementById('broadcast_tools_lower_thirds_infoline');
|
||||||
|
|
||||||
box.style.backgroundColor = event_info['color']);
|
box.style.backgroundColor = event_info['color'];
|
||||||
|
|
||||||
if (!schedule) {
|
if (!schedule) {
|
||||||
title = 'Waiting for schedule ...';
|
title.innerHTML = 'Waiting for schedule ...';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('error' in schedule) {
|
if ('error' in schedule) {
|
||||||
title = 'Error';
|
title.innerHTML = 'Error';
|
||||||
speaker = schedule['error'].join('<br>');
|
speaker.innerHTML = schedule['error'].join('<br>');
|
||||||
infoline = '';
|
infoline.innerHTML = '';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
|
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
|
||||||
title = 'Error';
|
title.innerHTML = 'Error';
|
||||||
speaker = 'Invalid room_name. Valid names: ' + schedule['rooms'].join(', ');
|
speaker.innerHTML = 'Invalid room_name. Valid names: ' + schedule['rooms'].join(', ');
|
||||||
infoline = '';
|
infoline.innerHTML = '';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
current_talk = get_current_talk(5);
|
current_talk = get_current_talk(5);
|
||||||
if (current_talk) {
|
if (current_talk) {
|
||||||
title = current_talk['title'];
|
title.innerHTML = current_talk['title'];
|
||||||
speaker = current_talk['persons'].join(', ');
|
speaker.innerHTML = current_talk['persons'].join(', ');
|
||||||
infoline = current_talk['infoline'];
|
infoline.innerHTML = current_talk['infoline'];
|
||||||
} else {
|
} else {
|
||||||
title = event_info['no_talk'];
|
title.innerHTML = event_info['no_talk'];
|
||||||
speaker = '';
|
speaker.innerHTML = '';
|
||||||
infoline = '';
|
infoline.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_talk && current_talk['track']) {
|
if (current_talk && current_talk['track']) {
|
||||||
|
|
|
@ -7,36 +7,36 @@ function update_room_info() {
|
||||||
}
|
}
|
||||||
|
|
||||||
box = document.getElementById('broadcast_tools_room_info');
|
box = document.getElementById('broadcast_tools_room_info');
|
||||||
roomname = document.getElementById('broadcast_tools_room_info_roomname').innerHTML;
|
roomname = document.getElementById('broadcast_tools_room_info_roomname');
|
||||||
title = document.getElementById('broadcast_tools_room_info_title').innerHTML;
|
title = document.getElementById('broadcast_tools_room_info_title');
|
||||||
speaker = document.getElementById('broadcast_tools_room_info_speaker').innerHTML;
|
speaker = document.getElementById('broadcast_tools_room_info_speaker');
|
||||||
qr = document.getElementById('broadcast_tools_room_info_qr').innerHTML;
|
qr = document.getElementById('broadcast_tools_room_info_qr');
|
||||||
|
|
||||||
if (!room_name) {
|
if (!room_name) {
|
||||||
roomname = event_info['name'];
|
roomname.innerHTML = event_info['name'];
|
||||||
title = 'Backstage';
|
title.innerHTML = 'Backstage';
|
||||||
speaker = '';
|
speaker.innerHTML = '';
|
||||||
qr = '';
|
qr.innerHTML = '';
|
||||||
box.style.backgroundColor = event_info['color'];
|
box.style.backgroundColor = event_info['color'];
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!schedule) {
|
if (!schedule) {
|
||||||
speaker = 'Waiting for schedule ...';
|
speaker.innerHTML = 'Waiting for schedule ...';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('error' in schedule) {
|
if ('error' in schedule) {
|
||||||
title = 'Error';
|
title.innerHTML = 'Error';
|
||||||
speaker = schedule['error'].join('<br>');
|
speaker.innerHTML = schedule['error'].join('<br>');
|
||||||
qr = '';
|
qr.innerHTML = '';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
|
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
|
||||||
title = 'Error';
|
title.innerHTML = 'Error';
|
||||||
speaker = 'Invalid room_name. Valid names: ' + schedule['rooms'].join(', ');
|
speaker.innerHTML = 'Invalid room_name. Valid names: ' + schedule['rooms'].join(', ');
|
||||||
qr = '';
|
qr.innerHTML = '';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,19 +54,19 @@ function update_room_info() {
|
||||||
qr_info = '';
|
qr_info = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
roomname = room_name;
|
roomname.innerHTML = room_name;
|
||||||
title = current_talk['title'];
|
title.innerHTML = current_talk['title'];
|
||||||
speaker = current_talk['persons'].join(', ');
|
speaker.innerHTML = current_talk['persons'].join(', ');
|
||||||
qr = qr_info;
|
qr.innerHTML = qr_info;
|
||||||
} else {
|
} else {
|
||||||
roomname = event_info['name'];
|
roomname.innerHTML = event_info['name'];
|
||||||
title = room_name;
|
title.innerHTML = room_name;
|
||||||
qr = '';
|
qr.innerHTML = '';
|
||||||
|
|
||||||
if (next_talk && event_info['room-info']['show_next_talk']) {
|
if (next_talk && event_info['room-info']['show_next_talk']) {
|
||||||
speaker = format_time_from_pretalx(next_talk['start']) + ' ' + next_talk['title'];
|
speaker.innerHTML = format_time_from_pretalx(next_talk['start']) + ' ' + next_talk['title'];
|
||||||
} else {
|
} else {
|
||||||
speaker = '';
|
speaker.innerHTML = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue