<p><label><input type="checkbox" id="tiles-sound" /><span data-l10n="text-content">Sound of the tiles</span></label></p>
<p><label><input type="checkbox" id="msg-sound" /><span data-l10n="text-content">Sound of messages</span></label></p>
</div>
- <div id="prefs">
- <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>
+ <div>
+ <p>
+ <label for="double-tap-duration" data-l10n="text-content">Double tap duration:</label>
+ <span class="span-range">
+ <span data-l10n="text-content">(fast)</span>
+ <input type="range" min="0" max="0" id="double-tap-duration" />
+ <span data-l10n="text-content">(slow)</span><br/>
+ </span>
+ </p>
</div>
- <div id="prefs">
- <p><label><span data-l10n="text-content">(fast)</span><input type="range" min="0" max="0" id="double-tap-duration"/><span data-l10n="text-content">(slow)</span><br/><span data-l10n="text-content">Double tap duration</span></label></p>
- <p><label><span data-l10n="text-content">(fast)</span><input type="range" min="0" max="0" id="flash-light-duration"/><span data-l10n="text-content">(slow)</span><br/><span data-l10n="text-content">Flash light duration</span></label></p>
- <p><label><input type="text" size="6" id="flash-light-color"/> <span data-l10n="text-content">Flash light color</span></label></p>
+ <div>
+ <p>
+ <label for="flash-light-duration" data-l10n="text-content">Flash light duration:</label>
+ <span class="span-range">
+ <span data-l10n="text-content">(fast)</span>
+ <input type="range" min="0" max="0" id="flash-light-duration" />
+ <span data-l10n="text-content">(slow)</span>
+ </span>
+ </p>
</div>
- <div id="prefs">
+ <div>
+ <p id="flash-light-color-p">
+ <label>
+ <input type="color" size="6" id="flash-light-color" />
+ <span data-l10n="text-content">Flash light color</span>
+ </label>
+ </p>
+ </div>
++ <div>
+ <p><label><input type="checkbox" id="enable-timer" /> <span data-l10n="text-content">Enable timer</span></label></p>
+ </div>
</div>
- </div>
+ </section>
<div id="content">
<table id="board">
</div>
</div>
- <div id="panel">
- <button id="btn-settings" data-l10n="text-content">Settings</button>
+ <div id="panel" class="panel">
+ <div id="btn-settings-wrapper">
+ <button id="btn-settings" data-l10n="text-content">Settings</button>
+ </div>
+ <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>
+ <p><span data-l10n="text-content">Number of tiles in the bag:</span><br /><span id="remaining-letters">102</span></p>
<table id="participants">
<tr><th data-l10n="text-content">Participant</th><th data-l10n="text-content">Rack</th><th data-l10n="text-content">Score</th><th data-l10n="text-content">Turn</th></tr>
<tr id="participants-placeholder"><td colspan="4" data-l10n="text-content">Waiting for other participants…</td></tr>
setConf("ENABLE_TILE_SOUND", true);
setConf("ENABLE_SPELL_CHECKER", false);
setConf("DOUBLE_TAP_DURATIONS", [650, 1100, 1800, 3000, 5000]);
+ setConf("DOUBLE_TAP_DURATION", middle("DOUBLE_TAP_DURATIONS"));
setConf("FLASH_LIGHT_DURATIONS", [800, 1600, 3200]);
- setConf("FLASH_LIGHT_COLOR", "#E3E");
+ setConf("FLASH_LIGHT_DURATION", middle("FLASH_LIGHT_DURATIONS"));
+ setConf("FLASH_LIGHT_COLOR", "#ee6633");
+ setConf("ENABLE_TIMER", true);
function isSetting(key) {
return Object.prototype.hasOwnProperty.call(Conf, key) ||
}
}
+ function nextHelpMessage() {
+ if (typeof nextHelpMessage.index === "undefined") {
+ nextHelpMessage.index = -1;
+ }
+
+ const helpMessages = document.getElementById("help-messages");
+ if (helpMessages) {
+ const listOfMessages = helpMessages.getElementsByTagName("p");
+ if ((nextHelpMessage.index >= 0) && (nextHelpMessage.index < listOfMessages.length)) {
+ listOfMessages[nextHelpMessage.index].hidden = true;
+ }
+ nextHelpMessage.index++;
+ if (nextHelpMessage.index === listOfMessages.length) {
+ nextHelpMessage.index = 0;
+ }
+ listOfMessages[nextHelpMessage.index].hidden = false;
+ }
+ }
+
+ 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 timerDate() {
+ return Math.floor(Date.now() / 1000);
+ }
+
+ function initTimer() {
+ if (!Object.prototype.hasOwnProperty.call(localStorage, "timerTurnDate")) {
+ localStorage.timerTurnDate = timerDate();
+ }
+ if (!Object.prototype.hasOwnProperty.call(localStorage, "timerGlobalDate")) {
+ localStorage.timerGlobalDate = timerDate();
+ }
+ if (!Object.prototype.hasOwnProperty.call(localStorage, "timerEnable")) {
+ localStorage.timerEnable = getSetting("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").textContent = timerString(timerDate() - Number(localStorage.timerTurnDate));
+ document.getElementById("timer-global").textContent = timerString(timerDate() - Number(localStorage.timerGlobalDate));
+ }, 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.timerGlobalDate = localStorage.timerTurnDate = timerDate();
+ }
+ }
+
function repromptName(f) {
if (getSetting("trivabblePlayerName") && getSetting("trivabblePlayerName").trim()) {
f();
initGame();
initSound();
initSpellChecker();
- initLaserPointer();
+ initFlashLight();
+ nextHelpMessage();
+ initTimer();
};
trivabble.l10nError = trivabble.run;