OpenSlides/openslides/projector/static/js/countdown.js
Emanuel Schuetze d8d2ad002a Rename and clean up static direcories.
- rename static subdirs to css and js
- move global static dir to core/static, changed
- move global templates dir to core/templates
- check comments and code style of all our own CSS and JS files
- minor changes related to the changes of template and static files
2014-01-14 23:27:12 +01:00

51 lines
1.3 KiB
JavaScript

/*
* JavaScript functions for countdown.
*
*/
function update_countdown() {
var time = projector.get_server_time().getTime() / 1000;
var totalseconds;
var min;
var sec;
var negative;
var start = projector.projector_countdown_start;
var duration = projector.projector_countdown_duration;
var pause = projector.projector_countdown_pause;
switch (projector.projector_countdown_state) {
case 'active':
totalseconds = start + duration - time;
break;
case 'paused':
totalseconds = start + duration - pause;
break;
case 'inactive':
totalseconds = duration;
break;
}
totalseconds = Math.floor(totalseconds);
if (totalseconds < 0 ) {
totalseconds = -totalseconds;
negative = true;
}
min = Math.floor(totalseconds / 60);
sec = Math.floor(totalseconds - (min * 60));
if (sec < 10) {
sec = "0" + sec;
}
if (negative) {
min = "-" + min;
$('#overlay_countdown_inner').addClass('negative');
}
else {
$('#overlay_countdown_inner').removeClass('negative');
}
if(totalseconds !== undefined) {
$('#overlay_countdown_inner').html(min + ":" + sec);
}
}
setInterval('update_countdown()', 200);