mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-17 05:44:57 +00:00
fix(web): address review feedback on PoW challenge component
- Guard j() helper against null/empty textContent before JSON.parse - Use <button> instead of clickable <div> for "finished reading" control to support keyboard navigation and screen readers - Make currentLang a local const inside initTranslations since it is not read elsewhere Assisted-by: Claude Opus 4.6 via Claude Code Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -15,7 +15,12 @@ const j = (id: string): any | null => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON.parse(elem.textContent);
|
const text = elem.textContent;
|
||||||
|
if (text == null || text.trim() === "") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return JSON.parse(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
const imageURL = (
|
const imageURL = (
|
||||||
@@ -66,11 +71,10 @@ const getRedirectUrl = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let translations: Record<string, string> = {};
|
let translations: Record<string, string> = {};
|
||||||
let currentLang: string;
|
|
||||||
|
|
||||||
// Initialize translations
|
// Initialize translations
|
||||||
const initTranslations = async () => {
|
const initTranslations = async () => {
|
||||||
currentLang = await getBrowserLanguage();
|
const currentLang = await getBrowserLanguage();
|
||||||
translations = await loadTranslations(currentLang);
|
translations = await loadTranslations(currentLang);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -281,7 +285,7 @@ function App({ anubisVersion, basePrefix }: AppProps) {
|
|||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
{phase === "reading" ? (
|
{phase === "reading" ? (
|
||||||
<div
|
<button
|
||||||
id="progress"
|
id="progress"
|
||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
@@ -297,11 +301,14 @@ function App({ anubisVersion, basePrefix }: AppProps) {
|
|||||||
outlineOffset: "2px",
|
outlineOffset: "2px",
|
||||||
width: "min(20rem, 90%)",
|
width: "min(20rem, 90%)",
|
||||||
margin: "1rem auto 2rem",
|
margin: "1rem auto 2rem",
|
||||||
|
border: "none",
|
||||||
|
fontSize: "inherit",
|
||||||
|
fontFamily: "inherit",
|
||||||
}}
|
}}
|
||||||
onClick={() => redirectFn.current?.()}
|
onClick={() => redirectFn.current?.()}
|
||||||
>
|
>
|
||||||
{t("finished_reading")}
|
{t("finished_reading")}
|
||||||
</div>
|
</button>
|
||||||
) : (
|
) : (
|
||||||
<div
|
<div
|
||||||
id="progress"
|
id="progress"
|
||||||
|
|||||||
Reference in New Issue
Block a user