diff --git a/extensions/ki_timesheets/templates/scripts/timeSheet.php b/extensions/ki_timesheets/templates/scripts/timeSheet.php index bb297093b..a5c2c1b90 100644 --- a/extensions/ki_timesheets/templates/scripts/timeSheet.php +++ b/extensions/ki_timesheets/templates/scripts/timeSheet.php @@ -263,9 +263,10 @@ $('#display_total').html(ts_total); latest_running_entry == null): ?> - updateRecordStatus(false); + updateRecordStatus(, false); updateRecordStatus( + , latest_running_entry['timeEntryID']?>, latest_running_entry['start']?>, latest_running_entry['customerID']?>, diff --git a/js/main.js b/js/main.js index bcf67f4b5..346819287 100644 --- a/js/main.js +++ b/js/main.js @@ -361,7 +361,7 @@ function stopRecord() { ); } -function updateRecordStatus(record_ID, record_startTime, customerID, customerName, projectID, projectName, activityID, activityName) { // Updated +function updateRecordStatus(serverTime, record_ID, record_startTime, customerID, customerName, projectID, projectName, activityID, activityName) { // if awaiting updateRecordStatus from buzzer if (typeof timeout_updateRecordStatus != 'undefined'){ clearTimeout(timeout_updateRecordStatus); @@ -375,11 +375,9 @@ function updateRecordStatus(record_ID, record_startTime, customerID, customerNam show_selectors(); return; } - - // Update offset accuracy - if ( typeof stopwatch_init_time != 'undefined' && (stopwatch_init_time + offset) != record_startTime ){ - offset = stopwatch_init_time - record_startTime; - } + + // calculate offset (note: this does not take into account network latencies - but I guess for display this should be accurate enough) + var offset = serverTime - ((new Date()).getTime() / 1000); startsec = record_startTime + offset; @@ -396,7 +394,6 @@ function show_stopwatch() { $("#ticker_project").html($("#selected_project").html()); $("#ticker_activity").html($("#selected_activity").html()); $("ul#ticker").newsticker(); - stopwatch_init_time = Math.floor((new Date()).getTime() / 1000); ticktac(); } @@ -412,7 +409,7 @@ function show_selectors() { } function buzzer() { - if ( currentRecording == 0 || $('#buzzer').hasClass('disabled') ) return; + if (currentRecording == 0 || $('#buzzer').hasClass('disabled')) return; if (currentRecording > -1) { stopRecord(); @@ -516,7 +513,6 @@ function ticktac() { function ticktack_off() { if (timeoutTicktack) { clearTimeout(timeoutTicktack); - delete stopwatch_init_time; timeoutTicktack = 0; $("#h").html("00"); $("#m").html("00");