Merge branch 'develop' into timer
authorLaurent Mazet <mazet@softndesign.org>
Sat, 29 Aug 2020 21:03:57 +0000 (23:03 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Sat, 29 Aug 2020 21:03:57 +0000 (23:03 +0200)
1  2 
l10n/po/fr/trivabble.po
l10n/pot/trivabble.pot
public/index.html
public/trivabble.css
public/trivabble.js

index 1032356a484b1a3253724dbe72cc29d821896cbc,752e8bb3ce0ac8b8d433c95f4e115c96adcf4c29..d5f5f3dea8572712d24581de651b54d64c923bd0
@@@ -166,26 -166,32 +166,50 @@@ msgstr "Vous avez changé la langue du 
  msgid  "{0} changed the language of the board to {1}"
  msgstr "{0} a changé la langue du plateau en {1}"
  
- msgid  "Configuration"
- msgstr "Options de configuration"
++msgid  "Settings"
++msgstr "Paramètres"
 +
- msgid  "Configuration window"
- msgstr "Fenêtre de configuration"
+ msgid  "Check spelling for new words"
+ msgstr "Vérifier l'orthographe des mots nouveaux"
+ 
+ msgid  "Incorrect spelling for {0} from {1}"
+ msgstr "Orthographe incorrecte pour {0} parmi {1}"
+ 
+ msgid  "All words are correct: {0}"
+ msgstr "Tous les mots sont corrects : {0}"
+ 
+ msgid  "No new word found"
+ msgstr "Aucun nouveau mot trouvé"
+ 
+ msgid  "Incorrect dictionary file."
+ msgstr "Dictionnaire incorrect."
+ 
+ msgid  "Can't load dictionary file."
+ msgstr "Impossible de charger le dictionnaire"
+ 
+ msgid  "Enable spell checker"
+ msgstr "Activer le vérificateur orthographique"
+ 
+ msgid  "Spell checking requires Trivabble to download a dictionary. Do you confirm?"
+ msgstr "La vérification orthographique nécessite que Trivabble télécharge un dictionnaire. Confirmez-vous ?"
+ 
+ msgid  "Spell checking is based on:"
+ msgstr "La vérification orthographique est basée sur :"
  
 -msgid  "Settings"
 -msgstr "Paramètres"
 +msgid  "Turn timer:"
 +msgstr "Temps du tour :"
 +
 +msgid  "Global timer:"
 +msgstr "Temp global :"
 +
 +msgid  "{0}d"
 +msgstr "{0}j"
 +
 +msgid  "{0}h"
 +msgstr "{0}h"
 +
 +msgid  "{0}' {1}''"
 +msgstr "{0}' {1}''"
 +
 +msgid  "Enable timer"
 +msgstr "Activer le timer"
index 80ce381ad9937a1c8012e2b2a88232677c36f08d,e8300029947387ecbf87b95fc9d13bd8744c39e5..662c5ed5d8bc0562c1d71c2f9fb12046d0d51139
@@@ -172,26 -172,32 +172,50 @@@ msgstr "
  msgid  "{0} changed the language of the board to {1}"
  msgstr ""
  
- msgid  "Configuration"
++msgid  "Settings"
 +msgstr ""
 +
- msgid  "Configuration window"
+ msgid  "Check spelling for new words"
+ msgstr ""
+ 
+ msgid  "Incorrect spelling for {0} from {1}"
+ msgstr ""
+ 
+ msgid  "All words are correct: {0}"
+ msgstr ""
+ 
+ msgid  "No new word found"
+ msgstr ""
+ 
+ msgid  "Incorrect dictionary file."
+ msgstr ""
+ 
+ msgid  "Can't load dictionary file."
+ msgstr ""
+ 
+ msgid  "Enable spell checker"
+ msgstr ""
+ 
+ msgid  "Spell checking requires Trivabble to download a dictionary. Do you confirm?"
+ msgstr ""
+ 
+ msgid  "Spell checking is based on:"
  msgstr ""
  
 -msgid  "Settings"
 -msgstr ""
 +msgid  "Turn timer:"
 +msgstr ""
 +
 +msgid  "Global timer:"
 +msgstr ""
 +
 +msgid  "{0}d"
 +msgstr ""
 +
 +msgid  "{0}h"
 +msgstr ""
 +
 +msgid  "{0}' {1}''"
 +msgstr ""
 +
 +msgid  "Enable timer"
 +msgstr ""
index 0f64a51f66325cebd10c834bba8eca00d8662e05,a8096464bdce8a5f492c3b849f366c087e4e6f28..8d0308dca8fde2b17dee95893036891bb9f0e27c
              </div>
          </div>
  
-         <div class="modal" id="modal-config-dialog">
+         <div class="modal" id="modal-settings-dialog">
              <div class="modal-content">
                  <h2>
-                     <span data-l10n="text-content">Configuration window</span>
-                     <span class="modal-button" id="modal-close-btn">&#215;</span>
-               </h2>
-                 <div id="prefs-sound">
+                     <span data-l10n="text-content">Settings</span>
+                     <span class="modal-button" id="btn-settings-close">&#215;</span>
+                       </h2>
 -                <div id="prefs-sound">
++                <div id="prefs">
                      <p><label><input type="checkbox" id="tiles-sound" checked="checked" /><span data-l10n="text-content">Sound of the tiles</span></label></p>
                      <p><label><input type="checkbox" id="msg-sound" checked="checked" /><span data-l10n="text-content">Sound of messages</span></label></p>
+                     <p id="enable-spell-checker-outer" style="display:none"><label><input type="checkbox" id="enable-spell-checker" /> <span data-l10n="text-content">Enable spell checker</span></label></p>
 +                    <p><label><input type="checkbox" id="enable-timer" /> <span data-l10n="text-content">Enable timer</span></label></p>
                  </div>
              </div>
          </div>
          </div>
  
          <div id="panel">
-             <div id="timer" style="display:none">
-                 <p>
-                     <span data-l10n="text-content">Turn timer:</span>
-                     <span id="timer-turn">0</span>
-                 </p>
-                 <p>
-                     <span data-l10n="text-content">Global timer:</span>
-                     <span id="timer-global">0</span>
-                 </p>
-             </div>
+             <button id="btn-settings" data-l10n="text-content">Settings</button>
++            <p id="timer" style="display:none">
++                <span data-l10n="text-content">Turn timer:</span>
++                <span id="timer-turn">0</span>
++                <br />
++                <span data-l10n="text-content">Global timer:</span>
++                <span id="timer-global">0</span>
++            </p>
              <div id="bag"></div>
              <p><span data-l10n="text-content">Number of tiles in the bag:</span><br /><span id="remaining-letters">102</span><br /><span id="help-bag" data-l10n="text-content">Click on it to take one.</span><a href="#" id="help-clear" style="display:none"></a></p>
              <table id="participants">
index 6514ccf40e9a3c64aa48f38288525ce7f8d4d021,50ab0eed405824dd2eb42ec42dcc8ef8a5d61c1d..7ead290efab4909ffd4d52c562c1b0cba690a1d1
@@@ -443,11 -457,11 +457,11 @@@ td.blink 
      }
  }
  
