From: Laurent Mazet Date: Wed, 23 Dec 2020 20:52:09 +0000 (+0100) Subject: New option for caption X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=aa595353ac095aef5a2a2c9f35321353ad44a2be;p=trivabble.git New option for caption --- diff --git a/public/index.html b/public/index.html index 8d046a0..ed592cf 100644 --- a/public/index.html +++ b/public/index.html @@ -101,6 +101,18 @@

+

+ +

+
diff --git a/public/trivabble.css b/public/trivabble.css index 85127fd..ce40519 100644 --- a/public/trivabble.css +++ b/public/trivabble.css @@ -122,10 +122,25 @@ html, #board, [draggable], .tile { display:inline-block; white-space:pre-wrap; font-size:7px; - text-overflow:ellipsis; overflow:hidden; } +.special-cell-label-clip { + text-overflow:clip; +} + +.special-cell-label-dots { + text-overflow:ellipsis; +} + +.special-cell-label-none { + visibility:hidden; +} + +.special-cell-label-short { + display:inline; +} + #center-cell .special-cell-label { font-weight:bold; color:black; diff --git a/public/trivabble.js b/public/trivabble.js index 717ebd8..4e7a3b2 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -63,6 +63,7 @@ setConf("PREMIUM_SEVEN_TILES", 50); setConf("SCORE_LAST_PLAYER", true); setConf("ENABLE_TIMER", false); + setConf("CELL_CAPTIONS", "dots"); // "clip", "dots", "none", "short" function isSetting(key) { return Object.prototype.hasOwnProperty.call(Conf, key) || @@ -155,7 +156,8 @@ Timer: "number", TimerEnable: "boolean", TimerGameDate: "number", - TimerTurnDate: "number" + TimerTurnDate: "number", + CellCaptions: "string" }; const _ = (window.libD && libD.l10n) ? libD.l10n() : function (s) { @@ -1542,17 +1544,25 @@ } const specialTypesText = { - doubleLetter: _("Double\nLetter"), - doubleWord: _("Double\nWord"), - tripleLetter: _("Triple\nLetter"), - tripleWord: _("Triple\nWord") + doubleLetter: "Double\nLetter", + doubleWord: "Double\nWord", + tripleLetter: "Triple\nLetter", + tripleWord: "Triple\nWord" + }; + + const specialTypesShortText = { + doubleLetter: "DL", + doubleWord: "DW", + tripleLetter: "TL", + tripleWord: "TW" }; function specialCell(type, cell) { cell.firstChild.appendChild(document.createElement("span")); cell.classList.add("special-cell"); cell.classList.add("special-cell-" + type); - cell.lastChild.lastChild.textContent = cell.title = _(specialTypesText[type]); + cell.lastChild.lastChild.longText = cell.title = _(specialTypesText[type]); + cell.lastChild.lastChild.shortText = _(specialTypesShortText[type]); cell.lastChild.lastChild.className = "special-cell-label"; } @@ -2295,6 +2305,30 @@ } } + function initCellCaptions() { + document.getElementById("cell-captions").onclick = function () { + setCellCaptions(document.getElementById("cell-captions").value); + }; + + setCellCaptions(getSetting("CellCaptions", getSetting("CELL_CAPTIONS"))); + } + + function setCellCaptions(mode) { + setSetting("CellCaptions", mode); + document.getElementById("cell-captions").value = mode; + + for (const cells of [].slice.call(document.getElementsByClassName("special-cell-label"))) { + cells.classList.remove("special-cell-label-clip"); + cells.classList.remove("special-cell-label-dots"); + cells.classList.remove("special-cell-label-none"); + cells.classList.remove("special-cell-label-short"); + + cells.classList.add("special-cell-label-" + mode); + + cells.innerHTML = (mode === "short") ? cells.shortText : cells.longText; + } + } + function repromptName(f) { if (getSetting("PlayerName") && getSetting("PlayerName").trim()) { f(); @@ -2528,6 +2562,7 @@ initFlashLight(); nextHelpMessage(); initTimer(); + initCellCaptions(); }; trivabble.l10nError = trivabble.run;