diff --git a/ts/routes/change-notetype/index.ts b/ts/routes/change-notetype/index.ts deleted file mode 100644 index 5d7b1e366..000000000 --- a/ts/routes/change-notetype/index.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright: Ankitects Pty Ltd and contributors -// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - -import { getChangeNotetypeInfo, getNotetypeNames } from "@generated/backend"; -import { ModuleName, setupI18n } from "@tslib/i18n"; -import { checkNightMode } from "@tslib/nightmode"; - -import ChangeNotetypePage from "./ChangeNotetypePage.svelte"; -import { ChangeNotetypeState } from "./lib"; - -const notetypeNames = getNotetypeNames({}); -const i18n = setupI18n({ - modules: [ModuleName.ACTIONS, ModuleName.CHANGE_NOTETYPE, ModuleName.KEYBOARD], -}); - -export async function setupChangeNotetypePage( - oldNotetypeId: bigint, - newNotetypeId: bigint, -): Promise { - const changeNotetypeInfo = getChangeNotetypeInfo({ - oldNotetypeId, - newNotetypeId, - }); - const [names, info] = await Promise.all([notetypeNames, changeNotetypeInfo, i18n]); - - checkNightMode(); - - const state = new ChangeNotetypeState(names, info); - return new ChangeNotetypePage({ - target: document.body, - props: { state }, - }); -} - -// use #testXXXX where XXXX is notetype ID to test -if (window.location.hash.startsWith("#test")) { - const ntid = parseInt(window.location.hash.substring("#test".length), 10); - setupChangeNotetypePage(BigInt(ntid), BigInt(ntid)); -} diff --git a/ts/routes/deck-options/index.ts b/ts/routes/deck-options/index.ts deleted file mode 100644 index ef2da7f56..000000000 --- a/ts/routes/deck-options/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright: Ankitects Pty Ltd and contributors -// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - -/* eslint -@typescript-eslint/no-explicit-any: "off", - */ - -import "$lib/sveltelib/export-runtime"; - -import { getDeckConfigsForUpdate } from "@generated/backend"; -import { ModuleName, setupI18n } from "@tslib/i18n"; -import { checkNightMode } from "@tslib/nightmode"; - -import { modalsKey, touchDeviceKey } from "$lib/components/context-keys"; -import EnumSelectorRow from "$lib/components/EnumSelectorRow.svelte"; -import SwitchRow from "$lib/components/SwitchRow.svelte"; -import TitledContainer from "$lib/components/TitledContainer.svelte"; - -import DeckOptionsPage from "./DeckOptionsPage.svelte"; -import { DeckOptionsState } from "./lib"; -import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte"; -import SpinBoxRow from "./SpinBoxRow.svelte"; - -const i18n = setupI18n({ - modules: [ - ModuleName.HELP, - ModuleName.SCHEDULING, - ModuleName.ACTIONS, - ModuleName.DECK_CONFIG, - ModuleName.KEYBOARD, - ModuleName.STUDYING, - ModuleName.DECKS, - ], -}); - -export async function setupDeckOptions(did_: number): Promise { - const did = BigInt(did_); - const [info] = await Promise.all([getDeckConfigsForUpdate({ did }), i18n]); - - checkNightMode(); - - const context = new Map(); - context.set(modalsKey, new Map()); - context.set(touchDeviceKey, "ontouchstart" in document.documentElement); - - const state = new DeckOptionsState(BigInt(did), info); - return new DeckOptionsPage({ - target: document.body, - props: { state }, - context, - }); -} - -export const components = { - TitledContainer, - SpinBoxRow, - SpinBoxFloatRow, - EnumSelectorRow, - SwitchRow, -}; - -// if (window.location.hash.startsWith("#test")) { -// setupDeckOptions(1); -// } diff --git a/ts/routes/graphs/index.ts b/ts/routes/graphs/index.ts deleted file mode 100644 index cc4882058..000000000 --- a/ts/routes/graphs/index.ts +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright: Ankitects Pty Ltd and contributors -// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - -/* eslint -@typescript-eslint/no-explicit-any: "off", - */ - -import { ModuleName, setupI18n } from "@tslib/i18n"; -import { checkNightMode } from "@tslib/nightmode"; -import type { SvelteComponent } from "svelte"; - -import GraphsPage from "./GraphsPage.svelte"; - -const i18n = setupI18n({ modules: [ModuleName.STATISTICS, ModuleName.SCHEDULING] }); - -export async function setupGraphs( - graphs: typeof SvelteComponent[], - { - search = "deck:current", - days = 365, - controller = null satisfies typeof SvelteComponent | null, - } = {}, -): Promise { - checkNightMode(); - await i18n; - - return new GraphsPage({ - target: document.body, - props: { - initialSearch: search, - initialDays: days, - graphs, - controller, - }, - }); -} - -import AddedGraph from "./AddedGraph.svelte"; -import ButtonsGraph from "./ButtonsGraph.svelte"; -import CalendarGraph from "./CalendarGraph.svelte"; -import CardCounts from "./CardCounts.svelte"; -import DifficultyGraph from "./DifficultyGraph.svelte"; -import EaseGraph from "./EaseGraph.svelte"; -import FutureDue from "./FutureDue.svelte"; -import { RevlogRange } from "./graph-helpers"; -import HourGraph from "./HourGraph.svelte"; -import IntervalsGraph from "./IntervalsGraph.svelte"; -import RangeBox from "./RangeBox.svelte"; -import RetrievabilityGraph from "./RetrievabilityGraph.svelte"; -import ReviewsGraph from "./ReviewsGraph.svelte"; -import StabilityGraph from "./StabilityGraph.svelte"; -import TodayStats from "./TodayStats.svelte"; - -export const graphComponents = { - TodayStats, - FutureDue, - CalendarGraph, - ReviewsGraph, - CardCounts, - IntervalsGraph, - StabilityGraph, - EaseGraph, - DifficultyGraph, - RetrievabilityGraph, - HourGraph, - ButtonsGraph, - AddedGraph, - RangeBox, - RevlogRange, -}; diff --git a/ts/routes/image-occlusion/index.ts b/ts/routes/image-occlusion/index.ts deleted file mode 100644 index 46d67c208..000000000 --- a/ts/routes/image-occlusion/index.ts +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright: Ankitects Pty Ltd and contributors -// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - -import { ModuleName, setupI18n } from "@tslib/i18n"; -import { checkNightMode } from "@tslib/nightmode"; -import { get } from "svelte/store"; - -import { addOrUpdateNote } from "./add-or-update-note.svelte"; -import ImageOcclusionPage from "./ImageOcclusionPage.svelte"; -import type { IOMode } from "./lib"; -import { hideAllGuessOne } from "./store"; - -globalThis.anki = globalThis.anki || {}; - -const i18n = setupI18n({ - modules: [ - ModuleName.IMPORTING, - ModuleName.DECKS, - ModuleName.EDITING, - ModuleName.NOTETYPES, - ModuleName.ACTIONS, - ModuleName.BROWSING, - ModuleName.UNDO, - ], -}); - -export async function setupImageOcclusion(mode: IOMode, target = document.body): Promise { - checkNightMode(); - await i18n; - - async function addNote(): Promise { - addOrUpdateNote(mode, get(hideAllGuessOne)); - } - - // for adding note from mobile devices - globalThis.anki.imageOcclusion = { - mode, - addNote, - }; - - return new ImageOcclusionPage({ - target: target, - props: { - mode, - }, - }); -} - -if (window.location.hash.startsWith("#test-")) { - const imagePath = window.location.hash.replace("#test-", ""); - setupImageOcclusion({ kind: "add", imagePath, notetypeId: 0 }); -} - -if (window.location.hash.startsWith("#testforedit-")) { - const noteId = parseInt(window.location.hash.replace("#testforedit-", "")); - setupImageOcclusion({ kind: "edit", noteId }); -} diff --git a/ts/routes/import-anki-package/index.ts b/ts/routes/import-anki-package/index.ts deleted file mode 100644 index 5cd5c1ee4..000000000 --- a/ts/routes/import-anki-package/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright: Ankitects Pty Ltd and contributors -// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - -import { getImportAnkiPackagePresets } from "@generated/backend"; -import { ModuleName, setupI18n } from "@tslib/i18n"; -import { checkNightMode } from "@tslib/nightmode"; - -import { modalsKey } from "$lib/components/context-keys"; - -import ImportAnkiPackagePage from "./ImportAnkiPackagePage.svelte"; - -const i18n = setupI18n({ - modules: [ - ModuleName.IMPORTING, - ModuleName.ACTIONS, - ModuleName.HELP, - ModuleName.DECK_CONFIG, - ModuleName.ADDING, - ModuleName.EDITING, - ModuleName.KEYBOARD, - ], -}); - -export async function setupImportAnkiPackagePage( - path: string, -): Promise { - const [_, options] = await Promise.all([ - i18n, - getImportAnkiPackagePresets({}), - ]); - - const context = new Map(); - context.set(modalsKey, new Map()); - checkNightMode(); - - return new ImportAnkiPackagePage({ - target: document.body, - props: { - path, - options, - }, - context, - }); -} - -// eg http://localhost:40000/_anki/pages/import-anki-package.html#test-/home/dae/foo.apkg -if (window.location.hash.startsWith("#test-")) { - const apkgPath = window.location.hash.replace("#test-", ""); - setupImportAnkiPackagePage(apkgPath); -} diff --git a/ts/routes/import-csv/index.ts b/ts/routes/import-csv/index.ts deleted file mode 100644 index 0c1176030..000000000 --- a/ts/routes/import-csv/index.ts +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright: Ankitects Pty Ltd and contributors -// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - -import { getCsvMetadata, getDeckNames, getNotetypeNames } from "@generated/backend"; -import { ModuleName, setupI18n } from "@tslib/i18n"; -import { checkNightMode } from "@tslib/nightmode"; - -import { modalsKey } from "$lib/components/context-keys"; -import ErrorPage from "$lib/components/ErrorPage.svelte"; - -import ImportCsvPage from "./ImportCsvPage.svelte"; -import { ImportCsvState } from "./lib"; - -const i18n = setupI18n({ - modules: [ - ModuleName.ACTIONS, - ModuleName.CHANGE_NOTETYPE, - ModuleName.DECKS, - ModuleName.EDITING, - ModuleName.IMPORTING, - ModuleName.KEYBOARD, - ModuleName.NOTETYPES, - ModuleName.STUDYING, - ModuleName.ADDING, - ModuleName.HELP, - ModuleName.DECK_CONFIG, - ], -}); - -export async function setupImportCsvPage(path: string): Promise { - const context = new Map(); - context.set(modalsKey, new Map()); - checkNightMode(); - - return Promise.all([ - getNotetypeNames({}), - getDeckNames({ - skipEmptyDefault: false, - includeFiltered: false, - }), - getCsvMetadata({ path }, { alertOnError: false }), - i18n, - ]).then(([notetypes, decks, metadata]) => { - return new ImportCsvPage({ - target: document.body, - props: { - state: new ImportCsvState(path, notetypes, decks, metadata), - }, - context, - }); - }).catch((error) => { - return new ErrorPage({ target: document.body, props: { error } }); - }); -} - -/* // use #testXXXX where XXXX is notetype ID to test -if (window.location.hash.startsWith("#test")) { - const ntid = parseInt(window.location.hash.substr("#test".length), 10); - setupCsvImportPage(ntid, ntid); -} */ diff --git a/ts/routes/import-page/index.ts b/ts/routes/import-page/index.ts deleted file mode 100644 index 6ea705f92..000000000 --- a/ts/routes/import-page/index.ts +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright: Ankitects Pty Ltd and contributors -// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - -import { importJsonFile, importJsonString } from "@generated/backend"; -import { ModuleName, setupI18n } from "@tslib/i18n"; -import { checkNightMode } from "@tslib/nightmode"; - -import ImportPage from "./ImportPage.svelte"; -import type { LogParams } from "./types"; - -const i18n = setupI18n({ - modules: [ - ModuleName.IMPORTING, - ModuleName.ADDING, - ModuleName.EDITING, - ModuleName.ACTIONS, - ModuleName.KEYBOARD, - ], -}); - -const postOptions = { alertOnError: false }; - -export async function setupImportPage( - params: LogParams, -): Promise { - await i18n; - - checkNightMode(); - - return new ImportPage({ - target: document.body, - props: { - path: params.path, - noOptions: true, - importer: { - doImport: () => { - switch (params.type) { - case "json_file": - return importJsonFile({ val: params.path }, postOptions); - case "json_string": - return importJsonString({ val: params.json }, postOptions); - } - }, - }, - }, - }); -} - -if (window.location.hash.startsWith("#test-")) { - const path = window.location.hash.replace("#test-", ""); - setupImportPage({ type: "json_file", path }); -}