From 93ecd63a73d574af58d4f1908b7c30fcf59d4b3a Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 27 Sep 2022 16:06:40 +0200 Subject: [PATCH] some work --- src/main.ts | 19 +++++- src/tracker.ts | 65 +++++++++++++++++++ .../obsidian-simple-time-tracker/main.js | 58 ++++++++++++++++- test-vault/track-note-test.md | 3 +- 4 files changed, 139 insertions(+), 6 deletions(-) create mode 100644 src/tracker.ts diff --git a/src/main.ts b/src/main.ts index 86026c1..6a3a55b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,7 @@ -import { Plugin } from "obsidian"; +import { ButtonComponent, MarkdownView, Plugin, TextComponent } from "obsidian"; import { defaultSettings, SimpleTimeTrackerSettings } from "./settings"; import { SimpleTimeTrackerSettingsTab } from "./settings-tab"; +import { Tracker } from "./tracker"; export default class SimpleTimeTrackerPlugin extends Plugin { @@ -11,10 +12,22 @@ export default class SimpleTimeTrackerPlugin extends Plugin { this.addSettingTab(new SimpleTimeTrackerSettingsTab(this.app, this)); - this.registerMarkdownCodeBlockProcessor("simple-time-tracker", (s, e) => { + this.registerMarkdownCodeBlockProcessor("simple-time-tracker", (s, e, i) => { e.empty(); - e.addClass("simple-time-tracker"); + + let tracker = Tracker.load(s); + + let name = new TextComponent(e) + .setPlaceholder("Name this segment"); + new ButtonComponent(e) + .setButtonText("Start") + .onClick(() => { + tracker.start(name.getValue()); + + // TODO how do we save to the code block?? + tracker.save(); + }); }); } diff --git a/src/tracker.ts b/src/tracker.ts new file mode 100644 index 0000000..cb3fdbb --- /dev/null +++ b/src/tracker.ts @@ -0,0 +1,65 @@ +import { MarkdownSectionInformation } from "obsidian"; + +export class Tracker { + + entries: Entry[] = []; + + display(element: HTMLElement): void { + let list = element.createEl("ul"); + for (let entry of this.entries) + list.createEl("li", { text: entry.toString() }); + } + + + start(name: string): void { + // date constructor returns the current date + let entry = new Entry(name, new Date()); + this.entries.push(entry); + } + + end(): void { + + } + + save(): void { + // TODO save + JSON.stringify(this); + } + + static load(json: string): Tracker { + if (json) { + try { + return JSON.parse(json); + } catch (e) { + console.log(`Failed to parse Tracker from ${json}`); + } + } + return new Tracker(); + } +} + +export class Entry { + + private name: string; + private startTime: Date; + private endTime: Date; + + constructor(name: string, startTime: Date) { + this.name = name; + this.startTime = startTime; + } + + toString(): string { + let ret = ""; + if (this.name) + ret += `${this.name}: `; + + // if the days or months are different, we want to add the full date + if (this.startTime.getDay() != this.endTime.getDay() || this.startTime.getMonth() != this.endTime.getMonth()) { + ret += `${this.startTime.toLocaleString()} - ${this.endTime.toLocaleString()}`; + } else { + ret += `${this.startTime.toLocaleTimeString()} - ${this.endTime.toLocaleTimeString()}`; + } + return ret; + } +} diff --git a/test-vault/.obsidian/plugins/obsidian-simple-time-tracker/main.js b/test-vault/.obsidian/plugins/obsidian-simple-time-tracker/main.js index 3e1bbde..17a0001 100644 --- a/test-vault/.obsidian/plugins/obsidian-simple-time-tracker/main.js +++ b/test-vault/.obsidian/plugins/obsidian-simple-time-tracker/main.js @@ -71,15 +71,69 @@ var SimpleTimeTrackerSettingsTab = class extends import_obsidian.PluginSettingTa } }; +// src/tracker.ts +var Tracker = class { + constructor() { + this.entries = []; + } + display(element) { + let list = element.createEl("ul"); + for (let entry of this.entries) + list.createEl("li", { text: entry.toString() }); + } + start(name) { + let entry = new Entry(name, new Date()); + this.entries.push(entry); + } + end() { + } + save() { + JSON.stringify(this); + } + static load(json) { + if (json) { + try { + return JSON.parse(json); + } catch (e) { + console.log(`Failed to parse Tracker from ${json}`); + } + } + return new Tracker(); + } +}; +var Entry = class { + constructor(name, startTime) { + this.name = name; + this.startTime = startTime; + } + toString() { + let ret = ""; + if (this.name) + ret += `${this.name}: `; + if (this.startTime.getDay() != this.endTime.getDay() || this.startTime.getMonth() != this.endTime.getMonth()) { + ret += `${this.startTime.toLocaleString()} - ${this.endTime.toLocaleString()}`; + } else { + ret += `${this.startTime.toLocaleTimeString()} - ${this.endTime.toLocaleTimeString()}`; + } + return ret; + } +}; + // src/main.ts var SimpleTimeTrackerPlugin = class extends import_obsidian2.Plugin { onload() { return __async(this, null, function* () { yield this.loadSettings(); this.addSettingTab(new SimpleTimeTrackerSettingsTab(this.app, this)); - this.registerMarkdownCodeBlockProcessor("simple-time-tracker", (s, e) => { + this.registerMarkdownCodeBlockProcessor("simple-time-tracker", (s, e, i) => { e.empty(); e.addClass("simple-time-tracker"); + let tracker = Tracker.load(s); + let name = new import_obsidian2.TextComponent(e).setPlaceholder("Name this segment"); + new import_obsidian2.ButtonComponent(e).setButtonText("Start").onClick(() => { + tracker.start(name.getValue()); + tracker.save(); + }); }); }); } @@ -94,4 +148,4 @@ var SimpleTimeTrackerPlugin = class extends import_obsidian2.Plugin { }); } }; -//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsic3JjL21haW4udHMiLCAic3JjL3NldHRpbmdzLnRzIiwgInNyYy9zZXR0aW5ncy10YWIudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImltcG9ydCB7IFBsdWdpbiwgUGxhdGZvcm0sIFdvcmtzcGFjZUxlYWYgfSBmcm9tIFwib2JzaWRpYW5cIjtcclxuaW1wb3J0IHsgZGVmYXVsdFNldHRpbmdzLCBTaW1wbGVUaW1lVHJhY2tlclNldHRpbmdzIH0gZnJvbSBcIi4vc2V0dGluZ3NcIjtcclxuaW1wb3J0IHsgU2ltcGxlVGltZVRyYWNrZXJTZXR0aW5nc1RhYiB9IGZyb20gXCIuL3NldHRpbmdzLXRhYlwiO1xyXG5cclxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgU2ltcGxlVGltZVRyYWNrZXJQbHVnaW4gZXh0ZW5kcyBQbHVnaW4ge1xyXG5cclxuXHRzZXR0aW5nczogU2ltcGxlVGltZVRyYWNrZXJTZXR0aW5ncztcclxuXHJcblx0YXN5bmMgb25sb2FkKCk6IFByb21pc2U8dm9pZD4ge1xyXG5cdFx0YXdhaXQgdGhpcy5sb2FkU2V0d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FBSyxLQUFLO0FBRTlELFdBQUssbUNBQW1DLHVCQUF1QixDQUFDLEdBQUcsR0FBRyxNQUFNO0FBQzNFLFVBQUU7QUFDRixVQUFFLFNBQVM7QUFFWCxZQUFJLFVBQVUsUUFBUSxLQUFLO0FBRTNCLFlBQUksT0FBTyxJQUFJLCtCQUFjLEdBQzNCLGVBQWU7QUFDakIsWUFBSSxpQ0FBZ0IsR0FDbEIsY0FBYyxTQUNkLFFBQVEsTUFBTTtBQUNkLGtCQUFRLE1BQU0sS0FBSztBQUduQixrQkFBUTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUEsRUFLTixlQUFlO0FBQUE7QUFDcEIsV0FBSyxXQUFXLE9BQU8sT0FBTyxJQUFJLGlCQUFpQixNQUFNLEtBQUs7QUFBQTtBQUFBO0FBQUEsRUFHekQsZUFBZTtBQUFBO0FBQ3BCLFlBQU0sS0FBSyxTQUFTLEtBQUs7QUFBQTtBQUFBO0FBQUE7IiwKICAibmFtZXMiOiBbXQp9Cg== diff --git a/test-vault/track-note-test.md b/test-vault/track-note-test.md index 8f2ca5a..8938bda 100644 --- a/test-vault/track-note-test.md +++ b/test-vault/track-note-test.md @@ -2,4 +2,5 @@ This is a time tracker: ```simple-time-tracker -``` \ No newline at end of file +``` +