--#prefs-sound {
++#prefs {
      margin:1ex 0 0 0;
  }
  
--#prefs-sound p {
++#prefs p {
      margin:0;
      padding:0;
      font-size:small
      font-size:small;
  }
  
--#prefs-sound input, #prefs-sound label {
++#prefs input, #prefs label {
      vertical-align:middle
  }
  
      transition: visibility 0s linear 0s, opacity 0.25s 0s, transform 0.25s;
  }
  
 -}
+ .alert {
+     z-index: 2;
+ }
+ 
+ #btn-settings {
+     background:lightgray;
+     color:black;
+     font-size:small;
+     border-radius:3px;
+     border:none;
+     margin:0 0 0 auto;
+     min-height: 2em;
+ }
+ 
+ #btn-settings:before {
+     content: "⚙️ "
+ }
+ 
+ #info-spell-checking {
+     font-size:small;
+     color:gray;
+ }
+ 
+ #info-spell-checking a {
+     color:black;
++}
++
 +#timer {
 +    text-align: center;
 +}
++
index ffcc07c9c39f188000d2c50134d9d42a55b0e7f7,aa525183d655dcf7e3f80451e0390bdd10f67738..5c380ed1874cffa5cab7c65075426e3151abef32
@@@ -42,8 -42,7 +42,8 @@@
      setConf("ENABLE_EVENT_SOURCE",  true);
      setConf("MAX_WEBSOCKET_ERRORS", 1);
      setConf("APP_PATH",             "");
