add a button to change message

This commit is contained in:
Laurent Mazet 2020-09-22 19:02:14 +02:00
parent 96b2721a0d
commit 40a8961622
2 changed files with 12 additions and 12 deletions

View File

@ -78,6 +78,7 @@
<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>
</table>
<button id="next-help-msg" class="minibutton" data-l10n="text-content">Next help message</button>
<div id="help-messages">
<p data-l10n="text-content" style="display:none">Click on the bag to take one tile.</p>
<p data-l10n="text-content" style="display:none">Click on someone's score&#10;to change it.</p>

View File

@ -46,7 +46,6 @@
setConf("DOUBLE_TAP_DURATIONS", [650, 1100, 1800, 3000, 5000]);
setConf("FLASH_LIGHT_DURATIONS", [800, 1600, 3200]);
setConf("FLASH_LIGHT_COLOR", "#E3E");
setConf("HELP_MSG_DELAY", 10000);
const _ = (window.libD && libD.l10n) ? libD.l10n() : function (s) {
return s;
@ -1954,24 +1953,23 @@
}
}
function changeHelpMessage() {
if (typeof changeHelpMessage.index === "undefined") {
changeHelpMessage.index = -1;
function nextHelpMessage() {
if (typeof nextHelpMessage.index === "undefined") {
nextHelpMessage.index = -1;
}
const helpMessages = document.getElementById("help-messages");
if (helpMessages) {
const listOfMessages = helpMessages.getElementsByTagName("p");
if ((changeHelpMessage.index >= 0) && (changeHelpMessage.index <listOfMessages.length)) {
listOfMessages[changeHelpMessage.index].style.display = "none";
if ((nextHelpMessage.index >= 0) && (nextHelpMessage.index < listOfMessages.length)) {
listOfMessages[nextHelpMessage.index].style.display = "none";
}
changeHelpMessage.index++;
if (changeHelpMessage.index === listOfMessages.length) {
changeHelpMessage.index = 0;
nextHelpMessage.index++;
if (nextHelpMessage.index === listOfMessages.length) {
nextHelpMessage.index = 0;
}
listOfMessages[changeHelpMessage.index].style.display = "";
listOfMessages[nextHelpMessage.index].style.display = "";
}
setTimeout(changeHelpMessage, Conf.HELP_MSG_DELAY);
}
function repromptName(f) {
@ -2067,6 +2065,7 @@
document.getElementById("check-spelling").onclick = checkSpellingClicked;
document.getElementById("btn-settings").onclick = showSettings;
document.getElementById("btn-settings-close").onclick = showSettings;
document.getElementById("next-help-msg").onclick = nextHelpMessage;
}
function initGame() {
@ -2191,7 +2190,7 @@
initSound();
initSpellChecker();
initLaserPointer();
changeHelpMessage();
nextHelpMessage();
};
trivabble.l10nError = trivabble.run;