diff options
Diffstat (limited to 'src/client/views/global/globalScripts.ts')
-rw-r--r-- | src/client/views/global/globalScripts.ts | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/client/views/global/globalScripts.ts b/src/client/views/global/globalScripts.ts index 7730ed385..107e21e08 100644 --- a/src/client/views/global/globalScripts.ts +++ b/src/client/views/global/globalScripts.ts @@ -135,10 +135,10 @@ ScriptingGlobals.add(function toggleOverlay(checkResult?: boolean) { }); // eslint-disable-next-line prefer-arrow-callback -ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines' | 'clusters' | 'viewAll' | 'fitOnce', checkResult?: boolean, persist?: boolean) { +ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines' | 'clusters' | 'viewAll' | 'fitOnce', checkResult?: boolean, persist?: boolean, ) { const selected = DocumentView.SelectedDocs().lastElement(); // prettier-ignore - const map: Map<'flashcards' | 'center' | 'grid' | 'snaplines' | 'clusters' | 'arrange' | 'viewAll' | 'fitOnce' | 'time' | 'docType' | 'color' | 'links' | 'like' | 'star' | 'idea' | 'chat' | '1' | '2' | '3' | '4', + const map: Map<'flashcards' | 'center' | 'grid' | 'snaplines' | 'clusters' | 'arrange' | 'viewAll' | 'fitOnce' | "Time" | "Type"| "Color"| "ChatGPT"| "Custom 1"| "Custom 2"| "Custom 3" , { waitForRender?: boolean; checkResult: (doc: Doc) => any; @@ -173,48 +173,49 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines' checkResult: (doc: Doc) => BoolCast(Doc.UserDoc().defaultToFlashcards, false), setDoc: (doc: Doc, dv: DocumentView) => Doc.UserDoc().defaultToFlashcards = !Doc.UserDoc().defaultToFlashcards, }], - ['time', { - checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "time", + ['Time', { + checkResult: (doc: Doc) => {StrCast(doc?.cardSort); + console.log(StrCast(doc?.cardSort + "card sort"))}, setDoc: (doc: Doc, dv: DocumentView) => doc.cardSort = "time", }], - ['docType', { - checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "type", + ['Type', { + checkResult: (doc: Doc) => StrCast(doc?.cardSort), setDoc: (doc: Doc, dv: DocumentView) => doc.cardSort = "type", }], - ['color', { - checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "color", + ['Color', { + checkResult: (doc: Doc) => StrCast(doc?.cardSort), setDoc: (doc: Doc, dv: DocumentView) => doc.cardSort = "color", }], - ['links', { - checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "links", - setDoc: (doc: Doc, dv: DocumentView) => doc.cardSort = "links", - }], - ['like', { - checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "custom" && StrCast(doc?.cardSort_customField) === "like", + // ['links', { + // checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "links", + // setDoc: (doc: Doc, dv: DocumentView) => doc.cardSort = "links", + // }], + ['Custom 1', { + checkResult: (doc: Doc) => StrCast(doc?.cardSort) + " 1", setDoc: (doc: Doc, dv: DocumentView) => { doc.cardSort = "custom"; doc.cardSort_customField = "like"; doc.cardSort_visibleSortGroups = new List<number>(); } }], - ['star', { - checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "custom" && StrCast(doc?.cardSort_customField) === "star", + ['Custom 2', { + checkResult: (doc: Doc) => StrCast(doc?.cardSort) + " 2", setDoc: (doc: Doc, dv: DocumentView) => { doc.cardSort = "custom"; doc.cardSort_customField = "star"; doc.cardSort_visibleSortGroups = new List<number>(); } }], - ['idea', { - checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "custom" && StrCast(doc?.cardSort_customField) === "idea", + ['Custom 3', { + checkResult: (doc: Doc) => StrCast(doc?.cardSort) + " 3", setDoc: (doc: Doc, dv: DocumentView) => { doc.cardSort = "custom"; doc.cardSort_customField = "idea"; doc.cardSort_visibleSortGroups = new List<number>(); } }], - ['chat', { - checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "custom" && StrCast(doc?.cardSort_customField) === "chat", + ['ChatGPT', { + checkResult: (doc: Doc) => StrCast(doc?.cardSort_customField), setDoc: (doc: Doc, dv: DocumentView) => { doc.cardSort = "custom"; doc.cardSort_customField = "chat"; @@ -233,6 +234,7 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines' } if (checkResult) { + console.log("HIIIIII") return map.get(attr)?.checkResult(selected); } const batch = map.get(attr)?.waitForRender ? UndoManager.StartBatch('set freeform attribute') : { end: () => {} }; |