From ef687ad23cf67f6eb61b19b3652afefbc79c4b03 Mon Sep 17 00:00:00 2001 From: Dominik Breu Date: Tue, 22 Oct 2013 00:15:45 +0200 Subject: [PATCH] Fix for wrong format of clock and countdown on projector --- AUTHORS | 1 + .../projector/static/javascript/clock.js | 9 ++++++ .../projector/static/javascript/countdown.js | 30 +++++++++++++++++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 866c452df..52d204a63 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,3 +13,4 @@ Authors of OpenSlides in chronological order of first contribution: Pavel Fric (Czech translation) Max Brauer Marco A.G.Pinto (Portuguese translation) + Dominik Breu diff --git a/openslides/projector/static/javascript/clock.js b/openslides/projector/static/javascript/clock.js index 6b3de95c4..6fcd167dd 100644 --- a/openslides/projector/static/javascript/clock.js +++ b/openslides/projector/static/javascript/clock.js @@ -2,7 +2,16 @@ function update_clock() { var currentTime = new Date(); var currentHours = currentTime.getHours(); var currentMinutes = currentTime.getMinutes(); + currentHours = normalise(currentHours); + currentMinutes = normalise(currentMinutes); $('#currentTime').html(currentHours + ':' + currentMinutes); setTimeout('update_clock()', 200); } + update_clock(); +function normalise(i) { + if(i < 10) { + i = "0" + i; + } + return i; +} diff --git a/openslides/projector/static/javascript/countdown.js b/openslides/projector/static/javascript/countdown.js index fb428c948..3a5aff9e6 100644 --- a/openslides/projector/static/javascript/countdown.js +++ b/openslides/projector/static/javascript/countdown.js @@ -1,11 +1,13 @@ function update_countdown() { var time = new Date().getTime() / 1000; var seconds; + var minutes_digit; + var seconds_digit; + var hours_digit; var start = projector.projector_countdown_start; var duration = projector.projector_countdown_duration; var pause = projector.projector_countdown_pause; - - switch (projector.projector_countdown_state) { + switch(projector.projector_countdown_state) { case 'active': seconds = start + duration - time; break; @@ -16,10 +18,32 @@ function update_countdown() { seconds = duration; 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)); + } + if(seconds !== undefined) { $('#overlay_countdown_inner').html(seconds); } setTimeout('update_countdown()', 200); } update_countdown(); + +function normalise(i) { + if(i < 10) { + i = "0" + i; + } + return i; +} +