diff options
Diffstat (limited to 'client-web/source/preferences')
-rw-r--r-- | client-web/source/preferences/decl.ts | 5 | ||||
-rw-r--r-- | client-web/source/preferences/mod.ts | 3 | ||||
-rw-r--r-- | client-web/source/preferences/ui.ts | 14 |
3 files changed, 10 insertions, 12 deletions
diff --git a/client-web/source/preferences/decl.ts b/client-web/source/preferences/decl.ts index 536c5c7..ab57f0e 100644 --- a/client-web/source/preferences/decl.ts +++ b/client-web/source/preferences/decl.ts @@ -3,9 +3,8 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2024 metamuffin <metamuffin.org> */ -// there should be no deps to dom APIs in this file for the tablegen to work -import { LOCALES } from "../locale/mod.ts"; +import { LANGS } from "../locale.ts"; export function hex_id(len = 8): string { if (len > 8) return hex_id() + hex_id(len - 8) @@ -18,7 +17,7 @@ const optional = <T>(a: T): T | undefined => a export const PREF_DECLS = { username: { type: string, default: "guest-" + hex_id(), allow_url: true }, - language: { type: string, possible_values: ["system", ...Object.keys(LOCALES)], default: "system", allow_url: true }, + language: { type: string, possible_values: LANGS, default: "system", allow_url: true }, /* MEDIA */ rnnoise: { type: bool, default: true, allow_url: true }, diff --git a/client-web/source/preferences/mod.ts b/client-web/source/preferences/mod.ts index bbf9bfb..b7e048f 100644 --- a/client-web/source/preferences/mod.ts +++ b/client-web/source/preferences/mod.ts @@ -6,7 +6,6 @@ import { log } from "../logger.ts"; import { PREF_DECLS } from "./decl.ts"; - export interface PrefDecl<T> { default?: T, type: T, @@ -92,7 +91,7 @@ export function generate_section(): string { export function load_params(): { raw_params: { [key: string]: string }, rsecret: string } { const raw_params: Record<string, string> = {} - const [rsecret, param_str] = decodeURIComponent(window.location.hash.substring(1)).split("?") + const [rsecret, param_str] = decodeURIComponent(globalThis.location.hash.substring(1)).split("?") if (!param_str) return { rsecret, raw_params: {} } for (const kv of param_str.split("&")) { const [key, value] = kv.split("=") diff --git a/client-web/source/preferences/ui.ts b/client-web/source/preferences/ui.ts index 0f26c14..a737e01 100644 --- a/client-web/source/preferences/ui.ts +++ b/client-web/source/preferences/ui.ts @@ -6,7 +6,7 @@ /// <reference lib="dom" /> import { e } from "../helper.ts"; -import { PO } from "../locale/mod.ts"; +import { tr } from "../locale.ts"; import { PREF_DECLS } from "./decl.ts"; import { change_pref, on_pref_changed, PrefDecl, PREFS } from "./mod.ts"; @@ -87,24 +87,24 @@ export function ui_preferences(): HTMLElement { use_opt_ = use_opt; } - const label = e("label", { for: id }, PO.setting_descs[key] ?? `[${key}]`) + const label = e("label", { for: id }, tr(`config.${key}`)) return e("tr", { class: "pref" }, e("td", {}, label), e("td", {}, use_opt_ ?? ""), e("td", {}, prim_control ?? "")) }) const notification_perm = Notification.permission == "granted" ? e("div", {}) : e("div", {}, - e("span", {}, PO.notification_perm_explain), - e("button", { onclick: () => Notification.requestPermission() }, PO.grant), + e("span", {}, tr("config.notification.perm_explain")), + e("button", { onclick: () => Notification.requestPermission() }, tr("config.notification.grant")), ) const reset = e("div", {}, - e("span", {}, PO.clear_prefs), + e("span", {}, tr("config.clear_prefs")), e("button", { onclick: () => { if (confirm("really clear all preferences?")) { localStorage.clear(); globalThis.location.reload() } } }, "RESET"), ) const table = document.createElement("table") table.append(...rows) - return e("div", { class: "preferences", role: "dialog", aria_label: PO.settings }, - e("h2", {}, PO.settings), + return e("div", { class: "preferences", role: "dialog", aria_label: tr("config") }, + e("h2", {}, tr("config")), notification_perm, e("br", {}), table, e("br", {}), reset |