let divAlertCallbackYes;
let divAlertCallbackNo;
let alertInput;
+ let alertSelect;
let divAlertContent;
const _ = (window.libD && libD.l10n) ? libD.l10n() : function (s) {
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"));
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;
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));
* @source: https://gitlab.com/raphj/trivabble/
*/
-/*global libD, myConfirm, myAlert, myPrompt*/
+/*global libD, myConfirm, myAlert, myPrompt, myChoice*/
(function () {
"use strict";
}
/* 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) {