gui: the Hide accounts buttons have their tooltip, and once on it says how to show the accounts again (#653)
Geequlim's account names were masked on Routing and they couldn't tell how to see them: the Routing and Usage "Hide accounts" buttons (and the request log's "Clear filter") carried their tooltip as data-tt="…" with no title, and translateStatic only read title, so no tooltip ever showed. A data-tt with a value is now the title's English; and while accounts are hidden the button's tooltip reads "Accounts are masked for a screenshot — click to show them" (账号已打码,方便截图分享,点一下即可显示). account-mask.test.cjs checks both and fails on the old code; it and mask-emails.test.cjs pass in WebKit (en, zh). go vet ./internal/gui, builds (darwin, GOOS=linux, GOOS=windows) and go test ./internal/gui under a temp HOME pass.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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]")) {
|
||||
|
||||
@@ -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 })),
|
||||
|
||||
Reference in New Issue
Block a user