Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions web/src/challange/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Start the countdown.
*/
export function start(){
const container = /** @type {HTMLDivElement} */ (document.querySelector(".captcha-container"));
container.classList.add("alert-warning");
const loader = /** @type {HTMLDivElement} */ (document.querySelector(".circle-loader"));
loader.style.visibility = "visible";
}
Expand All @@ -29,18 +31,25 @@ export function setChallengeInfo(text){
export function stop(countdown, failed = false){
const loader = /** @type {HTMLDivElement} */ (document.querySelector(".circle-loader"));
const checkmark = /** @type {HTMLDivElement} */ (document.querySelector(".checkmark"));
const container = /** @type {HTMLDivElement} */ (document.querySelector(".captcha-container"));
const cross = /** @type {HTMLDivElement} */ (document.querySelector(".cross"));

loader.classList.add("load-complete");
container.classList.remove("alert-warning");

failed
? cross.style.display = "block"
: checkmark.style.display = "block";

if (failed){
container.classList.add("alert-danger");
setChallengeInfo("Challenge failed.");
return;
}

setChallengeInfo("Challenge succeeded.");
container.classList.add("alert-success");

const interval = setInterval(() => {
setChallengeInfo(`Reloading in ${countdown}...`);
if (countdown === 0){
Expand Down
Loading