// Max consecutive tries before blacklisting WebSockets for the current session
MAX_WEBSOCKET_ERRORS: 1,
- // to tweak only if your webserver is shared with other conflicting resources at / ( ex: yunohost integration )
+ // To tweak only if your webserver is shared with other conflicting resources at / (e.g. Yunohost integration)
APP_PATH: "",
// Whether the spell checker is enabled (dictionaries must be downloaded on the server before enabling this option)
ENABLE_SPELL_CHECKER: false,
+ // The color of the flash light when double clicking on a cell
+ FLASH_LIGHT_COLOR: "#EE6633",
+
+ // The list of durations of the flash light available in the settings box
+ FLASH_LIGHT_DURATIONS: [800, 1600, 3200],
+
+ // The defaut flash light duration. If not set, the value at the middle of the previous array is used.
+ FLASH_LIGHT_DURATION: 1600,
+
+ // The list of durations used to detect a double tap available in the settings box
+ DOUBLE_TAP_DURATIONS: [650, 1100, 1800, 3000, 5000],
+
+ // The defaut double tap duration. If not set, the value at the middle of the previous array is used.
+ DOUBLE_TAP_DURATION: 1800,
+
+
// I don't like trailing commas, here is a nice message for you reading this file :-)
HAVE_FUN: true
};
<textarea id="chat-ta" placeholder="Write a message to your adversaries here" data-l10n="placeholder"></textarea>
<button id="chat-btn" class="minibutton" data-l10n="text-content">Send message</button>
<div id="lang-selection">
- <label>
- <span data-l10n="text-content">Interface language: </span>
+ <p>
+ <label for="select-lang" data-l10n="text-content">Interface language: </label>
<select id="select-lang">
<option value="en">English</option>
<option value="fr">Français</option>
<option value="br">Brezhoneg</option>
<option value="ro">Română</option>
</select>
- </label>
- </div>
- <div id="board-lang-selection" style="display:none">
- <label>
- <span data-l10n="text-content">Board language: </span>
+ </p>
+ <p id="board-lang-selection" style="display:none">
+ <label for="board-lang" data-l10n="text-content">Board language: </label>
<select id="board-lang">
<option value="fr">French</option>
</select>
- </label>
+ </p>
</div>
</div>
<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><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>
+ <p><label><input type="color" size="6" id="flash-light-color" /> <span data-l10n="text-content">Flash light color</span></label></p>
</div>
</div>
</div>
Conf[parameterName] = defaultValue;
} else if (typeof Conf[parameterName] !== typeof defaultValue) {
myAlert("Head's up - configuration " + parameterName + " does not have the right type. It should be a " + (typeof defaultValue) + ", it is a " + (typeof Conf[parameterName]));
- throw new Error("Wrong type for configuration " + parameterName + ", expected " + (typeof defaultValue) + ", got " + (typeof Conf[parameterName]));
+ throw new Error("Wrong type for configuration " + parameterName + ", expected " + (typeof defaultValue) + ", got " + (typeof Conf[parameterName]));
}
}
+ function middle(key) {
+ const setting = getSetting(key);
+ return setting[Math.floor(setting.length / 2)]
+ }
+
setConf("POLLING_DELAY", 2000);
setConf("ENABLE_WEBSOCKETS", true);
setConf("ENABLE_EVENT_SOURCE", true);
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");
function isSetting(key) {
return Object.prototype.hasOwnProperty.call(Conf, key) ||
}
function setSetting(key, value) {
+ if (getSetting(key) === value) {
+ return;
+ }
+
let type;
/* try to retrieve type from configuration */
localStorage.setItem(key + "_type", type);
}
}
- migrateSetting("doubleTapDuration", "number");
- migrateSetting("flashLightDuration", "number");
+
migrateSetting("spellCheckerEnabled", "boolean");
migrateSetting("trivabbleGameNumber", "number");
migrateSetting("trivabbleBoardLang", "string");
return;
}
- if ((laserTouch.last !== cell) || (Date.now() - laserTouch.date > getSetting("doubleTapDuration"))) {
+ if ((laserTouch.last !== cell) || (Date.now() - laserTouch.date > getSetting("DOUBLE_TAP_DURATION"))) {
laserTouch.last = cell;
laserTouch.date = Date.now();
return;
placeholder.classList.add("laser-highlighting");
placeholder.classList.add("laser-highlight");
- const sixthFlashLightDuration = getSetting("flashLightDuration") / 6;
+ const sixthFlashLightDuration = getSetting("FLASH_LIGHT_DURATION") / 6;
function on() {
placeholder.classList.add("laser-highlight");
document.body.addEventListener("dblclick", laserDblClick);
document.body.addEventListener("touchstart", laserTouch);
- if (!isSetting("doubleTapDuration")) {
- setSetting("doubleTapDuration", getSetting("DOUBLE_TAP_DURATIONS")[Math.floor(getSetting("DOUBLE_TAP_DURATIONS").length / 2)]);
- }
const doubleTapDuration = document.getElementById("double-tap-duration");
if (doubleTapDuration) {
doubleTapDuration.max = getSetting("DOUBLE_TAP_DURATIONS").length - 1;
- doubleTapDuration.value = translateDuration(getSetting("doubleTapDuration"), getSetting("DOUBLE_TAP_DURATIONS"));
+ doubleTapDuration.value = translateDuration(getSetting("DOUBLE_TAP_DURATION"), getSetting("DOUBLE_TAP_DURATIONS"));
doubleTapDuration.onchange = function () {
- setSetting("doubleTapDuration", translateDuration(
+ setSetting("DOUBLE_TAP_DURATION", translateDuration(
document.getElementById("double-tap-duration").value,
getSetting("DOUBLE_TAP_DURATIONS")
));
};
}
- if (!isSetting("flashLightDuration")) {
- setSetting("flashLightDuration", getSetting("FLASH_LIGHT_DURATIONS")[Math.floor(getSetting("FLASH_LIGHT_DURATIONS").length / 2)]);
- }
const flashLightDuration = document.getElementById("flash-light-duration");
if (flashLightDuration) {
flashLightDuration.max = getSetting("FLASH_LIGHT_DURATIONS").length - 1;
- flashLightDuration.value = translateDuration(getSetting("flashLightDuration"), getSetting("FLASH_LIGHT_DURATIONS"));
+ flashLightDuration.value = translateDuration(getSetting("FLASH_LIGHT_DURATION"), getSetting("FLASH_LIGHT_DURATIONS"));
flashLightDuration.onchange = function () {
- setSetting("flashLightDuration", translateDuration(
+ setSetting("FLASH_LIGHT_DURATION", translateDuration(
document.getElementById("flash-light-duration").value,
getSetting("FLASH_LIGHT_DURATIONS")
));
const flashLightColor = document.getElementById("flash-light-color");
if (flashLightColor) {
-
- /* migration of old settings for flash light color */
- const oldSetting = getSetting("flashLightColor");
- if (oldSetting) {
- setSetting("FLASH_LIGHT_COLOR", oldSetting);
- delete localStorage.flashLightColor;
- }
-
+ console.log(getSetting("FLASH_LIGHT_COLOR"));
flashLightColor.value = getSetting("FLASH_LIGHT_COLOR");
flashLightColor.onchange = function () {
setSetting("FLASH_LIGHT_COLOR", document.getElementById("flash-light-color").value);
document.getElementById("btn-settings").onclick = showSettings;
document.getElementById("btn-settings-close").onclick = showSettings;
document.getElementById("next-help-msg").onclick = nextHelpMessage;
+ document.body.addEventListener("keydown", function (e) {
+ if (e.key === 'Escape') {
+ document.querySelector(".modal").classList.remove("show-modal");
+ }
+ });
}
function initGame() {