From 8562ab8eddf3c9d187c756d1285f745f1ee866a5 Mon Sep 17 00:00:00 2001 From: malonehunter Date: Sun, 13 Sep 2026 00:20:24 -0400 Subject: [PATCH] calc: refresh matches box in place on cipher toggle (no resubmit) + Query-button centering (parity with production) Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01LmGTn96JVn6xPNNTTW77g1 --- calc/calc.js | 1 + calc/database.js | 24 ++++++++++++++++++++++++ calc/init-variables.js | 1 + calc/styles.css | 7 +++++++ index.html | 8 ++++---- 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/calc/calc.js b/calc/calc.js index fa3e7ea..3b6f5cf 100644 --- a/calc/calc.js +++ b/calc/calc.js @@ -1743,6 +1743,7 @@ function updateTables(updColorLayout = true) { autoHistoryTableLayout(); // use Compact History if necessary updateHistoryTable(); // update history table updateWordBreakdown(breakCipher, true); // update word breakdown and choose first enabled cipher + if (typeof refreshOpenQuery === "function") refreshOpenQuery(); // refresh an open matches box in place after a cipher-set change } function autoHistoryTableLayout() { diff --git a/calc/database.js b/calc/database.js index 6516fbf..8c6d058 100644 --- a/calc/database.js +++ b/calc/database.js @@ -3,6 +3,7 @@ function queryDatabase() { var cVal if(sVal() == "") return // empty input + lastQueryPhrase = sVal() // remember what this box is showing, so a later cipher toggle can refresh it if (liveDatabaseMode == true) calcLiveDatabase(userDBlive) // calculate gematria for live database for enabled ciphers @@ -77,6 +78,29 @@ function queryDatabase() { } } +var _refreshingQuery = false // reentrancy guard: updateTables -> refreshOpenQuery -> queryDatabase must not recurse +function refreshOpenQuery() { + // Called after any cipher-set change (updateTables). If a matches box is open and maximized, + // re-run the SAME query so a newly enabled cipher adds its column (and re-ranks) with no + // resubmit — and a newly disabled cipher drops its column. No-op when no box is open. + if (_refreshingQuery) return + var qa = document.getElementById("queryArea") + if (qa === null || $("#queryArea").hasClass("minimizeQuery")) return // only when open + not minimized + if (lastQueryPhrase === "") return + var box = document.getElementById("phraseBox") + var savedInput = box.value // preserve whatever the user may be typing now + var savedFilter = searchBarValue // preserve the find-in-results filter + _refreshingQuery = true + try { + box.value = lastQueryPhrase // queryDatabase reads sVal(); point it at the open box's phrase + queryDatabase() // rebuilds the table for the current enabled-cipher set + } finally { + box.value = savedInput // restore silently (direct assignment fires no input event) + _refreshingQuery = false + } + if (savedFilter) searchBarDBQuery(savedFilter) // re-apply the filter over the fresh matches +} + function clearDatabaseQueryTable() { $("#calcMain").removeClass("splitInterface") $("#queryArea").remove() // remove element from page diff --git a/calc/init-variables.js b/calc/init-variables.js index 423624a..039b6c7 100644 --- a/calc/init-variables.js +++ b/calc/init-variables.js @@ -38,6 +38,7 @@ var numericalMode // boolean flag, match numbers instead of phrase gematria var userDB = [] // imported database var userDBlive = [] // imported live database (phrases only) var queryResult = [] // matching phrases +var lastQueryPhrase = '' // the phrase that produced the OPEN matches box, so a cipher toggle can refresh it in place var queryResultInitial = [] // matching phrases (used to reset search bar results) var precalcDBLoaded = false // if precalculated database is loaded, disable cipher rearrangement var searchBarValue = '' // search bar value diff --git a/calc/styles.css b/calc/styles.css index ec05267..e3e2037 100644 --- a/calc/styles.css +++ b/calc/styles.css @@ -1018,9 +1018,16 @@ body { } #queryDBbtn { background-color: var(--input-bg-accent); + /* center the "\1F52E Query" value both axes: border-box so the 1px border doesn't bias width, + symmetric zero padding, and an explicit line-height so the emoji's tall line box doesn't push + the baseline down (was reading as extra top/left padding). */ + box-sizing: border-box; padding: 0em; margin: 0em 0.3em; width: 75px; + text-align: center; + line-height: 1; + vertical-align: middle; } #enterPhraseBtn, #autoMatchBtn { diff --git a/index.html b/index.html index 0f2e927..ef2fb2a 100644 --- a/index.html +++ b/index.html @@ -16,11 +16,11 @@ - - + + - + - +