X-Git-Url: https://git.auder.net/variants/Baroque/current/git-favicon.png?a=blobdiff_plain;f=app.js;h=6036d49756f322a8dcbc7f1d33ee676095b2fffd;hb=d262cff4c4e1247c1f9680970846cfc61f21b59f;hp=676b8955e9f1bbbb4117c55f18e24e500eace5f3;hpb=3c61449b830db29c95d82cdacc4dae710cc705a8;p=xogo.git diff --git a/app.js b/app.js index 676b895..6036d49 100644 --- a/app.js +++ b/app.js @@ -34,7 +34,8 @@ $.getElementById("myName").value = localStorage.getItem("name"); let inputName = document.getElementById("myName"); let formField = document.getElementById("ng-name"); const setActive = (active) => { - if (active) formField.classList.add("form-field--is-active"); + if (active) + formField.classList.add("form-field--is-active"); else { formField.classList.remove("form-field--is-active"); inputName.value == '' @@ -57,8 +58,10 @@ function setName() { // Turn a "tab" on, and "close" all others function toggleVisible(element) { for (elt of document.querySelectorAll("main > div")) { - if (elt.id != element) elt.style.display = "none"; - else elt.style.display = "block"; + if (elt.id != element) + elt.style.display = "none"; + else + elt.style.display = "block"; } if (element == "boardContainer") { // Avoid smartphone scrolling effects (TODO?) @@ -69,7 +72,8 @@ function toggleVisible(element) { document.querySelector("html").style.overflow = "visible"; document.body.style.overflow = "visible"; // Workaround "superposed texts" effect: - if (element == "newGame") setActive(false); + if (element == "newGame") + setActive(false); } } @@ -83,7 +87,8 @@ function seekGame() { } } function cancelSeek() { - if (send("cancelseek", {vname: seek_vname})) toggleVisible("newGame"); + if (send("cancelseek", {vname: seek_vname})) + toggleVisible("newGame"); } function sendRematch(random) { @@ -91,20 +96,23 @@ function sendRematch(random) { toggleVisible("pendingRematch"); } function cancelRematch() { - if (send("norematch", {gid: gid})) toggleVisible("newGame"); + if (send("norematch", {gid: gid})) + toggleVisible("newGame"); } // Play with a friend (or not ^^) function showNewGameForm() { const vname = $.getElementById("selectVariant").value; - if (vname == "_random") alert("Select a variant first"); + if (vname == "_random") + alert("Select a variant first"); else { $.getElementById("gameLink").innerHTML = ""; $.getElementById("selectColor").selectedIndex = 0; toggleVisible("newGameForm"); import(`/variants/${vname}/class.js`).then(module => { window.V = module.default; - for (const [k, v] of Object.entries(V.Aliases)) window[k] = v; + for (const [k, v] of Object.entries(V.Aliases)) + window[k] = v; prepareOptions(); }); } @@ -158,7 +166,8 @@ function prepareOptions() { while (i < stylesLength) { optHtml += '