Skip to content

Commit d019e5a

Browse files
tacerusfionera
authored andcommitted
feat(web): toggle bootstrap elements
For custom entrypoints using bootstrap based theming, it can be desirable to alter the appearance based on whether the challenge succeeded or failed - whilst at it, also set a more useful display text on failure. Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
1 parent caa6ce8 commit d019e5a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

web/src/challange/loader.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* Start the countdown.
77
*/
88
export function start(){
9+
const container = /** @type {HTMLDivElement} */ (document.querySelector(".captcha-container"));
10+
container.classList.add("alert-warning");
911
const loader = /** @type {HTMLDivElement} */ (document.querySelector(".circle-loader"));
1012
loader.style.visibility = "visible";
1113
}
@@ -29,18 +31,25 @@ export function setChallengeInfo(text){
2931
export function stop(countdown, failed = false){
3032
const loader = /** @type {HTMLDivElement} */ (document.querySelector(".circle-loader"));
3133
const checkmark = /** @type {HTMLDivElement} */ (document.querySelector(".checkmark"));
34+
const container = /** @type {HTMLDivElement} */ (document.querySelector(".captcha-container"));
3235
const cross = /** @type {HTMLDivElement} */ (document.querySelector(".cross"));
3336

3437
loader.classList.add("load-complete");
38+
container.classList.remove("alert-warning");
3539

3640
failed
3741
? cross.style.display = "block"
3842
: checkmark.style.display = "block";
3943

4044
if (failed){
45+
container.classList.add("alert-danger");
46+
setChallengeInfo("Challenge failed.");
4147
return;
4248
}
4349

50+
setChallengeInfo("Challenge succeeded.");
51+
container.classList.add("alert-success");
52+
4453
const interval = setInterval(() => {
4554
setChallengeInfo(`Reloading in ${countdown}...`);
4655
if (countdown === 0){

0 commit comments

Comments
 (0)