diff --git a/src/public/app/widgets/type_widgets/options/other/attachment_erasure_timeout.js b/src/public/app/widgets/type_widgets/options/other/attachment_erasure_timeout.ts similarity index 86% rename from src/public/app/widgets/type_widgets/options/other/attachment_erasure_timeout.js rename to src/public/app/widgets/type_widgets/options/other/attachment_erasure_timeout.ts index 671f7d644..53f968861 100644 --- a/src/public/app/widgets/type_widgets/options/other/attachment_erasure_timeout.js +++ b/src/public/app/widgets/type_widgets/options/other/attachment_erasure_timeout.ts @@ -2,6 +2,7 @@ import OptionsWidget from "../options_widget.js"; import server from "../../../../services/server.js"; import toastService from "../../../../services/toast.js"; import { t } from "../../../../services/i18n.js"; +import type { OptionMap } from "../../../../../../services/options_interface.js"; const TPL = `
@@ -13,13 +14,17 @@ const TPL = `
- +

${t("attachment_erasure_timeout.manual_erasing_description")}

- + `; export default class AttachmentErasureTimeoutOptions extends OptionsWidget { + + private $eraseUnusedAttachmentsAfterTimeInSeconds!: JQuery; + private $eraseUnusedAttachmentsNowButton!: JQuery; + doRender() { this.$widget = $(TPL); this.$eraseUnusedAttachmentsAfterTimeInSeconds = this.$widget.find(".erase-unused-attachments-after-time-in-seconds"); @@ -33,7 +38,7 @@ export default class AttachmentErasureTimeoutOptions extends OptionsWidget { }); } - async optionsLoaded(options) { + async optionsLoaded(options: OptionMap) { this.$eraseUnusedAttachmentsAfterTimeInSeconds.val(options.eraseUnusedAttachmentsAfterSeconds); } } diff --git a/src/public/app/widgets/type_widgets/options/other/html_import_tags.js b/src/public/app/widgets/type_widgets/options/other/html_import_tags.ts similarity index 91% rename from src/public/app/widgets/type_widgets/options/other/html_import_tags.js rename to src/public/app/widgets/type_widgets/options/other/html_import_tags.ts index efc3eb84f..38ff45fbf 100644 --- a/src/public/app/widgets/type_widgets/options/other/html_import_tags.js +++ b/src/public/app/widgets/type_widgets/options/other/html_import_tags.ts @@ -1,5 +1,6 @@ import OptionsWidget from "../options_widget.js"; import { t } from "../../../../services/i18n.js"; +import type { OptionMap } from "../../../../../../services/options_interface.js"; // TODO: Deduplicate with src/services/html_sanitizer once there is a commons project between client and server. export const DEFAULT_ALLOWED_TAGS = [ @@ -103,12 +104,12 @@ export const DEFAULT_ALLOWED_TAGS = [ const TPL = `

${t("import.html_import_tags.title")}

- +

${t("import.html_import_tags.description")}

- - - +
`; export default class HtmlImportTagsOptions extends OptionsWidget { + + private $allowedTags!: JQuery; + private $resetButton!: JQuery; + doRender() { this.$widget = $(TPL); this.contentSized(); @@ -131,7 +136,7 @@ export default class HtmlImportTagsOptions extends OptionsWidget { this.refresh(); } - async optionsLoaded(options) { + async optionsLoaded(options: OptionMap) { try { if (options.allowedHtmlTags) { const tags = JSON.parse(options.allowedHtmlTags); @@ -148,7 +153,7 @@ export default class HtmlImportTagsOptions extends OptionsWidget { } async saveTags() { - const tagsText = this.$allowedTags.val(); + const tagsText = String(this.$allowedTags.val()) || ""; const tags = tagsText .split(/[\n,\s]+/) // Split on newlines, commas, or spaces .map((tag) => tag.trim()) diff --git a/src/public/app/widgets/type_widgets/options/other/network_connections.js b/src/public/app/widgets/type_widgets/options/other/network_connections.ts similarity index 81% rename from src/public/app/widgets/type_widgets/options/other/network_connections.js rename to src/public/app/widgets/type_widgets/options/other/network_connections.ts index 33eb5189b..631a8b3ca 100644 --- a/src/public/app/widgets/type_widgets/options/other/network_connections.js +++ b/src/public/app/widgets/type_widgets/options/other/network_connections.ts @@ -1,10 +1,11 @@ import OptionsWidget from "../options_widget.js"; import { t } from "../../../../services/i18n.js"; +import type { OptionMap } from "../../../../../../services/options_interface.js"; const TPL = `

${t("network_connections.network_connections_title")}

