-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
165 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
pretalx_broadcast_tools/static/pretalx_broadcast_tools/room_timer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
function update_room_info() { | ||
room_name = get_room_name(); | ||
|
||
if (!event_info) { | ||
console.warn("Waiting for event info ..."); | ||
return | ||
} | ||
|
||
box = document.getElementById('broadcast_tools_room_timer'); | ||
header = document.getElementById('broadcast_tools_room_timer_header'); | ||
title = document.getElementById('broadcast_tools_room_timer_title'); | ||
speaker = document.getElementById('broadcast_tools_room_timer_speaker'); | ||
scheduledata = document.getElementById('broadcast_tools_room_timer_scheduledata'); | ||
timeleft = document.getElementById('broadcast_tools_room_timer_timeleft'); | ||
progressbar = document.getElementById('broadcast_tools_room_timer_progressbar'); | ||
|
||
box.style.backgroundColor = event_info['color']; | ||
|
||
if (!schedule) { | ||
speaker.innerHTML = 'Waiting for schedule ...'; | ||
return | ||
} | ||
|
||
if ('error' in schedule) { | ||
title.innerHTML = 'Error'; | ||
speaker.innerHTML = schedule['error'].join('<br>'); | ||
return | ||
} | ||
|
||
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) { | ||
title.innerHTML = 'Error'; | ||
speaker.innerHTML = 'Invalid room_name. Valid names: ' + schedule['rooms'].join(', '); | ||
return | ||
} | ||
|
||
current_talk = get_current_talk(60); | ||
next_talk = get_next_talk(); | ||
|
||
if (current_talk) { | ||
title.innerHTML = current_talk['title']; | ||
speaker.innerHTML = current_talk['persons'].join(', '); | ||
scheduledata.innerHTML = format_time_from_pretalx(current_talk['start']); | ||
scheduledata.innerHTML += ' - '; | ||
scheduledata.innerHTML += format_time_from_pretalx(current_talk['end']); | ||
|
||
now = new Date(); | ||
scheduled_start = new Date(current_talk['start']); | ||
scheduled_end = new Date(current_talk['end']); | ||
|
||
if (scheduled_end < now) { | ||
timeleft.innerHTML = '0'; | ||
progressbar.style.width = '0'; | ||
} else { | ||
diff = scheduled_end - now; | ||
let diff_s = Math.floor(Math.floor(diff / 1000) % 60/10); | ||
let diff_m = Math.floor(diff / 1000 / 60) % 60; | ||
|
||
timeleft.innerHTML = diff_m + 'min ' + diff_s + '0sec'; | ||
|
||
total_time = scheduled_end - scheduled_start; | ||
progressbar.style.width = (((diff/total_time)*100)-100)*-1 + 'vw'; | ||
} | ||
|
||
if (current_talk['track']) { | ||
header.style.backgroundColor = current_talk['track']['color']; | ||
progressbar.style.backgroundColor = current_talk['track']['color']; | ||
} else { | ||
header.style.backgroundColor = null; | ||
progressbar.style.backgroundColor = event_info['color']; | ||
} | ||
} else { | ||
title.innerHTML = room_name; | ||
scheduledata.innerHTML = ''; | ||
timeleft.innerHTML = ''; | ||
progressbar.style.width = '0'; | ||
|
||
if (next_talk) { | ||
speaker.innerHTML = format_time_from_pretalx(next_talk['start']) + ' ' + next_talk['title']; | ||
|
||
if (next_talk['track']) { | ||
header.style.backgroundColor = next_talk['track']['color']; | ||
} else { | ||
header.style.backgroundColor = null; | ||
} | ||
} else { | ||
speaker.innerHTML = ''; | ||
} | ||
} | ||
} | ||
window.setInterval(update_room_info, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
pretalx_broadcast_tools/templates/pretalx_broadcast_tools/room_timer.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{% load static %} | ||
{% load compress %} | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html" charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||
<title>{{ request.event.name }} room timer</title> | ||
<script src="{% static "pretalx_broadcast_tools/generic.js" %}"></script> | ||
<script src="{% static "pretalx_broadcast_tools/room_timer.js" %}"></script> | ||
<link rel="stylesheet" href="{% static "pretalx_broadcast_tools/frontend.css" %}" /> | ||
{% if request.event and request.event.custom_css %} | ||
<link rel="stylesheet" type="text/css" href="{{ request.event.custom_css.url }}"/> | ||
{% endif %} | ||
</head> | ||
<body id="broadcast_tools_room_timer"> | ||
<div id="broadcast_tools_room_timer_header"> | ||
<h2 id="broadcast_tools_room_timer_title">Loading ...</h2> | ||
<h3 id="broadcast_tools_room_timer_speaker">Content should appear soon. If not, please verify you have Javascript enabled.</h3> | ||
<p id="broadcast_tools_room_timer_scheduledata"></p> | ||
</div> | ||
<p id="broadcast_tools_room_timer_timeleft"></p> | ||
<p id="broadcast_tools_room_timer_progressbar"> </p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters