Previously the clock display could be up to one minute late.  Now the
update time is synchronised to occur within one tenth of a second
after the minute changes.
---
 modules/mode-line.js |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/modules/mode-line.js b/modules/mode-line.js
index 28b42fa..7c04d7b 100644
--- a/modules/mode-line.js
+++ b/modules/mode-line.js
@@ -180,7 +180,10 @@ function clock_widget(window)
     this.class_name = "clock-widget";
     text_widget.call(this, window);
     var obj = this;
-    this.timer_ID = window.setInterval(function () { obj.update(); }, 60000);
+    this.do_update = function () { obj.update(); };
+    // todo: use one timer for multiple clock widgets
+    this.timer_ID = window.setTimeout(this.do_update, 0);
+    this.timer_timeout = true;
 }
 clock_widget.prototype.__proto__ = text_widget.prototype;
 clock_widget.prototype.update = function () {
@@ -188,6 +191,17 @@ clock_widget.prototype.update = function () {
     var hours = time.getHours();
     var mins = time.getMinutes();
     this.view.text = (hours<10 ? "0" + hours:hours) + ":" + (mins<10 ?"0" 
+mins:mins);
+    if (time.getSeconds() > 0 || time.getMilliseconds() > 100) {
+        this.window.clearTimeout(this.timer_ID);
+        var time = time.getSeconds() * 1000 + time.getMilliseconds();
+        time = 60000 - time;
+        this.timer_ID = this.window.setTimeout(this.do_update, time);
+        this.timer_timeout = true;
+    } else if (this.timer_timeout) {
+        this.window.clearTimeout(this.timer_ID);
+        this.timer_ID = this.window.setInterval(this.do_update, 60000);
+        this.timer_timeout = false;
+    }
 };
 clock_widget.prototype.destroy = function () {
     this.window.clearTimeout(this.timer_ID);
-- 
1.6.5

_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to