mirror of
https://github.com/Kunsi/pretalx-plugin-broadcast-tools
synced 2024-11-21 20:51:03 +00:00
room info: add option to show next talk if no talk is running
This commit is contained in:
parent
0486cd44da
commit
788273e870
5 changed files with 50 additions and 10 deletions
|
@ -41,6 +41,14 @@ class BroadcastToolsSettingsForm(I18nFormMixin, HierarkeyForm):
|
||||||
label=_("lower content"),
|
label=_("lower content"),
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
broadcast_tools_room_info_show_next_talk = BooleanField(
|
||||||
|
help_text=_(
|
||||||
|
"If no talk is running in the room, show the time and title "
|
||||||
|
"of the next talk in the room."
|
||||||
|
),
|
||||||
|
label=_("Show next talk"),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
|
||||||
broadcast_tools_pdf_show_internal_notes = BooleanField(
|
broadcast_tools_pdf_show_internal_notes = BooleanField(
|
||||||
help_text=_(
|
help_text=_(
|
||||||
|
|
|
@ -8,8 +8,6 @@ function get_current_talk(max_offset) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_talk = null;
|
|
||||||
|
|
||||||
for (let offset = 0; offset <= max_offset; offset++) {
|
for (let offset = 0; offset <= max_offset; offset++) {
|
||||||
time_start = new Date(Date.now() + offset*60000).getTime();
|
time_start = new Date(Date.now() + offset*60000).getTime();
|
||||||
time_end = new Date(Date.now() - offset*60000).getTime();
|
time_end = new Date(Date.now() - offset*60000).getTime();
|
||||||
|
@ -26,17 +24,39 @@ function get_current_talk(max_offset) {
|
||||||
talk_end = new Date(talk['end']).getTime();
|
talk_end = new Date(talk['end']).getTime();
|
||||||
|
|
||||||
if (talk_start < time_start && talk_end > time_end) {
|
if (talk_start < time_start && talk_end > time_end) {
|
||||||
current_talk = talk;
|
return talk;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_talk) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return current_talk;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_next_talk() {
|
||||||
|
room_name = get_room_name();
|
||||||
|
|
||||||
|
if (!room_name) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_start = new Date(Date.now()).getTime();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
talk_start = new Date(talk['start']).getTime();
|
||||||
|
|
||||||
|
if (talk_start > time_start) {
|
||||||
|
return talk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_room_name() {
|
function get_room_name() {
|
||||||
|
|
|
@ -41,6 +41,8 @@ function update_room_info() {
|
||||||
}
|
}
|
||||||
|
|
||||||
current_talk = get_current_talk(15);
|
current_talk = get_current_talk(15);
|
||||||
|
next_talk = get_next_talk();
|
||||||
|
|
||||||
if (current_talk) {
|
if (current_talk) {
|
||||||
if (event_info['room-info']['lower_info'] == 'feedback_qr') {
|
if (event_info['room-info']['lower_info'] == 'feedback_qr') {
|
||||||
qr_info = '<img src="' + current_talk['urls']['feedback_qr'] + '" alt="Feedback QR Code"><p>Leave Feedback by scanning the code or visiting ' + current_talk['urls']['feedback'] + '</p>';
|
qr_info = '<img src="' + current_talk['urls']['feedback_qr'] + '" alt="Feedback QR Code"><p>Leave Feedback by scanning the code or visiting ' + current_talk['urls']['feedback'] + '</p>';
|
||||||
|
@ -59,8 +61,14 @@ function update_room_info() {
|
||||||
} else {
|
} else {
|
||||||
$('#broadcast_tools_room_info_roomname').text(event_info['name']);
|
$('#broadcast_tools_room_info_roomname').text(event_info['name']);
|
||||||
$('#broadcast_tools_room_info_title').text(room_name);
|
$('#broadcast_tools_room_info_title').text(room_name);
|
||||||
$('#broadcast_tools_room_info_speaker').text('');
|
|
||||||
$('#broadcast_tools_room_info_qr').text('');
|
$('#broadcast_tools_room_info_qr').text('');
|
||||||
|
|
||||||
|
if (next_talk && event_info['room-info']['show_next_talk']) {
|
||||||
|
next_time = new Date(next_talk['start']);
|
||||||
|
$('#broadcast_tools_room_info_speaker').text(next_time.getHours() + ':' + next_time.getMinutes() + ' ' + next_talk['title']);
|
||||||
|
} else {
|
||||||
|
$('#broadcast_tools_room_info_speaker').text('');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_talk && current_talk['track']) {
|
if (current_talk && current_talk['track']) {
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
{% translate "Room info" %}
|
{% translate "Room info" %}
|
||||||
</legend>
|
</legend>
|
||||||
{% bootstrap_field form.broadcast_tools_room_info_lower_content layout='event' %}
|
{% bootstrap_field form.broadcast_tools_room_info_lower_content layout='event' %}
|
||||||
|
{% bootstrap_field form.broadcast_tools_room_info_show_next_talk layout='event' %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
<legend>
|
||||||
|
|
|
@ -77,6 +77,9 @@ class BroadcastToolsEventInfoView(View):
|
||||||
"room-info": {
|
"room-info": {
|
||||||
"lower_info": self.request.event.settings.broadcast_tools_room_info_lower_content
|
"lower_info": self.request.event.settings.broadcast_tools_room_info_lower_content
|
||||||
or "",
|
or "",
|
||||||
|
"show_next_talk": True
|
||||||
|
if self.request.event.settings.broadcast_tools_room_info_show_next_talk
|
||||||
|
else False,
|
||||||
},
|
},
|
||||||
"slug": self.request.event.slug,
|
"slug": self.request.event.slug,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue