diff --git a/css/style.css b/css/style.css index 593edf1..d95f7ad 100644 --- a/css/style.css +++ b/css/style.css @@ -154,6 +154,7 @@ p.buttons { ----------------------------------------------------------------------------- */ input[type=text], +input[type=number], select, textarea { border: solid 1px #D6D6BE; diff --git a/js/options.js b/js/options.js index b58ff18..a3efdff 100644 --- a/js/options.js +++ b/js/options.js @@ -3,12 +3,14 @@ const saveOptions = () => { const dynamic_tasks = document.getElementById('dynamic_tasks').checked; const sort_by = document.getElementById('sort_by').value ?? 'id'; const sort_direction = document.getElementById('sort_direction').value ?? 'asc'; + const min_timer_seconds = parseInt(document.getElementById('min_timer_seconds').value) || 0; chrome.storage.local.set( { dynamic_tasks: dynamic_tasks, sort_by: sort_by, - sort_direction: sort_direction + sort_direction: sort_direction, + min_timer_seconds: min_timer_seconds }, () => { // Update status to let user know options were saved. @@ -28,12 +30,14 @@ const restoreOptions = () => { { dynamic_tasks: false, sort_by: 'id', - sort_direction: 'asc' + sort_direction: 'asc', + min_timer_seconds: 0 }, (items) => { document.getElementById('dynamic_tasks').checked = items.dynamic_tasks; document.getElementById('sort_by').value = items.sort_by; document.getElementById('sort_direction').value = items.sort_direction; + document.getElementById('min_timer_seconds').value = items.min_timer_seconds; } ); }; diff --git a/js/tasks.js b/js/tasks.js index 2b30328..57d58ff 100644 --- a/js/tasks.js +++ b/js/tasks.js @@ -578,13 +578,17 @@ let taskInterface = { start = new Date(task.start); // read from DB stop = new Date(); // now dif = Number(task.time) + Math.floor((stop.getTime() - start.getTime()) / 1000); // time diff in seconds - $('#item' + task.id + ' .timer').text(taskInterface.hms(dif)); + + let elapsed = Math.floor((stop.getTime() - start.getTime()) / 1000); + let min_seconds = taskInterface.options?.min_timer_seconds || 0; + let final_time = (elapsed < min_seconds) ? task.time : Number(dif); + $('#item' + task.id + ' .timer').text(taskInterface.hms(final_time)); // update record await tasks.update( { running: 0, - time: Number(dif) + time: final_time }, { id: task.id diff --git a/options.html b/options.html index ae13b6a..0ec3b6c 100644 --- a/options.html +++ b/options.html @@ -40,6 +40,14 @@ +