From 42a9284896b9cf9a579d32b7cf77dfc1f5786472 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Wed, 11 Mar 2020 09:36:48 +0100
Subject: [PATCH] Fixes

---
 client/src/App.vue                    |  9 +--------
 client/src/components/BaseGame.vue    |  5 ++---
 client/src/components/ContactForm.vue |  7 ++++++-
 client/src/components/MoveList.vue    |  7 +++----
 client/src/components/Settings.vue    | 13 ++++++++-----
 client/src/components/UpsertUser.vue  |  7 ++++++-
 client/src/translations/en.js         |  8 ++++----
 client/src/translations/es.js         |  8 ++++----
 client/src/translations/fr.js         |  8 ++++----
 client/src/variants/Antiking.js       |  1 +
 client/src/views/Game.vue             |  7 ++++---
 client/src/views/Hall.vue             |  4 ++--
 client/src/views/Problems.vue         |  3 +--
 13 files changed, 46 insertions(+), 41 deletions(-)

diff --git a/client/src/App.vue b/client/src/App.vue
index 312f324a..8258dc3e 100644
--- a/client/src/App.vue
+++ b/client/src/App.vue
@@ -44,8 +44,7 @@
 import ContactForm from "@/components/ContactForm.vue";
 import Settings from "@/components/Settings.vue";
 import UpsertUser from "@/components/UpsertUser.vue";
