mirror of
https://github.com/Kunsi/pretalx-plugin-broadcast-tools
synced 2024-11-23 20:11:04 +00:00
replace jQuery with plain JS
This commit is contained in:
parent
0b0df8b600
commit
d295ae18c3
3 changed files with 71 additions and 49 deletions
|
@ -87,11 +87,28 @@ function format_time_from_pretalx(from_pretalx) {
|
|||
return h + ':' + m;
|
||||
}
|
||||
|
||||
function update_schedule() {
|
||||
$.getJSON('../event.json', function(data) {
|
||||
event_info = data;
|
||||
function xhr_get(url, callback_func) {
|
||||
req = new XMLHttpRequest();
|
||||
req.timeout = 10000;
|
||||
req.open('GET', url);
|
||||
req.setRequestHeader('Accept', 'application/json');
|
||||
req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
req.addEventListener('load', function(event) {
|
||||
if (req.status != 200) {
|
||||
return;
|
||||
}
|
||||
|
||||
callback_func(event);
|
||||
});
|
||||
$.getJSON('../schedule.json', function(data) {
|
||||
req.send();
|
||||
}
|
||||
|
||||
function update_schedule() {
|
||||
xhr_get('../event.json', function() {
|
||||
event_info = JSON.parse(req.responseText);
|
||||
});
|
||||
xhr_get('../schedule.json', function() {
|
||||
data = JSON.parse(req.responseText);
|
||||
if ('error' in data) {
|
||||
console.error(data['error']);
|
||||
} else {
|
||||
|
|
|
@ -6,42 +6,47 @@ function update_lower_third() {
|
|||
return
|
||||
}
|
||||
|
||||
$('#broadcast_tools_lower_thirds_box').css('background-color', event_info['color']);
|
||||
box = document.getElementById('broadcast_tools_lower_thirds_box');
|
||||
title = document.getElementById('broadcast_tools_lower_thirds_title').innerHTML;
|
||||
speaker = document.getElementById('broadcast_tools_lower_thirds_speaker').innerHTML;
|
||||
infoline = document.getElementById('broadcast_tools_lower_thirds_infoline').innerHTML;
|
||||
|
||||
box.style.backgroundColor = event_info['color']);
|
||||
|
||||
if (!schedule) {
|
||||
$('#broadcast_tools_lower_thirds_title').text('Waiting for schedule ...')
|
||||
title = 'Waiting for schedule ...';
|
||||
return
|
||||
}
|
||||
|
||||
if ('error' in schedule) {
|
||||
$('#broadcast_tools_lower_thirds_title').text('Error')
|
||||
$('#broadcast_tools_lower_thirds_speaker').html(schedule['error'].join('<br>'));
|
||||
$('#broadcast_tools_lower_thirds_infoline').text('');
|
||||
title = 'Error';
|
||||
speaker = schedule['error'].join('<br>');
|
||||
infoline = '';
|
||||
return
|
||||
}
|
||||
|
||||
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
|
||||
$('#broadcast_tools_lower_thirds_title').text('Error')
|
||||
$('#broadcast_tools_lower_thirds_speaker').text('Invalid room_name. Valid names: ' + schedule['rooms'].join(', '));
|
||||
$('#broadcast_tools_lower_thirds_infoline').text('');
|
||||
title = 'Error';
|
||||
speaker = 'Invalid room_name. Valid names: ' + schedule['rooms'].join(', ');
|
||||
infoline = '';
|
||||
return
|
||||
}
|
||||
|
||||
current_talk = get_current_talk(5);
|
||||
if (current_talk) {
|
||||
$('#broadcast_tools_lower_thirds_title').text(current_talk['title']);
|
||||
$('#broadcast_tools_lower_thirds_speaker').text(current_talk['persons'].join(', '));
|
||||
$('#broadcast_tools_lower_thirds_infoline').text(current_talk['infoline']);
|
||||
title = current_talk['title'];
|
||||
speaker = current_talk['persons'].join(', ');
|
||||
infoline = current_talk['infoline'];
|
||||
} else {
|
||||
$('#broadcast_tools_lower_thirds_title').text(event_info['no_talk']);
|
||||
$('#broadcast_tools_lower_thirds_speaker').text('');
|
||||
$('#broadcast_tools_lower_thirds_infoline').text('');
|
||||
title = event_info['no_talk'];
|
||||
speaker = '';
|
||||
infoline = '';
|
||||
}
|
||||
|
||||
if (current_talk && current_talk['track']) {
|
||||
$('#broadcast_tools_lower_thirds_box').css('border-bottom', '10px solid ' + current_talk['track']['color']);
|
||||
box.style.borderBottom = '10px solid ' + current_talk['track']['color'];
|
||||
} else {
|
||||
$('#broadcast_tools_lower_thirds_box').css('border-bottom', 'none');
|
||||
box.style.borderBottom = 'none';
|
||||
}
|
||||
}
|
||||
window.setInterval(update_lower_third, 1000);
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
$(function() {
|
||||
$('#broadcast_tools_room_info_title').text('Content will appear soon.');
|
||||
$('#broadcast_tools_room_info_speaker').text('');
|
||||
$('#broadcast_tools_room_info_qr').text('');
|
||||
});
|
||||
|
||||
function update_room_info() {
|
||||
room_name = get_room_name();
|
||||
|
||||
|
@ -12,31 +6,37 @@ function update_room_info() {
|
|||
return
|
||||
}
|
||||
|
||||
box = document.getElementById('broadcast_tools_room_info');
|
||||
roomname = document.getElementById('broadcast_tools_room_info_roomname').innerHTML;
|
||||
title = document.getElementById('broadcast_tools_room_info_title').innerHTML;
|
||||
speaker = document.getElementById('broadcast_tools_room_info_speaker').innerHTML;
|
||||
qr = document.getElementById('broadcast_tools_room_info_qr').innerHTML;
|
||||
|
||||
if (!room_name) {
|
||||
$('#broadcast_tools_room_info_roomname').text(event_info['name']);
|
||||
$('#broadcast_tools_room_info_title').text('Backstage');
|
||||
$('#broadcast_tools_room_info_speaker').text('');
|
||||
$('#broadcast_tools_room_info_qr').text('');
|
||||
$('#broadcast_tools_room_info').css('background-color', event_info['color']);
|
||||
roomname = event_info['name'];
|
||||
title = 'Backstage';
|
||||
speaker = '';
|
||||
qr = '';
|
||||
box.style.backgroundColor = event_info['color'];
|
||||
return
|
||||
}
|
||||
|
||||
if (!schedule) {
|
||||
$('#broadcast_tools_room_info_speaker').text('Waiting for schedule ...')
|
||||
speaker = 'Waiting for schedule ...';
|
||||
return
|
||||
}
|
||||
|
||||
if ('error' in schedule) {
|
||||
$('#broadcast_tools_room_info_title').text('Error')
|
||||
$('#broadcast_tools_room_info_speaker').html(schedule['error'].join('<br>'));
|
||||
$('#broadcast_tools_room_info_qr').text('');
|
||||
title = 'Error';
|
||||
speaker = schedule['error'].join('<br>');
|
||||
qr = '';
|
||||
return
|
||||
}
|
||||
|
||||
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
|
||||
$('#broadcast_tools_room_info_title').text('Error')
|
||||
$('#broadcast_tools_room_info_speaker').text('Invalid room_name. Valid names: ' + schedule['rooms'].join(', '));
|
||||
$('#broadcast_tools_room_info_qr').text('');
|
||||
title = 'Error';
|
||||
speaker = 'Invalid room_name. Valid names: ' + schedule['rooms'].join(', ');
|
||||
qr = '';
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -54,26 +54,26 @@ function update_room_info() {
|
|||
qr_info = '';
|
||||
}
|
||||
|
||||
$('#broadcast_tools_room_info_roomname').text(room_name);
|
||||
$('#broadcast_tools_room_info_title').text(current_talk['title']);
|
||||
$('#broadcast_tools_room_info_speaker').text(current_talk['persons'].join(', '));
|
||||
$('#broadcast_tools_room_info_qr').html(qr_info);
|
||||
roomname = room_name;
|
||||
title = current_talk['title'];
|
||||
speaker = current_talk['persons'].join(', ');
|
||||
qr = qr_info;
|
||||
} else {
|
||||
$('#broadcast_tools_room_info_roomname').text(event_info['name']);
|
||||
$('#broadcast_tools_room_info_title').text(room_name);
|
||||
$('#broadcast_tools_room_info_qr').text('');
|
||||
roomname = event_info['name'];
|
||||
title = room_name;
|
||||
qr = '';
|
||||
|
||||
if (next_talk && event_info['room-info']['show_next_talk']) {
|
||||
$('#broadcast_tools_room_info_speaker').text(format_time_from_pretalx(next_talk['start']) + ' ' + next_talk['title']);
|
||||
speaker = format_time_from_pretalx(next_talk['start']) + ' ' + next_talk['title'];
|
||||
} else {
|
||||
$('#broadcast_tools_room_info_speaker').text('');
|
||||
speaker = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (current_talk && current_talk['track']) {
|
||||
$('#broadcast_tools_room_info').css('background-color', current_talk['track']['color']);
|
||||
box.style.backgroundColor = current_talk['track']['color'];
|
||||
} else {
|
||||
$('#broadcast_tools_room_info').css('background-color', event_info['color']);
|
||||
box.style.backgroundColor = event_info['color'];
|
||||
}
|
||||
}
|
||||
window.setInterval(update_room_info, 1000);
|
||||
|
|
Loading…
Reference in a new issue