mirror of
https://github.com/itflow-org/itflow
synced 2026-03-02 20:04:53 +00:00
Merge pull request #785 from o-psi/Update-Timer
Update Timer to stop when in focus
This commit is contained in:
@@ -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
|
// Start timer when page is loaded
|
||||||
startTimer();
|
startTimer();
|
||||||
|
|
||||||
@@ -84,4 +97,11 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
|
|
||||||
// Toggle timer when button is clicked
|
// Toggle timer when button is clicked
|
||||||
document.getElementById("toggleTimer").addEventListener('click', toggleTimer);
|
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);
|
||||||
|
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user