-
getTimeRemainingFunction:- Added properties
tenPercentandtwentyPercentto calculate specific time thresholds. - Enhanced the return object to include:
isExpired: Indicates if the timer has expired.formatted: A human-readable time format (e.g.,1d 2h 3m 4s).compact: A compact format (e.g.,01:02:03).
- Added properties
-
startTimerFunction:- Added logic to toggle CSS classes (
twenty-percentandten-percent) based on the remaining time. - Improved handling of expired timers:
- Cleared intervals when the timer expired.
- Updated the UI to reflect the expiration.
- Added logic to toggle CSS classes (
- Delete Button:
- Added an event listener to delete tasks:
- Clears the timer interval for the task (if it exists).
- Removes the task from the
tasksarray. - Updates
localStorageand re-renders the task list.
- Added an event listener to delete tasks:
- Checkbox Functionality:
- Added a checkbox to mark tasks as completed.
- Toggled the
completedclass on the task description based on the checkbox state. - Updated the
tasksarray andlocalStoragewhen the checkbox state changed.
- Highlighting Tasks:
- Added the
focusOnMainTaskfunction to scroll to and highlight a specific task. - Highlighted tasks are visually emphasized for a short duration.
- Added the
window.focusOnMainTask = (taskId) => {
const mainTask = document.querySelector(
`.todo-card[data-task-id="${taskId}"]`
);
if (mainTask) {
mainTask.scrollIntoView({ behavior: "smooth", block: "start" });
mainTask.classList.add("highlighted");
mainTask.style.transition = "background-color 0.5s ease-in-out";
setTimeout(() => {
mainTask.classList.remove("highlighted");
}, 1000);
}
};- Vibration Alert:
- Added the
vibrateTaskfunction to vibrate the device and alert the user when a timer expires.
- Added the
window.vibrateTask = () => {
if (navigator.vibrate) {
setTimeout(() => {
navigator.vibrate(1000);
alert("your timer has expired!");
}, 1000);
}
};- Centralized local Storage Updates:
- Added the
saveTasksToLocalStoragefunction to save thetasksarray tolocalStorage.
- Added the
export function saveTasksTolocalStorage() {
localStorage.setItem("tasks", JSON.stringify(tasks));
}- Ensured All Updates Reflect in
localStorage:- Task additions, deletions, edits, and completion status changes now update
localStorageconsistently.
- Task additions, deletions, edits, and completion status changes now update
moreOptionClick Event:- Added an event listener to the "More Options" button (
moreOption) to toggle the visibility of the priority container (optionals). - This allows users to dynamically show or hide additional options in the UI.
- Added an event listener to the "More Options" button (
moreOption.addEventListener("click", () => {
optionals.classList.toggle("show-priority-container");
});.priority-container:- Added styles for the priority container to position it absolutely, hide it by default, and style its appearance.
.priority-container {
position: absolute;
top: 0;
right: 0;
background-color: #263035;
display: none;
flex-direction: column;
align-items: center;
border-radius: var(--radius-sm);
gap: var(--gap-sm);
padding: var(--gap-sm);
}.show-priority-container:- Added a class to display the priority container when toggled.
.ten-percent:- Added styles for tasks with less than 10% of their time remaining, including a pulsing animation.
.ten-percent {
color: rgb(206, 19, 19);
animation: pulse 1s infinite;
}.twenty-percent:- Added styles for tasks with less than 20% of their time remaining, including a pulsing animation.
.twenty-percent {
color: rgb(236, 223, 33);
animation: pulse 1ms infinite;
}@keyframes pulse:- Defined a pulsing animation for the timer warnings.
.highlighted:- Added styles for highlighting a task when it is focused.
These changes improve the functionality, user experience, and data persistence of the task manager application. Key features include:
- Enhanced timer handling.
- Task deletion and completion tracking.
- UI improvements such as task highlighting and priority container toggling.
- Centralized local storage management.
- Improved styling for priority containers, timer warnings, and task highlighting.
- Drag-and-drop sorting of tasks with intuitive behavior
- Persistent order and data, even after page reload, using localStorage
- Dynamic UI updates when adding/editing/deleting tasks
- Smooth DOM reordering logic that aligns UI with saved state