+var chrono_last_update = 0;
+var chrono_time_ms = 0;
+var chrono_time_ms_last_update = 0;
+function chrono_update(time_ms)
+{
+ var d = new Date();
+ var chrono = 0;
+ // Don't update too often
+ if (d.getTime() - chrono_last_update < 3000 &&
+ chrono_time_ms_last_update > 0)
+ chrono = chrono_time_ms;
+ else
+ {
+ chrono_last_update = d.getTime();
+ chrono_time_ms = time_ms;
+ chrono = time_ms;
+ chrono_time_ms_last_update = d.getTime();
+ }
+
+ // Adjust chrono for smooth estimation
+ chrono = chrono - (d.getTime() - chrono_time_ms_last_update);
+
+ // Let's update chronometer
+ var time_str = '';
+ if (chrono > 0)
+ time_str = milliseconds_to_time_string (chrono);
+ return time_str;
+}