divAlertInput.appendChild(alertSelect);
- divAlertInput.appendChild(document.createElement("div"));
- divAlertInput.lastChild.className = "alert-prompt-buttons";
- divAlertInput.lastChild.appendChild(document.createElement("button"));
- divAlertInput.lastChild.lastChild.textContent = _("OK");
- divAlertInput.lastChild.lastChild.onclick = promptOK;
- divAlertInput.lastChild.appendChild(document.createElement("button"));
- divAlertInput.lastChild.lastChild.textContent = _("Annuler");
- divAlertInput.lastChild.lastChild.onclick = promptCancel;
+ const divAlertContentAndInput = document.createElement("div");
+ divAlertContentAndInput.className = "alert-content-and-input";
+ divAlertContentAndInput.appendChild(divAlertContent);
+ divAlertContentAndInput.appendChild(divAlertInput);
+
+ const divAlerPromptButton = document.createElement("div");
+ divAlerPromptButton.className = "alert-prompt-buttons";
+ divAlerPromptButton.appendChild(document.createElement("button"));
+ divAlerPromptButton.lastChild.textContent = _("OK");
+ divAlerPromptButton.lastChild.onclick = promptOK;
+ divAlerPromptButton.appendChild(document.createElement("button"));
+ divAlerPromptButton.lastChild.textContent = _("Annuler");
+ divAlerPromptButton.lastChild.onclick = promptCancel;
divAlertConfirm = document.createElement("div");
divAlertConfirm.className = _("alert-confirm");
const divAlertOuter = document.createElement("div");
divAlertOuter.className = "alert-outer";
- divAlertOuter.appendChild(divAlertContent);
- divAlertOuter.appendChild(divAlertInput);
+ divAlertOuter.appendChild(divAlertContentAndInput);
+ divAlertOuter.appendChild(divAlerPromptButton);
divAlertOuter.appendChild(divAlertConfirm);
divAlertOuter.appendChild(divAlertButton);
divAlert.appendChild(divAlertOuter);
}
divAlert.classList.remove("prompt");
+ divAlert.classList.remove('choice');
+ divAlert.classList.remove('choice-inline');
divAlertContent.textContent = msg;
divAlertInput.style.display = "none";
}
divAlert.classList.add("prompt");
+ divAlert.classList.remove('choice');
+ divAlert.classList.remove('choice-inline');
divAlertContent.textContent = msg;
divAlertInput.style.display = "";
}
divAlert.classList.remove("prompt");
+ divAlert.classList.remove('choice');
+ divAlert.classList.remove('choice-inline');
divAlertContent.textContent = msg;
divAlertInput.style.display = "none";
}
divAlert.classList.remove("prompt");
+ divAlert.classList.add('choice');
+
+ if (options.dispositionInline) {
+ divAlert.classList.add('choice-inline');
+ } else {
+ divAlert.classList.remove('choice-inline');
+ }
alertSelect.options.length = 0;
- for (let i = 0; i < options.length; i++) {
- alertSelect.options[i] = new Option(options[i], options[i]);
+ for (const key of options.choices) {
+ [].push.call(alertSelect.options, new Option(key, key));
}
alertSelect.value = defaultValue;
refreshCurrentPlayer();
}
+ function getScoreCell(playerName) {
+ return tablePlayers[playerName].childNodes[2].childNodes[0];
+ }
+
function setPlayers(players) {
if (participantPlaceholder) {
participantPlaceholder.parentNode.removeChild(participantPlaceholder);
}
if (Object.prototype.hasOwnProperty.call(player, "score")) {
- const scoreCell = tablePlayers[playerName].childNodes[2].childNodes[0];
+ const scoreCell = getScoreCell(playerName);
scoreCell.textContent = player.score;
blink(scoreCell);
}
totalScore += wordScore * wordFactor;
}
- /* Check for trivabble */
+ if (!totalScore) {
+ myAlert(_("There are no points to add."));
+ return;
+ }
+
+ /* Check for trivabble (the premium score) */
if (Object.keys(currentTilePlayed).length === 7) {
totalScore += getSetting("PREMIUM_SEVEN_TILES");
}
- /* Confirm score */
- if ((currentPlayer === "") || (currentPlayer === null)) {
- setCurrentPlayer(getSetting("PlayerName"));
- }
myChoice(
- format(_("{0} points will be added to the following player '{1}'"), totalScore, currentPlayer),
- Object.getOwnPropertyNames(tablePlayers),
+ format(_("{0} points will be added to:"), totalScore), {
+ choices: Object.keys(tablePlayers),
+ dispositionInline: true
+ },
function (name) {
- if ((currentPlayer === "") || (currentPlayer === null)) {
+ if (!name) {
return;
}
- if (currentPlayer !== name) {
- setCurrentPlayer(name);
- }
- const scoreCell = tablePlayers[currentPlayer].childNodes[2].childNodes[0];
+
sendCmds([{
cmd: "score",
player: currentPlayer,
- score: parseInt(scoreCell.textContent) + totalScore
+ score: parseInt(getScoreCell(name).textContent) + totalScore
}]);
},
- currentPlayer);
+ currentPlayer || getSetting("PlayerName")
+ );
}
function triggerFlashLight(cell) {