mirror of
https://github.com/Ellpeck/ObsidianSimpleTimeTracker.git
synced 2024-11-22 01:23:28 +01:00
added command to insert tracker
This commit is contained in:
parent
d001d7887a
commit
18cdda3e9b
4 changed files with 50 additions and 28 deletions
|
@ -17,6 +17,14 @@ export default class SimpleTimeTrackerPlugin extends Plugin {
|
||||||
e.empty();
|
e.empty();
|
||||||
displayTracker(tracker, e, () => i.getSectionInfo(e));
|
displayTracker(tracker, e, () => i.getSectionInfo(e));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.addCommand({
|
||||||
|
id: `insert-simple-time-tracker`,
|
||||||
|
name: `Insert Simple Time Tracker`,
|
||||||
|
editorCallback: (e, _) => {
|
||||||
|
e.replaceSelection("```simple-time-tracker\n```\n");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadSettings() {
|
async loadSettings() {
|
||||||
|
|
|
@ -77,10 +77,11 @@ export function displayTracker(tracker: Tracker, element: HTMLElement, getSectio
|
||||||
let current = currentDiv.createEl("span", { cls: "simple-time-tracker-timer-time" });
|
let current = currentDiv.createEl("span", { cls: "simple-time-tracker-timer-time" });
|
||||||
currentDiv.createEl("span", { text: "Current" });
|
currentDiv.createEl("span", { text: "Current" });
|
||||||
let totalDiv = timer.createEl("div", { cls: "simple-time-tracker-timer" });
|
let totalDiv = timer.createEl("div", { cls: "simple-time-tracker-timer" });
|
||||||
let total = totalDiv.createEl("span", { cls: "simple-time-tracker-timer-time" });
|
let total = totalDiv.createEl("span", { cls: "simple-time-tracker-timer-time", text: "0s" });
|
||||||
totalDiv.createEl("span", { text: "Total" });
|
totalDiv.createEl("span", { text: "Total" });
|
||||||
|
|
||||||
// add list
|
// add table
|
||||||
|
if (tracker.entries.length > 0) {
|
||||||
let table = element.createEl("table", { cls: "simple-time-tracker-table" });
|
let table = element.createEl("table", { cls: "simple-time-tracker-table" });
|
||||||
table.createEl("tr").append(
|
table.createEl("tr").append(
|
||||||
createEl("th", { text: "Segment" }),
|
createEl("th", { text: "Segment" }),
|
||||||
|
@ -98,6 +99,7 @@ export function displayTracker(tracker: Tracker, element: HTMLElement, getSectio
|
||||||
row.createEl("td", { text: getCountdownDisplay(moment.duration(duration)) });
|
row.createEl("td", { text: getCountdownDisplay(moment.duration(duration)) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setCountdownValues(tracker, current, total, currentDiv);
|
setCountdownValues(tracker, current, total, currentDiv);
|
||||||
let intervalId = window.setInterval(() => {
|
let intervalId = window.setInterval(() => {
|
||||||
|
|
File diff suppressed because one or more lines are too long
3
test-vault/test2.md
Normal file
3
test-vault/test2.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
```simple-time-tracker
|
||||||
|
{"entries":[{"name":"Segment 1","startTime":1664308278,"endTime":1664308284},{"name":"Segment 2","startTime":1664308285,"endTime":1664308286},{"name":"Segment 3","startTime":1664308299,"endTime":1664308312}]}
|
||||||
|
```
|
Loading…
Reference in a new issue