mirror of
https://github.com/Ellpeck/ObsidianSimpleTimeTracker.git
synced 2024-12-18 11:39:22 +01:00
fix: feature today sum
This commit is contained in:
parent
84a1657003
commit
ceb41d2a33
3 changed files with 12 additions and 8 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "simple-time-tracker",
|
"name": "simple-time-tracker",
|
||||||
"version": "1.0.3",
|
"version": "1.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "simple-time-tracker",
|
"name": "simple-time-tracker",
|
||||||
"version": "1.0.3",
|
"version": "1.1.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^16.11.6",
|
"@types/node": "^16.11.6",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "simple-time-tracker",
|
"name": "simple-time-tracker",
|
||||||
"version": "1.0.3",
|
"version": "1.1.0",
|
||||||
"description": "Multi-purpose time trackers for your notes!",
|
"description": "Multi-purpose time trackers for your notes!",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -101,9 +101,12 @@ export function displayTracker(tracker: Tracker, element: HTMLElement, getFile:
|
||||||
let total = totalDiv.createEl("span", { cls: "simple-time-tracker-timer-time", text: "0s" });
|
let total = totalDiv.createEl("span", { cls: "simple-time-tracker-timer-time", text: "0s" });
|
||||||
totalDiv.createEl("span", { text: "Total" });
|
totalDiv.createEl("span", { text: "Total" });
|
||||||
|
|
||||||
|
let totalTodayDiv;
|
||||||
|
let totalToday: HTMLElement;
|
||||||
|
|
||||||
if (settings.showToday) {
|
if (settings.showToday) {
|
||||||
let totalTodayDiv = timer.createEl("div", { cls: "simple-time-tracker-timer" })
|
totalTodayDiv = timer.createEl("div", { cls: "simple-time-tracker-timer" })
|
||||||
let totalToday = totalTodayDiv.createEl("span", { cls: "simple-time-tracker-timer-time", text: "0s" })
|
totalToday = totalTodayDiv.createEl("span", { cls: "simple-time-tracker-timer-time", text: "0s" })
|
||||||
totalTodayDiv.createEl("span", { text: "Today" })
|
totalTodayDiv.createEl("span", { text: "Today" })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,14 +134,14 @@ export function displayTracker(tracker: Tracker, element: HTMLElement, getFile:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setCountdownValues(tracker, current, total, currentDiv, settings);
|
setCountdownValues(tracker, current, total, totalToday, currentDiv, settings);
|
||||||
let intervalId = window.setInterval(() => {
|
let intervalId = window.setInterval(() => {
|
||||||
// we delete the interval timer when the element is removed
|
// we delete the interval timer when the element is removed
|
||||||
if (!element.isConnected) {
|
if (!element.isConnected) {
|
||||||
window.clearInterval(intervalId);
|
window.clearInterval(intervalId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setCountdownValues(tracker, current, total, currentDiv, settings);
|
setCountdownValues(tracker, current, total, totalToday, currentDiv, settings);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +325,7 @@ function removeEntry(entries: Entry[], toRemove: Entry): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCountdownValues(tracker: Tracker, current: HTMLElement, total: HTMLElement, currentDiv: HTMLDivElement, settings: SimpleTimeTrackerSettings): void {
|
function setCountdownValues(tracker: Tracker, current: HTMLElement, total: HTMLElement, totalToday: HTMLElement, currentDiv: HTMLDivElement, settings: SimpleTimeTrackerSettings): void {
|
||||||
let running = getRunningEntry(tracker.entries);
|
let running = getRunningEntry(tracker.entries);
|
||||||
if (running && !running.endTime) {
|
if (running && !running.endTime) {
|
||||||
current.setText(formatDuration(getDuration(running), settings));
|
current.setText(formatDuration(getDuration(running), settings));
|
||||||
|
@ -331,6 +334,7 @@ function setCountdownValues(tracker: Tracker, current: HTMLElement, total: HTMLE
|
||||||
currentDiv.hidden = true;
|
currentDiv.hidden = true;
|
||||||
}
|
}
|
||||||
total.setText(formatDuration(getTotalDuration(tracker.entries), settings));
|
total.setText(formatDuration(getTotalDuration(tracker.entries), settings));
|
||||||
|
totalToday.setText(formatDuration(getTotalDurationToday(tracker.entries), settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatEditableTimestamp(timestamp: string, settings: SimpleTimeTrackerSettings): string {
|
function formatEditableTimestamp(timestamp: string, settings: SimpleTimeTrackerSettings): string {
|
||||||
|
|
Loading…
Reference in a new issue