removed some old countdown code, defined some default values

This commit is contained in:
Oskar Hahn 2012-04-18 18:55:33 +02:00
parent 4b2211d59f
commit a77038fbf4
4 changed files with 9 additions and 54 deletions

View File

@ -1,3 +1,4 @@
from django.db import models
from django.dispatch import receiver
@ -52,4 +53,8 @@ register_slidemodel(ProjectorSlide, model_name=_('Projector Slide'))
def default_config(sender, key, **kwargs):
return {
'projector_message': '',
'countdown_time': 60,
'countdown_start': False,
'bigger': 100,
'up': 0,
}.get(key)

View File

@ -86,8 +86,9 @@ def countdown(sender, **kwargs):
if kwargs['register']:
return name
if name in kwargs['call']:
starttime = config['countdown_start']
seconds = max(0, int(starttime + config['agenda_countdown_time'] - time()))
if config['countdown_start'] is False:
config['countdown_start'] = time()
seconds = max(0, int(config['countdown_start'] + config['countdown_time'] - time()))
return (name, seconds)
return None

View File

@ -45,47 +45,3 @@ $(document).ready(function() {
switchajax();
presentation_reload();
});
// *** Countdown variables and functions ***
var timer_value;
var timer_is_running=false;
var timer_is_visible=false;
var timerIntervalId;
function resetTimer(value) {
stopTimer()
timer_value = value;
updateTimer();
}
function stopTimer() {
timer_is_running = false;
clearInterval(timerIntervalId);
}
function startTimer() {
timer_is_running = true;
if (timer_value > 0) {
timerIntervalId = setInterval("decrementTimer()", 1000);
}
}
function decrementTimer() {
timer_value--;
if (timer_value <= 0) {
timer_value = 0;
stopTimer();
}
updateTimer();
}
function convertSeconds(s) {
var m = Math.floor(s / 60);
s %= 60;
var h = Math.floor(m / 60);
m %= 60;
return (h>0?h+':':'') + (h>0&&m<10?'0':'') + m + ':' + (s<10?'0':'') + s;
}
function updateTimer() {
if (timer_value >= 0) {
$("#countdown").html(convertSeconds(timer_value));
}
}

View File

@ -153,9 +153,6 @@ def active_slide(request, sid=None):
'time': datetime.now().strftime('%H:%M'),
'bigger': config['bigger'],
'up': config['up'],
'countdown_visible': config['countdown_visible'],
'countdown_time': config['agenda_countdown_time'],
'countdown_control': config['countdown_control'],
'overlay': data['overlay']
}
return ajax_request(jsondata)
@ -189,11 +186,7 @@ def projector_edit(request, direction):
@permission_required('projector.can_manage_projector')
def projector_countdown(request, command):
#todo: why is there the time argument?
if command == 'show':
config['countdown_visible'] = True
elif command == 'hide':
config['countdown_visible'] = False
elif command == 'reset':
if command == 'reset':
config['countdown_start'] = time()
elif command == 'start':
config['countdown_run'] = True