diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 539ada65a..b760efd00 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -14409,6 +14409,10 @@ window.noteAccounts = noteAccounts; const label = btn.querySelector("[data-t]"); label.dataset.en = on ? "Accounts hidden" : "Hide accounts"; label.textContent = t(label.dataset.en); + // and how to have them back, for one who never turned it on (#653) + btn.dataset.enTitle = on ? "Accounts are masked for a screenshot — click to show them" + : "Mask the accounts on this page — email addresses and account names — for a screenshot to share"; + btn.title = t(btn.dataset.enTitle); } view.classList.toggle("masked", on); // a name learnt since it was masked: hidden afresh diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 8b431d699..2713ffd97 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -1685,6 +1685,7 @@ const I18N = { "{date}: not counted — magpie began counting on {since}": "{date}:未统计——magpie 从 {since} 开始统计", "Counted since {date}": "从 {date} 开始统计", "Accounts hidden": "账号已打码", + "Accounts are masked for a screenshot — click to show them": "账号已打码,方便截图分享,点一下即可显示", "Add a model": "添加模型", "Add another model": "再添加一个模型", "{api} only · after the others": "仅 {api} · 排在其他之后", @@ -2625,14 +2626,15 @@ function t(s, vars) { // Static text in index.html: elements marked data-t (text) or data-tt // (title) keep their English in a data attribute and are re-rendered on a -// language change. +// language change. A data-tt with a value is the title's English itself +// (#653: the Hide accounts buttons had no title, so no tooltip showed). function translateStatic() { for (const e of document.querySelectorAll("[data-t]")) { if (e.dataset.en === undefined) e.dataset.en = e.textContent; e.textContent = t(e.dataset.en); } for (const e of document.querySelectorAll("[data-tt]")) { - if (e.dataset.enTitle === undefined) e.dataset.enTitle = e.title; + if (e.dataset.enTitle === undefined) e.dataset.enTitle = e.dataset.tt || e.title; e.title = t(e.dataset.enTitle); } for (const e of document.querySelectorAll("[data-tp]")) { diff --git a/internal/gui/tests/account-mask.test.cjs b/internal/gui/tests/account-mask.test.cjs index eac41d238..21c4e61a2 100644 --- a/internal/gui/tests/account-mask.test.cjs +++ b/internal/gui/tests/account-mask.test.cjs @@ -43,8 +43,8 @@ function serve(lang, panel) { } const words = { - en: { hide: "Hide accounts", hidden: "Accounts hidden" }, - zh: { hide: "账号打码", hidden: "账号已打码" }, + en: { hide: "Hide accounts", hidden: "Accounts hidden", tip: /^Mask the accounts/, back: /click to show them/ }, + zh: { hide: "账号打码", hidden: "账号已打码", tip: /^给本页的账号/, back: /点一下即可显示/ }, }; for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { @@ -69,6 +69,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await page.waitForSelector(".subscription-account .user"); const btn = page.locator("#usageMask"); assert.equal((await btn.textContent()).trim(), w.hide); + // the button has a tooltip, and once on it says how to have them back (#653) + assert.match(await btn.getAttribute("title"), w.tip); // a sentence and a tooltip naming the accounts, and a word with one inside await page.evaluate(() => { const d = document.createElement("div"); @@ -79,6 +81,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", }); await btn.click(); assert.equal((await btn.textContent()).trim(), w.hidden); + assert.match(await btn.getAttribute("title"), w.back); + assert.match(await page.locator("#rtMask").getAttribute("title"), w.back); await page.waitForFunction(() => document.querySelectorAll("#sample .pii").length === 2); const got = await page.evaluate(() => ({ users: [...document.querySelectorAll(".subscription-account .user")].map((u) => ({ raw: u.querySelector(".pii")?.dataset.raw ?? null, text: u.textContent, title: u.title })),