From: Benjamin Auder Date: Mon, 9 Mar 2020 02:25:37 +0000 (+0100) Subject: Some small enhancements and fixes X-Git-Url: https://git.auder.net/variants/Chakart/doc/scripts/pieces/css/common.css?a=commitdiff_plain;h=afde76668963c4d0d96002fcae2ebabb9acf81e4;p=vchess.git Some small enhancements and fixes --- diff --git a/client/src/App.vue b/client/src/App.vue index 78cd10b1..3839976c 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -64,7 +64,6 @@ export default { }, methods: { hideDrawer: function(e) { - if (e.target.innerText == "Forum") return; //external link e.preventDefault(); //TODO: why is this needed? document.getElementsByClassName("drawer")[0].checked = false; } diff --git a/client/src/main.js b/client/src/main.js index 7e9ce9cc..f2e38f1f 100644 --- a/client/src/main.js +++ b/client/src/main.js @@ -11,9 +11,11 @@ new Vue({ return h(App); }, created: function() { + // Several interactions on clicks on elements: window.doClick = elemId => { document.getElementById(elemId).click(); }; + // Esc key can close modals: document.addEventListener("keydown", e => { if (e.code === "Escape") { let modalBoxes = document.querySelectorAll("[id^='modal']"); diff --git a/client/src/translations/en.js b/client/src/translations/en.js index 5b90af70..f0a5942a 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -87,6 +87,7 @@ export const translations = { Observe: "Observe", "Offer draw?": "Offer draw?", "Opponent action": "Opponent action", + "Participant(s):": "Participant(s):", "Play with?": "Play with?", Players: "Players", "Please log in to accept corr challenges": "Please log in to accept corr challenges", @@ -97,7 +98,6 @@ export const translations = { Previous: "Previous", "Processing... Please wait": "Processing... Please wait", Problems: "Problems", - "participant(s):": "participant(s):", "Random?": "Random?", "Randomness": "Randomness", "Randomness against computer": "Randomness against computer", diff --git a/client/src/translations/es.js b/client/src/translations/es.js index f647a9b2..b79df7e8 100644 --- a/client/src/translations/es.js +++ b/client/src/translations/es.js @@ -87,6 +87,7 @@ export const translations = { "Offer draw?": "¿Ofrecer tablas?", Observe: "Observar", "Opponent action": "Acción del adversario", + "Participant(s):": "Participante(s):", "Play with?": "¿Jugar con?", Players: "Jugadores", "Please log in to accept corr challenges": "Inicia sesión para aceptar los desafíos por correspondencia", @@ -97,7 +98,6 @@ export const translations = { Previous: "Anterior", "Processing... Please wait": "Procesando... por favor espere", Problems: "Problemas", - "participant(s):": "participante(s):", "Random?": "Aleatorio?", "Randomness": "Grado de azar", "Randomness against computer": "Grado de azar contra la computadora", diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js index e7121ca3..2cbc6d28 100644 --- a/client/src/translations/fr.js +++ b/client/src/translations/fr.js @@ -87,6 +87,7 @@ export const translations = { "Offer draw?": "Proposer nulle ?", Observe: "Observer", "Opponent action": "Action de l'adversaire", + "Participant(s):": "Participant(s) :", "Play with?": "Jouer avec ?", Players: "Joueurs", "Please log in to accept corr challenges": "Identifiez vous pour accepter des défis par correspondance", @@ -97,7 +98,6 @@ export const translations = { Previous: "Précédent", "Processing... Please wait": "Traitement en cours... Attendez SVP", Problems: "Problèmes", - "participant(s):": "participant(s) :", "Random?": "Aléatoire?", "Randomness": "Degré d'aléa", "Randomness against computer": "Degré d'aléa contre l'ordinateur", diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 282a3716..d920053a 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -11,7 +11,7 @@ main .card label.modal-close(for="modalChat") #participants - span {{ Object.keys(people).length + " " + st.tr["participant(s):"] }} + span {{ st.tr["Participant(s):"] }} span( v-for="p in Object.values(people)" v-if="p.focus && !!p.name" diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 271c0bcf..9656c967 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -15,8 +15,11 @@ main span.variantName {{ curChallToAccept.vname }} span {{ curChallToAccept.cadence }} span {{ st.tr["with"] + " " + curChallToAccept.from.name }} - .diagram(v-html="tchallDiag") - .button-group#buttonsTchall + .diagram( + v-if="!!curChallToAccept.fen" + v-html="tchallDiag" + ) + .button-group#buttonsTchall(:style="tchallButtonsMargin()") button.acceptBtn(@click="decisionChallenge(true)") span {{ st.tr["Accept challenge?"] }} button.refuseBtn(@click="decisionChallenge(false)") @@ -117,7 +120,7 @@ main .button-group button#peopleBtn(onClick="window.doClick('modalPeople')") | {{ st.tr["Who's there?"] }} - button(onClick="window.doClick('modalNewgame')") + button(@click="showNewchallengeForm()") | {{ st.tr["New game"] }} .row .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 @@ -363,7 +366,20 @@ export default { : "losefocus" ); }, - // Helpers: + partialResetNewchallenge: function() { + // Reset potential target and custom FEN: + this.newchallenge.to = ""; + this.newchallenge.fen = ""; + this.newchallenge.diag = ""; + }, + showNewchallengeForm: function() { + this.partialResetNewchallenge(); + window.doClick("modalNewgame"); + }, + tchallButtonsMargin: function() { + if (!!this.curChallToAccept.fen) return { "margin-top": "10px" }; + return {}; + }, cadenceFocusIfOpened: function() { if (event.target.checked) document.getElementById("cadence").focus(); @@ -416,7 +432,8 @@ export default { ); }, challenge: function(sid) { - // Available, in Hall (only) + this.partialResetNewchallenge(); + // Available, in Hall this.newchallenge.to = this.people[sid].name; document.getElementById("modalPeople").checked = false; window.doClick("modalNewgame"); @@ -911,17 +928,11 @@ export default { position: parsedFen.position, orientation: c.mycolor }); - this.curChallToAccept = c; - document.getElementById("modalAccept").checked = true; - } - else { - if (!confirm(this.st.tr["Accept challenge?"])) - c.accepted = false; - this.finishProcessingChallenge(c); } + this.curChallToAccept = c; + document.getElementById("modalAccept").checked = true; } - else - this.finishProcessingChallenge(c); + else this.finishProcessingChallenge(c); } else { // My challenge @@ -1071,7 +1082,7 @@ button.refuseBtn background-color: red #buttonsTchall - margin-top: 10px + // margin-top set dynamically (depends if diagram showed or not) & > button > span width: 100% text-align: center diff --git a/server/db/create.sql b/server/db/create.sql index c9f52324..8f3daa84 100644 --- a/server/db/create.sql +++ b/server/db/create.sql @@ -58,6 +58,7 @@ create table Games ( score varchar default '*', scoreMsg varchar, cadence varchar, + randomness integer, --for rematch created datetime, drawOffer character default '', rematchOffer character default '',