fix(challenges/xeact): add noscript warning

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2025-08-29 19:22:34 +00:00
parent 7905a1c6b6
commit ee662f2b56
3 changed files with 26 additions and 1 deletions

View File

@@ -115,6 +115,15 @@ const d = (ms) => {
};
};
/**
* Parse the contents of a given HTML page element as JSON and
* return the results.
*
* This is useful when using templ to pass complicated data from
* the server to the client via HTML[1].
*
* [1]: https://templ.guide/syntax-and-usage/script-templates/#pass-server-side-data-to-the-client-in-a-html-attribute
*/
const j = (id) => JSON.parse(g(id).textContent);
export { h, t, x, g, j, c, n, u, s, r, useState, d };

View File

@@ -17,5 +17,8 @@ templ page(redir, challenge string, difficulty int, loc *localization.SimpleLoca
"pensive_url": anubis.BasePrefix + "/.within.website/x/cmd/anubis/static/img/pensive.webp?cacheBuster=" + anubis.Version,
})
@templ.ComponentFunc(renderAppJS)
<noscript>
{ loc.T("javascript_required") }
</noscript>
</div>
}

View File

@@ -53,7 +53,20 @@ func page(redir, challenge string, difficulty int, loc *localization.SimpleLocal
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</div>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<noscript>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(loc.T("javascript_required"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `preact.templ`, Line: 21, Col: 33}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</noscript></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}