-     setConf("APP_PATH",             "");
-     setConf("ENABLE_TIMER",        true);
+     setConf("ENABLE_SPELL_CHECKER", false);
++    setConf("ENABLE_TIMER",         true);
  
      const _ = (window.libD && libD.l10n) ? libD.l10n() : function (s) {
          return s;
      function setCurrentPlayer(player) {
          if (currentPlayer && tablePlayers[currentPlayer]) {
              tablePlayers[currentPlayer].classList.remove("current-player");
 +            localStorage.timerTurn = 0;
          }
  
+         currentTilePlayed = {};
          currentPlayer = player;
          refreshCurrentPlayer();
      }
          }
      }
  
+     function initSpellChecker() {
+         if (Conf.ENABLE_SPELL_CHECKER) {
+             document.getElementById("enable-spell-checker-outer").style.display = "";
+         }
+ 
+         document.getElementById("enable-spell-checker").onclick = spellCheckerSettingChecked;
+ 
+         if (!Conf.ENABLE_SPELL_CHECKER || localStorage.spellCheckerEnabled === "false") {
+             document.getElementById("check-spelling").style.display = "none";
+             document.getElementById("enable-spell-checker").checked = false;
+             document.getElementById("info-spell-checking").style.display = "none";
+         } else {
+             document.getElementById("check-spelling").style.display = "";
+             document.getElementById("info-spell-checking").style.display = "";
+             document.getElementById("enable-spell-checker").checked = true;
+         }
+     }
+ 
 +    function timerString(delta) {
 +        const d = Math.floor(delta / (60 * 60 * 24));
 +        const h = Math.floor((delta % (60 * 60 * 24)) / (60 * 60));
 +        const m = Math.floor((delta % (60 * 60)) / 60);
 +        const s = Math.floor(delta % 60);
 +        return ((d > 0) ? format(_("{0}d "), d) : "") +
 +               ((h > 0) ? format(_("{0}h "), h) : "") +
 +               format(_("{0}' {1}''"), m, s);
 +    }
 +
 +    function initTimer() {
 +        if (!Object.prototype.hasOwnProperty.call(localStorage, "timerTurn")) {
 +            localStorage.timerTurn = 0;
 +        }
 +        if (!Object.prototype.hasOwnProperty.call(localStorage, "timerGlobal")) {
 +            localStorage.timerGlobal = 0;
 +        }
 +        if (!Object.prototype.hasOwnProperty.call(localStorage, "timerEnable")) {
 +            localStorage.timerEnable = Conf.ENABLE_TIMER;
 +        }
 +        document.getElementById("enable-timer").onclick = function () {
 +            setTimerState(document.getElementById("enable-timer").checked);
 +        };
 +        setTimerState(localStorage.timerEnable);
 +    }
 +
 +    function setTimerState(state) {
 +        if (state) {
 +            document.getElementById("timer").style.display = "block";
 +            document.getElementById("enable-timer").checked = true;
 +            localStorage.timer = setInterval(function () {
 +                document.getElementById("timer-turn").innerHTML = timerString(++localStorage.timerTurn);
 +                document.getElementById("timer-global").innerHTML = timerString(++localStorage.timerGlobal);
 +            }, 1000);
 +        } else {
 +            document.getElementById("timer").style.display = "none";
 +            document.getElementById("enable-timer").checked = false;
 +            if (Object.prototype.hasOwnProperty.call(localStorage, "timer")) {
 +                clearInterval(localStorage.timer);
 +                delete localStorage.timer;
 +            }
 +            localStorage.timerGlobal = localStorage.timerTurn = 0;
 +        }
 +    }
 +
      function repromptName(f) {
          if (localStorage.trivabblePlayerName && localStorage.trivabblePlayerName.trim()) {
              f();
          initChat();
          initGame();
          initSound();
+         initSpellChecker();
 +        initTimer();
      };
  
      trivabble.l10nError = trivabble.run;