Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ p.buttons {
----------------------------------------------------------------------------- */

input[type=text],
input[type=number],
select,
textarea {
border: solid 1px #D6D6BE;
Expand Down
8 changes: 6 additions & 2 deletions js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
);
};
Expand Down
8 changes: 6 additions & 2 deletions js/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
</select>
</div>

<div class="item">
<label>
Min. seconds to save timer
</label>
<input type="number" id="min_timer_seconds" min="0" value="0">
<small>Reverts timer if stopped before this threshold</small>
</div>

<p id="status"></p>
<div class="buttons">
<input type="button" id="save" value="Save">
Expand Down