Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Timer to stop when in focus #785

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion js/ticket_time_tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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);

});
Loading