Merge branch 'master' into See-All-Timers

This commit is contained in:
Andrew Malsbury
2023-11-14 11:24:26 -06:00
committed by GitHub
85 changed files with 1474 additions and 1213 deletions

View File

@@ -1,41 +0,0 @@
function addWatcher(button) {
var container = button.previousElementSibling;
var textFieldWrapper = document.createElement("div");
textFieldWrapper.className = "input-group mb-3";
var prependWrapper = document.createElement("div");
prependWrapper.className = "input-group-prepend";
var iconSpan = document.createElement("span");
iconSpan.className = "input-group-text";
iconSpan.innerHTML = "<i class='fas fa-fw fa-envelope'></i>";
prependWrapper.appendChild(iconSpan);
var textField = document.createElement("input");
textField.type = "email";
textField.className = "form-control";
textField.name = "watchers[]";
textField.placeholder = "Enter an email";
var removeButtonWrapper = document.createElement("div");
removeButtonWrapper.className = "input-group-append";
var removeButton = document.createElement("button");
removeButton.className = "btn btn-danger";
removeButton.type = "button";
removeButton.innerHTML = "<i class='fas fa-fw fa-minus'></i>";
removeButton.onclick = function() {
removeWatcher(this);
};
removeButtonWrapper.appendChild(removeButton);
textFieldWrapper.appendChild(prependWrapper);
textFieldWrapper.appendChild(textField);
textFieldWrapper.appendChild(removeButtonWrapper);
container.appendChild(textFieldWrapper);
}
function removeWatcher(button) {
var container = button.parentNode.parentNode.parentNode; // Navigate to the container
var textFieldWrapper = button.parentNode.parentNode;
container.removeChild(textFieldWrapper);
}

View File

@@ -125,6 +125,7 @@
}
}
function updateRunningTicketsCount() {
var runningTickets = parseInt(document.getElementById('runningTicketsCount').innerText, 10);
@@ -136,6 +137,16 @@
document.getElementById('runningTicketsCount').innerText = runningTickets.toString();
}
// Function to check status and pause timer
function checkStatusAndPauseTimer() {
var status = document.querySelector('select[name="status"]').value;
if (status.includes("Pending")) {
pauseTimer();
}
}
document.getElementById("hours").addEventListener('change', updateTimeFromInput);
document.getElementById("minutes").addEventListener('change', updateTimeFromInput);
@@ -146,6 +157,9 @@
document.getElementById("minutes").addEventListener('focus', handleInputFocus);
document.getElementById("seconds").addEventListener('focus', handleInputFocus);
document.querySelector('select[name="status"]').addEventListener('change', checkStatusAndPauseTimer);
document.getElementById("startStopTimer").addEventListener('click', function() {
if (timerInterval === null) {
startTimer();
@@ -162,16 +176,17 @@
// Wait for other synchronous actions (if any) to complete before resetting the timer.
setTimeout(forceResetTimer, 100); // 100ms delay should suffice, but you can adjust as needed.
});
try {
displayTime();
if (!localStorage.getItem(getLocalStorageKey("startTime")) && !localStorage.getItem(getLocalStorageKey("pausedTime"))) {
// If first time, start the timer automatically
startTimer();
} else if (localStorage.getItem(getLocalStorageKey("startTime"))) {
// Continue timer if it was running before
startTimer();
}
// Check and pause timer if status is pending
checkStatusAndPauseTimer();
} catch (error) {
console.error("There was an issue initializing the timer:", error);
}