aboutsummaryrefslogtreecommitdiff
path: root/web/js
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2025-04-03 08:40:34 -0400
committerXe Iaso <me@xeiaso.net>2025-04-03 08:40:34 -0400
commit344fd12e530bd28efb15a8488ad0772f312bd3f0 (patch)
tree5cc5e02cc9e53272b1c5667fc145ccf0c1c5b695 /web/js
parent08fa5f8085770774e34ac5510c2e01dbffb128e7 (diff)
downloadanubis-release/v1.15.2.tar.xz
anubis-release/v1.15.2.zip
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'web/js')
-rw-r--r--web/js/main.mjs38
1 files changed, 27 insertions, 11 deletions
diff --git a/web/js/main.mjs b/web/js/main.mjs
index 297f16f..3e5940d 100644
--- a/web/js/main.mjs
+++ b/web/js/main.mjs
@@ -27,6 +27,22 @@ const imageURL = (mood, cacheBuster) =>
const spinner = document.getElementById('spinner');
const anubisVersion = JSON.parse(document.getElementById('anubis_version').textContent);
+ const ohNoes = ({ titleMsg, statusMsg, imageSrc }) => {
+ title.innerHTML = titleMsg;
+ status.innerHTML = statusMsg;
+ image.src = imageSrc;
+ progress.style.display = "none";
+ };
+
+ if (!window.isSecureContext) {
+ ohNoes({
+ titleMsg: "Your context is not secure!",
+ statusMsg: `Try connecting over HTTPS or let the admin know to set up HTTPS. For more information, see <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts#when_is_a_context_considered_secure">MDN</a>.`,
+ imageSrc: imageURL("reject", anubisVersion),
+ });
+ return;
+ }
+
// const testarea = document.getElementById('testarea');
// const videoWorks = await testVideo(testarea);
@@ -35,9 +51,9 @@ const imageURL = (mood, cacheBuster) =>
// if (!videoWorks) {
// title.innerHTML = "Oh no!";
// status.innerHTML = "Checks failed. Please check your browser's settings and try again.";
- // image.src = imageURL("sad");
// spinner.innerHTML = "";
// spinner.style.display = "none";
+ // image.src = imageURL("reject");
// return;
// }
@@ -51,21 +67,21 @@ const imageURL = (mood, cacheBuster) =>
return r.json();
})
.catch(err => {
- title.innerHTML = "Oh no!";
- status.innerHTML = `Failed to fetch config: ${err.message}`;
- image.src = imageURL("sad", anubisVersion);
- spinner.innerHTML = "";
- spinner.style.display = "none";
+ ohNoes({
+ titleMsg: "Internal error!",
+ statusMsg: `Failed to fetch challenge config: ${err.message}`,
+ imageSrc: imageURL("reject", anubisVersion),
+ });
throw err;
});
const process = algorithms[rules.algorithm];
if (!process) {
- title.innerHTML = "Oh no!";
- status.innerHTML = `Failed to resolve check algorithm. You may want to reload the page.`;
- image.src = imageURL("sad", anubisVersion);
- spinner.innerHTML = "";
- spinner.style.display = "none";
+ ohNoes({
+ titleMsg: "Challenge error!",
+ statusMsg: `Failed to resolve check algorithm. You may want to reload the page.`,
+ imageSrc: imageURL("reject", anubisVersion),
+ });
return;
}