-import { store } from "./store.js";
-import { processModalClick } from "./utils/modalClick.js";
+import { store } from "@/store.js";
 export default {
   components: {
     ContactForm,
@@ -57,12 +56,6 @@ export default {
       st: store.state
     };
   },
-  mounted: function() {
-    let dialogs = document.querySelectorAll("div[role='dialog']");
-    dialogs.forEach(d => {
-      d.addEventListener("click", processModalClick);
-    });
-  },
   methods: {
     hideDrawer: function(e) {
       e.preventDefault(); //TODO: why is this needed?
diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue
index 0d5a3bbc..8e88b055 100644
--- a/client/src/components/BaseGame.vue
+++ b/client/src/components/BaseGame.vue
@@ -138,9 +138,8 @@ export default {
       baseGameDiv.addEventListener("keydown", this.handleKeys);
       baseGameDiv.addEventListener("wheel", this.handleScroll);
     }
-    document.getElementById("eogDiv").addEventListener(
-      "click",
-      processModalClick);
+    document.getElementById("eogDiv")
+      .addEventListener("click", processModalClick);
   },
   methods: {
     focusBg: function() {
diff --git a/client/src/components/ContactForm.vue b/client/src/components/ContactForm.vue
index 50270e69..e5d27326 100644
--- a/client/src/components/ContactForm.vue
+++ b/client/src/components/ContactForm.vue
@@ -4,7 +4,7 @@ div
     type="checkbox"
     @change="trySetEnterTime($event)"
   )
-  div(
+  div#contactDiv(
     role="dialog"
     data-checkbox="modalContact"
   )
@@ -26,6 +26,7 @@ div
 import { ajax } from "@/utils/ajax";
 import { store } from "@/store";
 import { checkNameEmail } from "@/data/userCheck";
+import { processModalClick } from "@/utils/modalClick.js";
 export default {
   name: "my-contact-form",
   data: function() {
@@ -35,6 +36,10 @@ export default {
       infoMsg: ""
     };
   },
+  mounted: function() {
+    document.getElementById("contactDiv")
+      .addEventListener("click", processModalClick);
+  },
   methods: {
     trySetEnterTime: function(event) {
       if (event.target.checked) {
diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue
index 4428f298..c4e19982 100644
--- a/client/src/components/MoveList.vue
+++ b/client/src/components/MoveList.vue
@@ -74,9 +74,8 @@ export default {
     };
   },
   mounted: function() {
-    document.getElementById("adjuster").addEventListener(
-      "click",
-      processModalClick);
+    document.getElementById("adjuster")
+      .addEventListener("click", processModalClick);
     if ("ontouchstart" in window) {
       // Disable tooltips on smartphones:
       document.querySelectorAll("#aboveMoves .tooltip").forEach(elt => {
@@ -226,6 +225,6 @@ span#rulesBtn
 button
   margin: 0
 
-button.tooltip
+#aboveMoves button
   padding-bottom: 5px
 </style>
diff --git a/client/src/components/Settings.vue b/client/src/components/Settings.vue
index 7e90b0f2..5b79e06e 100644
--- a/client/src/components/Settings.vue
+++ b/client/src/components/Settings.vue
@@ -1,7 +1,7 @@
 <template lang="pug">
 div
   input#modalSettings.modal(type="checkbox")
-  div(
+  div#settingsDiv(
     role="dialog"
     data-checkbox="modalSettings"
   )
@@ -27,14 +27,14 @@ div
           )
       div(@change="updateSettings($event)")
         fieldset
-          label(for="setHints") {{ st.tr["Show possible moves?"] }}
+          label(for="setHints") {{ st.tr["Show possible moves"] }}
           input#setHints(
             type="checkbox"
             v-model="st.settings.hints"
           )
         fieldset
           label(for="setHighlight")
-            | {{ st.tr["Highlight last move and checks?"] }}
+            | {{ st.tr["Highlight last move"] }}
           input#setHighlight(
             type="checkbox"
             v-model="st.settings.highlight"
@@ -47,14 +47,14 @@ div
             option(value="chesstempo") {{ st.tr["blue"] }}
         fieldset
           label(for="setSound")
-            | {{ st.tr["Sound alert when game starts?"] }}
+            | {{ st.tr["Sound alert at game start"] }}
           input#setSound(
             type="checkbox"
             v-model="st.settings.sound"
           )
         fieldset
           label(for="setGotonext")
-            | {{ st.tr["Show next game after move?"] }}
+            | {{ st.tr["Show next game after a move"] }}
           input#setGotonext(
             type="checkbox"
             v-model="st.settings.gotonext"
@@ -69,6 +69,7 @@ div
 
 <script>
 import { store } from "@/store.js";
+import { processModalClick } from "@/utils/modalClick.js";
 export default {
   name: "my-settings",
   data: function() {
@@ -77,6 +78,8 @@ export default {
     };
   },
   mounted: function() {
+    document.getElementById("settingsDiv")
+      .addEventListener("click", processModalClick);
     // NOTE: better style would be in pug directly, but how?
     document.querySelectorAll("#langSelect > option").forEach(opt => {
       if (opt.value == this.st.lang) opt.selected = true;
diff --git a/client/src/components/UpsertUser.vue b/client/src/components/UpsertUser.vue
index ca322e0c..dc948cf1 100644
--- a/client/src/components/UpsertUser.vue
+++ b/client/src/components/UpsertUser.vue
@@ -4,7 +4,7 @@ div
     type="checkbox"
     @change="trySetEnterTime($event)"
   )
-  div(
+  div#upsertDiv(
     role="dialog"
     data-checkbox="modalUser"
   )
@@ -59,6 +59,7 @@ div
 import { store } from "@/store";
 import { checkNameEmail } from "@/data/userCheck";
 import { ajax } from "@/utils/ajax";
+import { processModalClick } from "@/utils/modalClick.js";
 export default {
   name: "my-upsert-user",
   data: function() {
@@ -71,6 +72,10 @@ export default {
       user: {}
     };
   },
+  mounted: function() {
+    document.getElementById("upsertDiv")
+      .addEventListener("click", processModalClick);
+  },
   watch: {
     nameOrEmail: function(newValue) {
       if (newValue.indexOf("@") >= 0) {
diff --git a/client/src/translations/en.js b/client/src/translations/en.js
index a3f660e7..c03a0976 100644
--- a/client/src/translations/en.js
+++ b/client/src/translations/en.js
@@ -47,7 +47,7 @@ export const translations = {
   Go: "Go",
   green: "green",
   Hall: "Hall",
-  "Highlight last move and checks?": "Highlight last move and checks?",
+  "Highlight last move": "Highlight last move",
   Instructions: "Instructions",
   "Invalid email": "Invalid email",
   "It's your turn!": "It's your turn!",
@@ -119,11 +119,11 @@ export const translations = {
   "Self-challenge is forbidden": "Self-challenge is forbidden",
   "Send challenge": "Send challenge",
   Settings: "Settings",
-  "Show next game after move?": "Show next game after move?",
-  "Show possible moves?": "Show possible moves?",
+  "Show next game after a move": "Show next game after move",
+  "Show possible moves": "Show possible moves",
   "Show solution": "Show solution",
   Solution: "Solution",
-  "Sound alert when game starts?": "Sound alert when game starts?",
+  "Sound alert at game start": "Sound alert at game start",
   Stop: "Stop",
   "Stop game": "Stop game",
   Subject: "Subject",
diff --git a/client/src/translations/es.js b/client/src/translations/es.js
index 3b5c7ab8..5a4e8dff 100644
--- a/client/src/translations/es.js
+++ b/client/src/translations/es.js
@@ -47,7 +47,7 @@ export const translations = {
   Go: "Go",
   green: "verde",
   Hall: "Salón",
-  "Highlight last move and checks?": "¿Resaltar el último movimiento y jaques?",
+  "Highlight last move": "Resaltar el último movimiento",
   Instructions: "Instrucciones",
   "Invalid email": "Email inválido",
   "It's your turn!": "¡Es su turno!",
@@ -119,11 +119,11 @@ export const translations = {
   "Self-challenge is forbidden": "Auto desafío está prohibido",
   "Send challenge": "Enviar desafío",
   Settings: "Configuraciones",
-  "Show next game after move?": "¿Mostrar la siguiente partida después de una jugada?",
-  "Show possible moves?": "¿Mostrar posibles movimientos?",
+  "Show next game after a move": "Mostrar la siguiente partida después de una jugada",
+  "Show possible moves": "Mostrar posibles movimientos",
   "Show solution": "Mostrar la solución",
   Solution: "Solución",
-  "Sound alert when game starts?": "¿Alerta audible cuando comienza una partida?",
+  "Sound alert at game start": "Alerta audible cuando comienza una partida",
   Stop: "Interrupción",
   "Stop game": "Terminar la partida",
   Subject: "Asunto",
diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js
index 405320c3..a685d55c 100644
--- a/client/src/translations/fr.js
+++ b/client/src/translations/fr.js
@@ -47,7 +47,7 @@ export const translations = {
   Go: "Go",
   green: "vert",
   Hall: "Salon",
-  "Highlight last move and checks?": "Mettre en valeur le dernier coup et les échecs ?",
+  "Highlight last move": "Mettre en valeur le dernier coup",
   Instructions: "Instructions",
   "Invalid email": "Email invalide",
   "It's your turn!": "À vous de jouer !",
@@ -119,11 +119,11 @@ export const translations = {
   "Self-challenge is forbidden": "Interdit de s'auto-défier",
   "Send challenge": "Envoyer défi",
   Settings: "Réglages",
-  "Show next game after move?": "Montrer la partie suivante après un coup ?",
-  "Show possible moves?": "Montrer les coups possibles ?",
+  "Show next game after a move": "Montrer la partie suivante après un coup",
+  "Show possible moves": "Montrer les coups possibles",
   "Show solution": "Montrer la solution",
   Solution: "Solution",
-  "Sound alert when game starts?": "Alerte sonore quand une partie démarre ?",
+  "Sound alert at game start": "Alerte sonore quand une partie démarre",
   Stop: "Arrêt",
   "Stop game": "Arrêter la partie",
   Subject: "Sujet",
diff --git a/client/src/variants/Antiking.js b/client/src/variants/Antiking.js
index aa6b54cc..77f0c839 100644
--- a/client/src/variants/Antiking.js
+++ b/client/src/variants/Antiking.js
@@ -160,6 +160,7 @@ export const VariantRules = class AntikingRules extends ChessRules {
     for (let c of ["w", "b"]) {
       if (c == 'b' && randomness == 1) {
         pieces['b'] = pieces['w'];
+        antikingPos['b'] = antikingPos['w'];
         break;
       }
 
diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue
index 703ba184..62826808 100644
--- a/client/src/views/Game.vue
+++ b/client/src/views/Game.vue
@@ -216,9 +216,10 @@ export default {
   },
   mounted: function() {
     document.addEventListener('visibilitychange', this.visibilityChange);
-    document
-      .getElementById("chatWrap")
-      .addEventListener("click", processModalClick);
+    ["chatWrap", "infoDiv"].forEach(eltName => {
+      document.getElementById(eltName)
+        .addEventListener("click", processModalClick);
+    });
     if ("ontouchstart" in window) {
       // Disable tooltips on smartphones:
       document.querySelectorAll("#aboveBoard .tooltip").forEach(elt => {
diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue
index 608c5d53..829e5b7d 100644
--- a/client/src/views/Hall.vue
+++ b/client/src/views/Hall.vue
@@ -381,8 +381,8 @@ export default {
   mounted: function() {
     document.addEventListener('visibilitychange', this.visibilityChange);
     ["peopleWrap", "infoDiv", "newgameDiv"].forEach(eltName => {
-      let elt = document.getElementById(eltName);
-      elt.addEventListener("click", processModalClick);
+      document.getElementById(eltName)
+        .addEventListener("click", processModalClick);
     });
     document.querySelectorAll("#predefinedCadences > button").forEach(b => {
       b.addEventListener("click", () => {
diff --git a/client/src/views/Problems.vue b/client/src/views/Problems.vue
index ef05e121..71f5c3e0 100644
--- a/client/src/views/Problems.vue
+++ b/client/src/views/Problems.vue
@@ -188,8 +188,7 @@ export default {
     );
   },
   mounted: function() {
-    document
-      .getElementById("newprobDiv")
+    document.getElementById("newprobDiv")
       .addEventListener("click", processModalClick);
   },
   watch: {
-- 
2.44.0