Added CAPTCHA's styling based on prefers-color-scheme media query.
This commit is contained in:
parent
28120c8f3a
commit
7c39ad7c3c
@ -5,11 +5,15 @@ const captcha_hidden_field = document.forms[0].children[4].children[0];
|
|||||||
let g_captcha_timeout_remain = g_captcha_timeout_seconds;
|
let g_captcha_timeout_remain = g_captcha_timeout_seconds;
|
||||||
let g_current_captcha_id = captcha_hidden_field.value;
|
let g_current_captcha_id = captcha_hidden_field.value;
|
||||||
|
|
||||||
|
function getColorScheme() {
|
||||||
|
return window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
|
||||||
|
}
|
||||||
|
|
||||||
async function getNewCaptcha() {
|
async function getNewCaptcha() {
|
||||||
const id = await fetch("/captcha/").then(r => r.text());
|
const id = await fetch("/captcha/").then(r => r.text());
|
||||||
g_current_captcha_id = id;
|
g_current_captcha_id = id;
|
||||||
captcha_hidden_field.value = id;
|
captcha_hidden_field.value = id;
|
||||||
setTimeout(() => { captcha_img.src = `/captcha/${id}/image` }, 600);
|
setTimeout(() => { captcha_img.src = `/captcha/${id}/image?style=${getColorScheme()}` }, 600);
|
||||||
g_captcha_timeout_remain = g_captcha_timeout_seconds;
|
g_captcha_timeout_remain = g_captcha_timeout_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user