From bc093771b892cfeda9c6f7a97fcedf6206395746 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Mon, 10 Feb 2020 01:06:48 +0100
Subject: [PATCH] Improve translations

---
 client/src/App.vue            | 11 +++++------
 client/src/translations/en.js |  4 ++--
 client/src/translations/es.js |  4 ++--
 client/src/translations/fr.js |  4 ++--
 client/src/views/Game.vue     |  2 +-
 client/src/views/Hall.vue     |  4 ++--
 server/sockets.js             |  2 ++
 7 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/client/src/App.vue b/client/src/App.vue
index 0c0013e7..2771e282 100644
--- a/client/src/App.vue
+++ b/client/src/App.vue
@@ -82,18 +82,17 @@ export default {
 </script>
 
 <style lang="sass">
-//html, *
-//  font-family: "Open Sans", Arial, sans-serif
-//  --back-color: #f2f2f2
-//  --a-link-color: black
-//  --a-visited-color: black
+html, *
+  font-family: "Open Sans", Arial, sans-serif
+  --back-color: #f2f2f2
+  --a-link-color: black
+  --a-visited-color: black
 
 body
   padding: 0
   min-width: 320px
 
 #app
-  font-family: "Open Sans", "Avenir", Helvetica, Arial, sans-serif
   -webkit-font-smoothing: antialiased
   -moz-osx-font-smoothing: grayscale
 
diff --git a/client/src/translations/en.js b/client/src/translations/en.js
index 8a4ce5e9..37b98a4c 100644
--- a/client/src/translations/en.js
+++ b/client/src/translations/en.js
@@ -80,7 +80,9 @@ export const translations =
   "Settings": "Settings",
   "Stop game": "Stop game",
   "Subject": "Subject",
+  "Target is not connected": "Target is not connected",
   "Terminate game?": "Terminate game?",
+  "This tab is now offline": "This tab is now offline",
   "Three repetitions": "Three repetitions",
   "Time": "Time",
   "To": "To",
@@ -90,8 +92,6 @@ export const translations =
   "Update": "Update",
   "Variant": "Variant",
   "Variants": "Variants",
-  "Warning: target is not connected": "Warning: target is not connected",
-  "Warning: multi-tabs not supported": "Warning: multi-tabs not supported",
   "White": "White",
   "White to move": "White to move",
   "White win": "White win",
diff --git a/client/src/translations/es.js b/client/src/translations/es.js
index af0e6658..34fd2bcc 100644
--- a/client/src/translations/es.js
+++ b/client/src/translations/es.js
@@ -80,7 +80,9 @@ export const translations =
   "Settings": "Configuraciones",
   "Stop game": "Terminar la partida",
   "Subject": "Asunto",
+  "Target is not connected": "El destinatario no está conectado",
   "Terminate game?": "¿ Terminar la partida ?",
+  "This tab is now offline": "Esta pestaña ahora está desconectada",
   "Three repetitions": "Tres repeticiones",
   "Time": "Tiempo",
   "To": "A",
@@ -90,8 +92,6 @@ export const translations =
   "Update": "Actualización",
   "Variant": "Variante",
   "Variants": "Variantes",
-  "Warning: target is not connected": "Advertencia : el destinatario no está conectado",
-  "Warning: multi-tabs not supported": "Advertencia : múltiples pestañas no soportado",
   "White": "Blancas",
   "White to move": "Juegan las blancas",
   "White win": "Las blancas gagnan",
diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js
index ad92da50..26b1c83d 100644
--- a/client/src/translations/fr.js
+++ b/client/src/translations/fr.js
@@ -80,7 +80,9 @@ export const translations =
   "Settings": "Réglages",
   "Stop game": "Arrêter la partie",
   "Subject": "Sujet",
+  "Target is not connected": "La cible n'est pas connectée",
   "Terminate game?": "Stopper la partie ?",
+  "This tab is now offline": "Cet onglet est désormais hors ligne",
   "Three repetitions": "Triple répétition",
   "Time": "Temps",
   "To": "À",
@@ -90,8 +92,6 @@ export const translations =
   "Update": "Mise à jour",
   "Variant": "Variante",
   "Variants": "Variantes",
-  "Warning: target is not connected": "Attention : la cible n'est pas connectée",
-  "Warning: multi-tabs not supported": "Attention : mode multi-onglets non supporté",
   "White": "Blancs",
   "White to move": "Trait aux blancs",
   "White win": "Les blancs gagnent",
diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue
index 8f571538..022e3cb6 100644
--- a/client/src/views/Game.vue
+++ b/client/src/views/Game.vue
@@ -167,7 +167,7 @@ export default {
         case "duplicate":
           this.st.conn.send(JSON.stringify({code:"duplicate",
             page:"/game/" + this.game.id}));
-          alert(this.st.tr["Warning: multi-tabs not supported"]);
+          alert(this.st.tr["This tab is now offline"]);
           break;
         // 0.2] Receive clients list (just socket IDs)
         case "pollclients":
diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue
index b3645684..2395f60e 100644
--- a/client/src/views/Hall.vue
+++ b/client/src/views/Hall.vue
@@ -293,7 +293,7 @@ export default {
           if (!targetSid)
           {
             if (!!warnDisconnected)
-              alert(this.st.tr["Warning: target is not connected"]);
+              alert(this.st.tr["Target is not connected"]);
             return false;
           }
         }
@@ -309,7 +309,7 @@ export default {
         case "duplicate":
           this.st.conn.send(JSON.stringify({code:"duplicate", page:"/"}));
           this.st.conn.send = () => {};
-          alert(this.st.tr["Warning: multi-tabs not supported"]);
+          alert(this.st.tr["This tab is now offline"]);
           break;
         // 0.2] Receive clients list (just socket IDs)
         case "pollclients":
diff --git a/server/sockets.js b/server/sockets.js
index 45e003f8..64b180db 100644
--- a/server/sockets.js
+++ b/server/sockets.js
@@ -17,6 +17,8 @@ module.exports = function(wss) {
   let clients = {}; //associative array sid --> socket
   wss.on("connection", (socket, req) => {
     const query = getJsonFromUrl(req.url);
+    if (query["page"] != "/" && query["page"].indexOf("/game/") < 0)
+      return; //other tabs don't need to be connected
     const sid = query["sid"];
     const notifyRoom = (page,code,obj={},excluded=[]) => {
       Object.keys(clients).forEach(k => {
-- 
2.44.0