mirror of
https://github.com/Kunsi/pretalx-plugin-broadcast-tools
synced 2024-11-23 15:31:02 +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;
|
return h + ':' + m;
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_schedule() {
|
function xhr_get(url, callback_func) {
|
||||||
$.getJSON('../event.json', function(data) {
|
req = new XMLHttpRequest();
|
||||||
event_info = data;
|
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) {
|
if ('error' in data) {
|
||||||
console.error(data['error']);
|
console.error(data['error']);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -6,42 +6,47 @@ function update_lower_third() {
|
||||||
return
|
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) {
|
if (!schedule) {
|
||||||
$('#broadcast_tools_lower_thirds_title').text('Waiting for schedule ...')
|
title = 'Waiting for schedule ...';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('error' in schedule) {
|
if ('error' in schedule) {
|
||||||
$('#broadcast_tools_lower_thirds_title').text('Error')
|
title = 'Error';
|
||||||
$('#broadcast_tools_lower_thirds_speaker').html(schedule['error'].join('<br>'));
|
speaker = schedule['error'].join('<br>');
|
||||||
$('#broadcast_tools_lower_thirds_infoline').text('');
|
infoline = '';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
|
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
|
||||||
$('#broadcast_tools_lower_thirds_title').text('Error')
|
title = 'Error';
|
||||||
$('#broadcast_tools_lower_thirds_speaker').text('Invalid room_name. Valid names: ' + schedule['rooms'].join(', '));
|
speaker = 'Invalid room_name. Valid names: ' + schedule['rooms'].join(', ');
|
||||||
$('#broadcast_tools_lower_thirds_infoline').text('');
|
infoline = '';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
current_talk = get_current_talk(5);
|
current_talk = get_current_talk(5);
|
||||||
if (current_talk) {
|
if (current_talk) {
|
||||||
$('#broadcast_tools_lower_thirds_title').text(current_talk['title']);
|
title = current_talk['title'];
|
||||||
$('#broadcast_tools_lower_thirds_speaker').text(current_talk['persons'].join(', '));
|
speaker = current_talk['persons'].join(', ');
|
||||||
$('#broadcast_tools_lower_thirds_infoline').text(current_talk['infoline']);
|
infoline = current_talk['infoline'];
|
||||||
} else {
|
} else {
|
||||||
$('#broadcast_tools_lower_thirds_title').text(event_info['no_talk']);
|
title = event_info['no_talk'];
|
||||||
$('#broadcast_tools_lower_thirds_speaker').text('');
|
speaker = '';
|
||||||
$('#broadcast_tools_lower_thirds_infoline').text('');
|
infoline = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_talk && current_talk['track']) {
|
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 {
|
} else {
|
||||||
$('#broadcast_tools_lower_thirds_box').css('border-bottom', 'none');
|
box.style.borderBottom = 'none';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.setInterval(update_lower_third, 1000);
|
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() {
|
function update_room_info() {
|
||||||
room_name = get_room_name();
|
room_name = get_room_name();
|
||||||
|
|
||||||
|
@ -12,31 +6,37 @@ function update_room_info() {
|
||||||
return
|
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) {
|
if (!room_name) {
|
||||||
$('#broadcast_tools_room_info_roomname').text(event_info['name']);
|
roomname = event_info['name'];
|
||||||
$('#broadcast_tools_room_info_title').text('Backstage');
|
title = 'Backstage';
|
||||||
$('#broadcast_tools_room_info_speaker').text('');
|
speaker = '';
|
||||||
$('#broadcast_tools_room_info_qr').text('');
|
qr = '';
|
||||||
$('#broadcast_tools_room_info').css('background-color', event_info['color']);
|
box.style.backgroundColor = event_info['color'];
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!schedule) {
|
if (!schedule) {
|
||||||
$('#broadcast_tools_room_info_speaker').text('Waiting for schedule ...')
|
speaker = 'Waiting for schedule ...';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('error' in schedule) {
|
if ('error' in schedule) {
|
||||||
$('#broadcast_tools_room_info_title').text('Error')
|
title = 'Error';
|
||||||
$('#broadcast_tools_room_info_speaker').html(schedule['error'].join('<br>'));
|
speaker = schedule['error'].join('<br>');
|
||||||
$('#broadcast_tools_room_info_qr').text('');
|
qr = '';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
|
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
|
||||||
$('#broadcast_tools_room_info_title').text('Error')
|
title = 'Error';
|
||||||
$('#broadcast_tools_room_info_speaker').text('Invalid room_name. Valid names: ' + schedule['rooms'].join(', '));
|
speaker = 'Invalid room_name. Valid names: ' + schedule['rooms'].join(', ');
|
||||||
$('#broadcast_tools_room_info_qr').text('');
|
qr = '';
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,26 +54,26 @@ function update_room_info() {
|
||||||
qr_info = '';
|
qr_info = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#broadcast_tools_room_info_roomname').text(room_name);
|
roomname = room_name;
|
||||||
$('#broadcast_tools_room_info_title').text(current_talk['title']);
|
title = current_talk['title'];
|
||||||
$('#broadcast_tools_room_info_speaker').text(current_talk['persons'].join(', '));
|
speaker = current_talk['persons'].join(', ');
|
||||||
$('#broadcast_tools_room_info_qr').html(qr_info);
|
qr = qr_info;
|
||||||
} else {
|
} else {
|
||||||
$('#broadcast_tools_room_info_roomname').text(event_info['name']);
|
roomname = event_info['name'];
|
||||||
$('#broadcast_tools_room_info_title').text(room_name);
|
title = room_name;
|
||||||
$('#broadcast_tools_room_info_qr').text('');
|
qr = '';
|
||||||
|
|
||||||
if (next_talk && event_info['room-info']['show_next_talk']) {
|
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 {
|
} else {
|
||||||
$('#broadcast_tools_room_info_speaker').text('');
|
speaker = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_talk && current_talk['track']) {
|
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 {
|
} else {
|
||||||
$('#broadcast_tools_room_info').css('background-color', event_info['color']);
|
box.style.backgroundColor = event_info['color'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.setInterval(update_room_info, 1000);
|
window.setInterval(update_room_info, 1000);
|
||||||
|
|
Loading…
Reference in a new issue