This commit is contained in:
Ell 2023-05-22 20:01:50 +02:00
parent 402b97c799
commit 70ade8ada0
11 changed files with 184 additions and 181 deletions

View file

@ -4,6 +4,6 @@ root = true
[*] [*]
charset = utf-8 charset = utf-8
insert_final_newline = true insert_final_newline = true
indent_style = tab indent_style = space
indent_size = 4 indent_size = 4
tab_width = 4 tab_width = 4

View file

@ -1,7 +1,7 @@
import { Plugin } from "obsidian"; import { Plugin } from "obsidian";
import { defaultSettings, SimpleTimeTrackerSettings } from "./settings"; import { defaultSettings, SimpleTimeTrackerSettings } from "./settings";
import { SimpleTimeTrackerSettingsTab } from "./settings-tab"; import { SimpleTimeTrackerSettingsTab } from "./settings-tab";
import { displayTracker, loadTracker } from "./tracker"; import { displayTracker, loadTracker, Tracker } from "./tracker";
export default class SimpleTimeTrackerPlugin extends Plugin { export default class SimpleTimeTrackerPlugin extends Plugin {
@ -13,7 +13,7 @@ export default class SimpleTimeTrackerPlugin extends Plugin {
this.addSettingTab(new SimpleTimeTrackerSettingsTab(this.app, this)); this.addSettingTab(new SimpleTimeTrackerSettingsTab(this.app, this));
this.registerMarkdownCodeBlockProcessor("simple-time-tracker", (s, e, i) => { this.registerMarkdownCodeBlockProcessor("simple-time-tracker", (s, e, i) => {
let tracker = loadTracker(s); let tracker: Tracker = loadTracker(s);
e.empty(); e.empty();
displayTracker(tracker, e, () => i.getSectionInfo(e), this.settings); displayTracker(tracker, e, () => i.getSectionInfo(e), this.settings);
}); });
@ -27,11 +27,11 @@ export default class SimpleTimeTrackerPlugin extends Plugin {
}); });
} }
async loadSettings() { async loadSettings(): Promise<void> {
this.settings = Object.assign({}, defaultSettings, await this.loadData()); this.settings = Object.assign({}, defaultSettings, await this.loadData());
} }
async saveSettings() { async saveSettings(): Promise<void> {
await this.saveData(this.settings); await this.saveData(this.settings);
} }
} }

View file

@ -44,6 +44,9 @@ export class SimpleTimeTrackerSettingsTab extends PluginSettingTab {
this.containerEl.createEl("hr"); this.containerEl.createEl("hr");
this.containerEl.createEl("p", {text: "If you like this plugin and want to support its development, you can do so through my website by clicking this fancy image!"}); this.containerEl.createEl("p", {text: "If you like this plugin and want to support its development, you can do so through my website by clicking this fancy image!"});
this.containerEl.createEl("a", {href: "https://ellpeck.de/support"}) this.containerEl.createEl("a", {href: "https://ellpeck.de/support"})
.createEl("img", { attr: { src: "https://ellpeck.de/res/generalsupport.png" }, cls: "simple-time-tracker-support" }); .createEl("img", {
attr: {src: "https://ellpeck.de/res/generalsupport.png"},
cls: "simple-time-tracker-support"
});
} }
} }

View file

@ -122,7 +122,7 @@ function startNewEntry(tracker: Tracker, name: string): void {
name = `Segment ${tracker.entries.length + 1}`; name = `Segment ${tracker.entries.length + 1}`;
let entry: Entry = {name: name, startTime: moment().unix(), endTime: null, subEntries: null}; let entry: Entry = {name: name, startTime: moment().unix(), endTime: null, subEntries: null};
tracker.entries.push(entry); tracker.entries.push(entry);
}; }
function endRunningEntry(tracker: Tracker): void { function endRunningEntry(tracker: Tracker): void {
let entry = getRunningEntry(tracker.entries); let entry = getRunningEntry(tracker.entries);