Site: the Android button's texts reach the page; platform links show the download heading
The page script gets only the texts listed in CLIENT_KEYS; the Android ones were missing, so a phone saw "btn_android". A test now checks every text the script uses. A link to a platform (Android, Linux…) scrolls to the start of the download section instead of the panel under its tabs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ba00887cc2
commit
356384b13e
2 changed files with 22 additions and 1 deletions
|
|
@ -74,6 +74,11 @@ const CLIENT_KEYS: &[&str] = &[
|
|||
"copied",
|
||||
"lb_count",
|
||||
"meta_title",
|
||||
"btn_android",
|
||||
"and_full_title",
|
||||
"and_requires",
|
||||
"and_alpha",
|
||||
"next_android",
|
||||
];
|
||||
|
||||
pub struct Site {
|
||||
|
|
@ -388,4 +393,18 @@ mod tests {
|
|||
assert_eq!(date("2026-10-19T06:54:58Z", "es"), "19 de octubre de 2026");
|
||||
assert_eq!(date("bad", "en"), "");
|
||||
}
|
||||
|
||||
/// Every text the page script asks for is sent to it: a key left out shows as
|
||||
/// itself ("btn_android") on the page.
|
||||
#[test]
|
||||
fn the_script_gets_every_text_it_uses() {
|
||||
let script = include_str!("../../static/js/site.js");
|
||||
let en: HashMap<String, String> =
|
||||
serde_json::from_str(include_str!("../../site/i18n/en.json")).expect("en.json");
|
||||
let quoted = script.split('"').skip(1).step_by(2);
|
||||
let missing: Vec<&str> = quoted
|
||||
.filter(|k| en.contains_key(*k) && !CLIENT_KEYS.contains(k))
|
||||
.collect();
|
||||
assert!(missing.is_empty(), "not in CLIENT_KEYS: {missing:?}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -230,7 +230,9 @@
|
|||
var panelId = id.replace(/^(download-(windows|macos|linux|android)).*/, "$1");
|
||||
var tab = tabs.filter(function (x) { return x.getAttribute("aria-controls") === panelId; })[0];
|
||||
if (tab) select(tab);
|
||||
var target = $(id);
|
||||
// A platform link shows the section from its heading and tabs; a link to one
|
||||
// file, its row.
|
||||
var target = id === panelId ? $("download") : $(id);
|
||||
if (target) target.scrollIntoView();
|
||||
}
|
||||
// The jump is done: drop the anchor, or a reload jumps there again from wherever
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue