From ae79bb84b899e340c57649dec5ae66cb69dc8e33 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Fri, 15 Jan 2021 18:36:36 +0100 Subject: [PATCH] Limit changes on cell text content --- public/trivabble.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/public/trivabble.js b/public/trivabble.js index 6c843b7..0733578 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -2317,16 +2317,28 @@ setSetting("CellCaptions", mode); document.getElementById("cell-captions").value = mode; - board.classList.remove("special-cell-label-clip"); - board.classList.remove("special-cell-label-dots"); - board.classList.remove("special-cell-label-none"); - board.classList.remove("special-cell-label-short"); + if (board.classList.contains("special-cell-label-short")) { + board.classList.remove("special-cell-label-short"); - board.classList.add("special-cell-label-" + mode); + if (mode !== "short") { + for (const cell of [].slice.call(document.getElementsByClassName("special-cell-label"))) { + cell.textContent = cell.longText; + } + } + + } else { + board.classList.remove("special-cell-label-clip"); + board.classList.remove("special-cell-label-dots"); + board.classList.remove("special-cell-label-none"); - for (const cells of [].slice.call(document.getElementsByClassName("special-cell-label"))) { - cells.textContent = (mode === "short") ? cells.shortText : cells.longText; + if (mode === "short") { + for (const cell of [].slice.call(document.getElementsByClassName("special-cell-label"))) { + cell.textContent = cell.shortText; + } + } } + + board.classList.add("special-cell-label-" + mode); } function repromptName(f) { -- 2.30.2