- +
`; export default class NetworkConnectionsOptions extends OptionsWidget { + + private $checkForUpdates!: JQuery; + doRender() { this.$widget = $(TPL); this.$checkForUpdates = this.$widget.find(".check-for-updates"); this.$checkForUpdates.on("change", () => this.updateCheckboxOption("checkForUpdates", this.$checkForUpdates)); } - async optionsLoaded(options) { + async optionsLoaded(options: OptionMap) { this.setCheckboxState(this.$checkForUpdates, options.checkForUpdates); } } diff --git a/src/public/app/widgets/type_widgets/options/other/note_erasure_timeout.js b/src/public/app/widgets/type_widgets/options/other/note_erasure_timeout.ts similarity index 86% rename from src/public/app/widgets/type_widgets/options/other/note_erasure_timeout.js rename to src/public/app/widgets/type_widgets/options/other/note_erasure_timeout.ts index f81735e9c..ee6693f80 100644 --- a/src/public/app/widgets/type_widgets/options/other/note_erasure_timeout.js +++ b/src/public/app/widgets/type_widgets/options/other/note_erasure_timeout.ts @@ -2,6 +2,7 @@ import OptionsWidget from "../options_widget.js"; import server from "../../../../services/server.js"; import toastService from "../../../../services/toast.js"; import { t } from "../../../../services/i18n.js"; +import type { OptionMap } from "../../../../../../services/options_interface.js"; const TPL = `
@@ -13,13 +14,17 @@ const TPL = `
- +

${t("note_erasure_timeout.manual_erasing_description")}

- +
`; export default class NoteErasureTimeoutOptions extends OptionsWidget { + + private $eraseEntitiesAfterTimeInSeconds!: JQuery; + private $eraseDeletedNotesButton!: JQuery; + doRender() { this.$widget = $(TPL); this.$eraseEntitiesAfterTimeInSeconds = this.$widget.find(".erase-entities-after-time-in-seconds"); @@ -33,7 +38,7 @@ export default class NoteErasureTimeoutOptions extends OptionsWidget { }); } - async optionsLoaded(options) { + async optionsLoaded(options: OptionMap) { this.$eraseEntitiesAfterTimeInSeconds.val(options.eraseEntitiesAfterTimeInSeconds); } } diff --git a/src/public/app/widgets/type_widgets/options/other/revision_snapshots_limit.js b/src/public/app/widgets/type_widgets/options/other/revision_snapshots_limit.ts similarity index 83% rename from src/public/app/widgets/type_widgets/options/other/revision_snapshots_limit.js rename to src/public/app/widgets/type_widgets/options/other/revision_snapshots_limit.ts index 76c09ac43..7ff133733 100644 --- a/src/public/app/widgets/type_widgets/options/other/revision_snapshots_limit.js +++ b/src/public/app/widgets/type_widgets/options/other/revision_snapshots_limit.ts @@ -2,6 +2,7 @@ import OptionsWidget from "../options_widget.js"; import { t } from "../../../../services/i18n.js"; import server from "../../../../services/server.js"; import toastService from "../../../../services/toast.js"; +import type { OptionMap } from "../../../../../../services/options_interface.js"; const TPL = `
@@ -19,11 +20,15 @@ const TPL = `
`; export default class RevisionSnapshotsLimitOptions extends OptionsWidget { + + private $revisionSnapshotsNumberLimit!: JQuery; + private $eraseExcessRevisionSnapshotsButton!: JQuery; + doRender() { this.$widget = $(TPL); this.$revisionSnapshotsNumberLimit = this.$widget.find(".revision-snapshot-number-limit"); this.$revisionSnapshotsNumberLimit.on("change", () => { - let revisionSnapshotNumberLimit = this.$revisionSnapshotsNumberLimit.val(); + let revisionSnapshotNumberLimit = parseInt(String(this.$revisionSnapshotsNumberLimit.val()), 10); if (!isNaN(revisionSnapshotNumberLimit) && revisionSnapshotNumberLimit >= -1) { this.updateOption("revisionSnapshotNumberLimit", revisionSnapshotNumberLimit); } @@ -36,7 +41,7 @@ export default class RevisionSnapshotsLimitOptions extends OptionsWidget { }); } - async optionsLoaded(options) { + async optionsLoaded(options: OptionMap) { this.$revisionSnapshotsNumberLimit.val(options.revisionSnapshotNumberLimit); } } diff --git a/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.js b/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.ts similarity index 84% rename from src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.js rename to src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.ts index f3285eb39..11071e018 100644 --- a/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.js +++ b/src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.ts @@ -1,5 +1,6 @@ import OptionsWidget from "../options_widget.js"; import { t } from "../../../../services/i18n.js"; +import type { OptionMap } from "../../../../../../services/options_interface.js"; const TPL = `
@@ -14,13 +15,16 @@ const TPL = `
`; export default class RevisionsSnapshotIntervalOptions extends OptionsWidget { + + private $revisionsTimeInterval!: JQuery; + doRender() { this.$widget = $(TPL); this.$revisionsTimeInterval = this.$widget.find(".revision-snapshot-time-interval-in-seconds"); this.$revisionsTimeInterval.on("change", () => this.updateOption("revisionSnapshotTimeInterval", this.$revisionsTimeInterval.val())); } - async optionsLoaded(options) { + async optionsLoaded(options: OptionMap) { this.$revisionsTimeInterval.val(options.revisionSnapshotTimeInterval); } } diff --git a/src/public/app/widgets/type_widgets/options/other/search_engine.js b/src/public/app/widgets/type_widgets/options/other/search_engine.ts similarity index 85% rename from src/public/app/widgets/type_widgets/options/other/search_engine.js rename to src/public/app/widgets/type_widgets/options/other/search_engine.ts index bdbfd7b15..946cbbbde 100644 --- a/src/public/app/widgets/type_widgets/options/other/search_engine.js +++ b/src/public/app/widgets/type_widgets/options/other/search_engine.ts @@ -1,13 +1,14 @@ import OptionsWidget from "../options_widget.js"; import utils from "../../../../services/utils.js"; import { t } from "../../../../services/i18n.js"; +import type { OptionMap } from "../../../../../../services/options_interface.js"; const TPL = `

${t("search_engine.title")}

- +

${t("search_engine.custom_search_engine_info")}

- +
@@ -18,24 +19,24 @@ const TPL = `
- +
- +
- +
`; -const SEARCH_ENGINES = { +const SEARCH_ENGINES: Record = { Bing: "https://www.bing.com/search?q={keyword}", Baidu: "https://www.baidu.com/s?wd={keyword}", DuckDuckGo: "https://duckduckgo.com/?q={keyword}", @@ -43,6 +44,12 @@ const SEARCH_ENGINES = { }; export default class SearchEngineOptions extends OptionsWidget { + + private $form!: JQuery; + private $predefinedSearchEngineSelect!: JQuery; + private $customSearchEngineName!: JQuery; + private $customSearchEngineUrl!: JQuery; + isEnabled() { return super.isEnabled() && utils.isElectron(); } @@ -56,7 +63,7 @@ export default class SearchEngineOptions extends OptionsWidget { this.$customSearchEngineUrl = this.$widget.find(".custom-search-engine-url"); this.$predefinedSearchEngineSelect.on("change", () => { - const predefinedSearchEngine = this.$predefinedSearchEngineSelect.val(); + const predefinedSearchEngine = String(this.$predefinedSearchEngineSelect.val()); this.$customSearchEngineName[0].value = predefinedSearchEngine; this.$customSearchEngineUrl[0].value = SEARCH_ENGINES[predefinedSearchEngine]; }); @@ -69,7 +76,7 @@ export default class SearchEngineOptions extends OptionsWidget { }); } - async optionsLoaded(options) { + async optionsLoaded(options: OptionMap) { this.$predefinedSearchEngineSelect.val(""); this.$customSearchEngineName[0].value = options.customSearchEngineName; this.$customSearchEngineUrl[0].value = options.customSearchEngineUrl; diff --git a/src/public/app/widgets/type_widgets/options/other/tray.js b/src/public/app/widgets/type_widgets/options/other/tray.ts similarity index 81% rename from src/public/app/widgets/type_widgets/options/other/tray.js rename to src/public/app/widgets/type_widgets/options/other/tray.ts index 10255ac18..4f8326479 100644 --- a/src/public/app/widgets/type_widgets/options/other/tray.js +++ b/src/public/app/widgets/type_widgets/options/other/tray.ts @@ -1,6 +1,7 @@ import OptionsWidget from "../options_widget.js"; import { t } from "../../../../services/i18n.js"; import utils from "../../../../services/utils.js"; +import type { OptionMap } from "../../../../../../services/options_interface.js"; const TPL = `
@@ -13,6 +14,9 @@ const TPL = `
`; export default class TrayOptions extends OptionsWidget { + + private $trayEnabled!: JQuery; + doRender() { this.$widget = $(TPL); this.$trayEnabled = this.$widget.find(".tray-enabled"); @@ -23,7 +27,7 @@ export default class TrayOptions extends OptionsWidget { return utils.isElectron(); } - async optionsLoaded(options) { + async optionsLoaded(options: OptionMap) { this.$trayEnabled.prop("checked", options.disableTray !== "true"); } }