Fix for wrong format of clock and countdown on projector

This commit is contained in:
Dominik Breu 2013-10-22 00:15:45 +02:00 committed by Oskar Hahn
parent 6f7dabe870
commit ef687ad23c
3 changed files with 37 additions and 3 deletions

View File

@ -13,3 +13,4 @@ Authors of OpenSlides in chronological order of first contribution:
Pavel Fric <pavelfric@seznam.cz> (Czech translation) Pavel Fric <pavelfric@seznam.cz> (Czech translation)
Max Brauer <max@max-brauer.de> Max Brauer <max@max-brauer.de>
Marco A.G.Pinto <marcoagpinto@mail.telepac.pt> (Portuguese translation) Marco A.G.Pinto <marcoagpinto@mail.telepac.pt> (Portuguese translation)
Dominik Breu <dominikbreu@yahoo.de>

View File

@ -2,7 +2,16 @@ function update_clock() {
var currentTime = new Date(); var currentTime = new Date();
var currentHours = currentTime.getHours(); var currentHours = currentTime.getHours();
var currentMinutes = currentTime.getMinutes(); var currentMinutes = currentTime.getMinutes();
currentHours = normalise(currentHours);
currentMinutes = normalise(currentMinutes);
$('#currentTime').html(currentHours + ':' + currentMinutes); $('#currentTime').html(currentHours + ':' + currentMinutes);
setTimeout('update_clock()', 200); setTimeout('update_clock()', 200);
} }
update_clock(); update_clock();
function normalise(i) {
if(i < 10) {
i = "0" + i;
}
return i;
}

View File

@ -1,10 +1,12 @@
function update_countdown() { function update_countdown() {
var time = new Date().getTime() / 1000; var time = new Date().getTime() / 1000;
var seconds; var seconds;
var minutes_digit;
var seconds_digit;
var hours_digit;
var start = projector.projector_countdown_start; var start = projector.projector_countdown_start;
var duration = projector.projector_countdown_duration; var duration = projector.projector_countdown_duration;
var pause = projector.projector_countdown_pause; var pause = projector.projector_countdown_pause;
switch(projector.projector_countdown_state) { switch(projector.projector_countdown_state) {
case 'active': case 'active':
seconds = start + duration - time; seconds = start + duration - time;
@ -16,10 +18,32 @@ function update_countdown() {
seconds = duration; seconds = duration;
break; break;
} }
if (seconds !== undefined) { if(seconds > 60) {
hours_digit = Math.floor(seconds / 3600);
minutes_digit = Math.floor((seconds - (hours_digit * 3600)) / 60);
seconds_digit = Math.floor(seconds - (hours_digit * 3600) - (minutes_digit * 60));
minutes_digit = normalise(minutes_digit);
seconds_digit = normalise(seconds_digit);
if(hours_digit > 0) {
hours_digit = normalise(hours_digit);
seconds = hours_digit + ":" + minutes_digit + ":" + seconds_digit;
} else {
seconds = minutes_digit + ":" + seconds_digit;
}
} else {
seconds = Math.max(0, Math.floor(seconds)); seconds = Math.max(0, Math.floor(seconds));
}
if(seconds !== undefined) {
$('#overlay_countdown_inner').html(seconds); $('#overlay_countdown_inner').html(seconds);
} }
setTimeout('update_countdown()', 200); setTimeout('update_countdown()', 200);
} }
update_countdown(); update_countdown();
function normalise(i) {
if(i < 10) {
i = "0" + i;
}
return i;
}