summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/shows.js5
-rw-r--r--www/js/utils.js20
2 files changed, 18 insertions, 7 deletions
diff --git a/www/js/shows.js b/www/js/shows.js
index eddb80f..13bc9be 100644
--- a/www/js/shows.js
+++ b/www/js/shows.js
@@ -349,15 +349,12 @@ function shows_init() {
data = { LOGIN_NAME: auth_username, PASSWORD: auth_token };
$.post("/rh-bin/listdropboxes.cgi", data, shows_updateList, "xml")
shows_drawClock('Do, 1.1.1970', '00:00:00', 0);
- shows_clock = new Clock(shows_drawClock);
- shows_clock.start();
+ clock_add_callback(shows_drawClock);
}
function shows_cleanup() {
sessionStorage.removeItem("shows_currentid");
delete shows_currentid;
- shows_clock.stop();
- delete shows_clock;
shows_list = [];
shows_group_carts = {};
shows_log_carts = [];
diff --git a/www/js/utils.js b/www/js/utils.js
index 3123c9c..eeebadd 100644
--- a/www/js/utils.js
+++ b/www/js/utils.js
@@ -96,8 +96,8 @@ function get_rd_week(msEpoch) {
return week;
}
-function Clock(draw_callback) {
- this.draw_callback = draw_callback;
+function Clock() {
+ this.draw_callbacks = $.Callbacks('unique');
this.last_message = { t1: 0, t2: 0, t3: 0, t4: 0, tz_offset: 3600 };
this.clock_offset = 0;
@@ -115,7 +115,11 @@ function Clock(draw_callback) {
time_str += (rdtime.getUTCMinutes() > 9 ? ':' : ':0') + rdtime.getUTCMinutes();
time_str += (rdtime.getUTCSeconds() > 9 ? ':' : ':0') + rdtime.getUTCSeconds();
- this.draw_callback(date_str, time_str, get_rd_week(rdtime_ms));
+ this.draw_callbacks.fireWith(window, [date_str, time_str, get_rd_week(rdtime_ms)]);
+ }
+
+ this.addCallback = function(cb) {
+ this.draw_callbacks.add(cb);
}
this.ntp_update = function(event) {
@@ -176,3 +180,13 @@ function Clock(draw_callback) {
this.sock.close();
}
}
+
+var clock = new Clock();
+
+function clock_init() {
+ clock.start();
+}
+
+function clock_add_callback(cb) {
+ clock.addCallback(cb);
+}