From 2a3156cd59b4d3aee669604ae010a494e0264100 Mon Sep 17 00:00:00 2001 From: o-psi Date: Tue, 24 Oct 2023 20:07:10 +0000 Subject: [PATCH 1/3] Enhance timer: Pause during input edits --- js/ticket_time_tracking.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/js/ticket_time_tracking.js b/js/ticket_time_tracking.js index b9f8d47b..ee30411d 100644 --- a/js/ticket_time_tracking.js +++ b/js/ticket_time_tracking.js @@ -76,6 +76,18 @@ document.addEventListener("DOMContentLoaded", function() { } } + function pauseForEdit() { + wasRunningBeforeEdit = !isPaused; // check if timer was running + pauseTimer(); + } + + function restartAfterEdit() { + if (wasRunningBeforeEdit) { + startTimer(); + } + } + + // Start timer when page is loaded startTimer(); @@ -84,4 +96,11 @@ document.addEventListener("DOMContentLoaded", function() { // Toggle timer when button is clicked document.getElementById("toggleTimer").addEventListener('click', toggleTimer); + + // Function to pause the timer when the time input is clicked + document.getElementById("time_worked").addEventListener('focus', pauseForEdit); + + // Function to restart the timer when the time input is clicked away from + document.getElementById("time_worked").addEventListener('blur', restartAfterEdit); + }); From 6c137737069e56c860ab569c54a36b44db1d3387 Mon Sep 17 00:00:00 2001 From: o-psi Date: Tue, 24 Oct 2023 20:08:22 +0000 Subject: [PATCH 2/3] Revert "Enhance timer: Pause during input edits" This reverts commit 2a3156cd59b4d3aee669604ae010a494e0264100. --- js/ticket_time_tracking.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/js/ticket_time_tracking.js b/js/ticket_time_tracking.js index ee30411d..b9f8d47b 100644 --- a/js/ticket_time_tracking.js +++ b/js/ticket_time_tracking.js @@ -76,18 +76,6 @@ document.addEventListener("DOMContentLoaded", function() { } } - function pauseForEdit() { - wasRunningBeforeEdit = !isPaused; // check if timer was running - pauseTimer(); - } - - function restartAfterEdit() { - if (wasRunningBeforeEdit) { - startTimer(); - } - } - - // Start timer when page is loaded startTimer(); @@ -96,11 +84,4 @@ document.addEventListener("DOMContentLoaded", function() { // Toggle timer when button is clicked document.getElementById("toggleTimer").addEventListener('click', toggleTimer); - - // Function to pause the timer when the time input is clicked - document.getElementById("time_worked").addEventListener('focus', pauseForEdit); - - // Function to restart the timer when the time input is clicked away from - document.getElementById("time_worked").addEventListener('blur', restartAfterEdit); - }); From 53c953b60e441ea144d36f877728df8dd202557e Mon Sep 17 00:00:00 2001 From: o-psi Date: Tue, 24 Oct 2023 20:09:07 +0000 Subject: [PATCH 3/3] Update the timer to stop when focused. --- js/ticket_time_tracking.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/js/ticket_time_tracking.js b/js/ticket_time_tracking.js index b9f8d47b..3a8ac886 100644 --- a/js/ticket_time_tracking.js +++ b/js/ticket_time_tracking.js @@ -76,6 +76,19 @@ document.addEventListener("DOMContentLoaded", function() { } } + + function pauseForEdit() { + wasRunningBeforeEdit = !isPaused; // check if timer was running + pauseTimer(); + } + + function restartAfterEdit() { + if (wasRunningBeforeEdit) { + startTimer(); + } + } + + // Start timer when page is loaded startTimer(); @@ -84,4 +97,11 @@ document.addEventListener("DOMContentLoaded", function() { // Toggle timer when button is clicked document.getElementById("toggleTimer").addEventListener('click', toggleTimer); -}); + + // Function to pause the timer when the time input is clicked + document.getElementById("time_worked").addEventListener('focus', pauseForEdit); + + // Function to restart the timer when the time input is clicked away from + document.getElementById("time_worked").addEventListener('blur', restartAfterEdit); + +}); \ No newline at end of file