Skip to content

Commit

Permalink
Warn before leaving a game
Browse files Browse the repository at this point in the history
nayakrujul committed Apr 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent aab291b commit c0b3cd4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sets/main.js
Original file line number Diff line number Diff line change
@@ -264,6 +264,8 @@ function restart() {
}

function create_wrongtbl() {
set_obu(false);

document.getElementById("inp").value = "";
document.getElementById("inp").disabled = true;
document.getElementById(
@@ -525,6 +527,8 @@ function showacbr(ix) {
}

function start_classic() {
set_obu(true);

hide_stuff();

let scorebar = document.createElement("b");
@@ -594,6 +598,8 @@ function start_classic() {
}

function start_match() {
set_obu(true);

hide_stuff();

let pairs = random_shuffle(random_shuffle(lst).slice(0, PAIRS));
@@ -660,6 +666,8 @@ function clicked(elem) {
}

if ([...document.querySelectorAll(".done")].length >= PAIRS * 2) {
set_obu(false);

clearInterval(id);

let restartbtn = document.createElement("input");
@@ -678,6 +686,8 @@ function rmntext(n = 0) {
}

function start_hangman() {
set_obu(true);

hide_stuff();

let image = document.createElement("img");
@@ -767,6 +777,14 @@ function check_input_hangman() {
}
}

function set_obu(newval) {
if (newval) {
window.onbeforeunload = () => "Your game is in progress.";
} else {
window.onbeforeunload = undefined;
}
}

function start() {
let selected = document.getElementById("game").value;
if (selected === "classic") {

0 comments on commit c0b3cd4

Please sign in to comment.