add a selector to choice player
This commit is contained in:
parent
b28dc47089
commit
ea2485f71d
|
@ -196,8 +196,8 @@ msgstr "La vérification orthographique nécessite que Trivabble télécharge un
|
|||
msgid "Spell checking is based on:"
|
||||
msgstr "La vérification orthographique est basée sur :"
|
||||
|
||||
msgid "{0} points will be added to the following player '{1}'"
|
||||
msgstr "{0} points vont être ajouté au joueur '{1}'"
|
||||
msgid "{0} points will be added to the following player"
|
||||
msgstr "{0} points vont être ajouté au joueur"
|
||||
|
||||
msgid "Settings"
|
||||
msgstr "Paramètres"
|
||||
|
|
|
@ -196,7 +196,7 @@ msgstr ""
|
|||
msgid "Spell checking is based on:"
|
||||
msgstr ""
|
||||
|
||||
msgid "{0} points will be added to the following player '{1}'"
|
||||
msgid "{0} points will be added to the following player"
|
||||
msgstr ""
|
||||
|
||||
msgid "Settings"
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
let divAlertCallbackYes;
|
||||
let divAlertCallbackNo;
|
||||
let alertInput;
|
||||
let alertSelect;
|
||||
let divAlertContent;
|
||||
|
||||
const _ = (window.libD && libD.l10n) ? libD.l10n() : function (s) {
|
||||
|
@ -85,6 +86,13 @@
|
|||
|
||||
divAlertInput.appendChild(alertInput);
|
||||
|
||||
alertSelect = document.createElement("select");
|
||||
alertSelect.onchange = function () {
|
||||
alertInput.value = alertSelect.value;
|
||||
};
|
||||
|
||||
divAlertInput.appendChild(alertSelect);
|
||||
|
||||
divAlertInput.appendChild(document.createElement("div"));
|
||||
divAlertInput.lastChild.className = "alert-prompt-buttons";
|
||||
divAlertInput.lastChild.appendChild(document.createElement("button"));
|
||||
|
@ -152,8 +160,10 @@
|
|||
|
||||
divAlertContent.textContent = msg;
|
||||
divAlertInput.style.display = "";
|
||||
alertInput.style.display = "";
|
||||
alertInput.value = defaultText || "";
|
||||
alertInput.type = (options && options.type) || "text";
|
||||
alertSelect.style.display = "none";
|
||||
divAlertConfirm.style.display = "none";
|
||||
divAlertButton.style.display = "none";
|
||||
divAlertCallback = callback;
|
||||
|
@ -180,4 +190,28 @@
|
|||
divAlert.style.display = "";
|
||||
divAlertConfirm.getElementsByTagName("button")[0].focus();
|
||||
};
|
||||
|
||||
global.myChoice = function (msg, options, callback, defaultValue) {
|
||||
if (!divAlert) {
|
||||
prepare();
|
||||
}
|
||||
|
||||
divAlert.classList.remove("prompt");
|
||||
|
||||
alertSelect.options.length = 0;
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
alertSelect.options[i] = new Option(options[i], options[i]);
|
||||
}
|
||||
alertSelect.value = defaultValue;
|
||||
|
||||
divAlertContent.textContent = msg;
|
||||
divAlertInput.style.display = "";
|
||||
alertInput.style.display = "none";
|
||||
alertSelect.style.display = "";
|
||||
divAlertConfirm.style.display = "none";
|
||||
divAlertButton.style.display = "none";
|
||||
divAlertCallback = callback;
|
||||
divAlert.style.display = "";
|
||||
divAlertConfirm.getElementsByTagName("button")[0].focus();
|
||||
};
|
||||
}(this));
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* @source: https://gitlab.com/raphj/trivabble/
|
||||
*/
|
||||
|
||||
/*global libD, myConfirm, myAlert, myPrompt*/
|
||||
/*global libD, myConfirm, myAlert, myPrompt, myChoice*/
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
@ -1878,20 +1878,27 @@
|
|||
}
|
||||
|
||||
/* Confirm score */
|
||||
if (currentPlayer === "") {
|
||||
setCurrentPlayer( getSetting("PlayerName"));
|
||||
if ((currentPlayer === "") || (currentPlayer === null)) {
|
||||
setCurrentPlayer(getSetting("PlayerName"));
|
||||
}
|
||||
myConfirm(
|
||||
myChoice(
|
||||
format(_("{0} points will be added to the following player '{1}'"), totalScore, currentPlayer),
|
||||
function () {
|
||||
Object.getOwnPropertyNames(tablePlayers),
|
||||
function (name) {
|
||||
if (currentPlayer === "") {
|
||||
return;
|
||||
}
|
||||
if (currentPlayer !== name) {
|
||||
setCurrentPlayer(name);
|
||||
}
|
||||
const scoreCell = tablePlayers[currentPlayer].childNodes[2].childNodes[0];
|
||||
sendCmds([{
|
||||
cmd: "score",
|
||||
player: currentPlayer,
|
||||
score: parseInt(scoreCell.textContent) + totalScore
|
||||
}]);
|
||||
}
|
||||
);
|
||||
},
|
||||
currentPlayer);
|
||||
}
|
||||
|
||||
function triggerFlashLight(cell) {
|
||||
|
|
Loading…
Reference in New Issue