Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72c696420f |
No files matched your search
@@ -2,3 +2,4 @@ config.js
|
||||
db.json
|
||||
__pycache__/
|
||||
*.pyc
|
||||
db_lite.json
|
||||
@@ -60,6 +60,7 @@ var optHltSameCipher = false;
|
||||
var alphaHlt = 0.15; // opacity for values that do not match - change value here and in conf_SOM()
|
||||
|
||||
var optAllowPhraseComments = true; // allow phrase comments, text inside [...] is not evaluated
|
||||
var optPrioritizeIngglish = (typeof CALC_CONFIG !== 'undefined' && CALC_CONFIG.prioritizeIngglishMatches) ? true : false; // sort [Ingglish: ...] matches to top of query results
|
||||
var liveDatabaseMode = true; // live database mode
|
||||
|
||||
var dbPageItems = (typeof CALC_CONFIG !== 'undefined' && CALC_CONFIG.resultsPerPage) ? CALC_CONFIG.resultsPerPage : 12;
|
||||
@@ -103,6 +104,7 @@ var calcOptionsArr = [
|
||||
"optNewPhrasesGoFirst",
|
||||
"optShowExtraCiphers",
|
||||
"optAllowPhraseComments",
|
||||
"optPrioritizeIngglish",
|
||||
"liveDatabaseMode",
|
||||
"optLetterWordCount",
|
||||
"optWordBreakdown",
|
||||
@@ -546,6 +548,8 @@ function createOptionsMenu() {
|
||||
|
||||
if (optShowExtraCiphers) SECstate = "checked"; // Show Extra Ciphers
|
||||
if (optAllowPhraseComments) APCstate = "checked"; // Allow Phrase Comments
|
||||
var PIMstate = "";
|
||||
if (optPrioritizeIngglish) PIMstate = "checked"; // Prioritize Ingglish [...]
|
||||
if (liveDatabaseMode) LDMstate = "checked"; // Live Database Mode
|
||||
|
||||
if (optNewPhrasesGoFirst) NPGFstate = "checked"; // New Phrases Go First
|
||||
@@ -586,6 +590,10 @@ function createOptionsMenu() {
|
||||
'<div class="optionElement"><label class="chkLabel ciphCheckboxLabel2">Ignore Comments [...]<input type="checkbox" id="chkbox_APC" onclick="conf_APC()" ' +
|
||||
APCstate +
|
||||
'><span class="custChkBox"></span></label></div>';
|
||||
o +=
|
||||
'<div class="optionElement"><label class="chkLabel ciphCheckboxLabel2">Prioritize Ingglish [...]<input type="checkbox" id="chkbox_PIM" onclick="conf_PIM()" ' +
|
||||
PIMstate +
|
||||
'><span class="custChkBox"></span></label></div>';
|
||||
o +=
|
||||
'<div class="optionElement"><label class="chkLabel ciphCheckboxLabel2">Live Database Mode<input type="checkbox" id="chkbox_LDM" onclick="conf_LDM()" ' +
|
||||
LDMstate +
|
||||
@@ -709,6 +717,16 @@ function conf_APC() {
|
||||
updateTables();
|
||||
}
|
||||
|
||||
function conf_PIM() {
|
||||
// Prioritize Ingglish [...] Matches
|
||||
optPrioritizeIngglish = !optPrioritizeIngglish;
|
||||
var chk = document.getElementById("chkbox_PIM");
|
||||
if (chk !== null) chk.checked = optPrioritizeIngglish;
|
||||
var btn = document.getElementById("queryIngPriorityBtn");
|
||||
if (btn !== null) btn.classList.toggle("ingPriorityOn", optPrioritizeIngglish);
|
||||
refreshOpenQuery();
|
||||
}
|
||||
|
||||
function conf_LWC() {
|
||||
// Letter/Word Count
|
||||
optLetterWordCount = !optLetterWordCount;
|
||||
|
||||
+34
-14
@@ -109,6 +109,31 @@ function clearDatabaseQueryTable() {
|
||||
queryResultInitial = [] // clear
|
||||
}
|
||||
|
||||
function isIngglishEntry(phr) {
|
||||
return typeof phr === "string" && phr.indexOf("[Ingglish:") !== -1
|
||||
}
|
||||
|
||||
function compareQueryMatches(a, b, searchPhrase) {
|
||||
// 1. Exact phrase match (full string or stripped of [...] comment) always first
|
||||
var aRaw = a[1].toLowerCase()
|
||||
var bRaw = b[1].toLowerCase()
|
||||
var aStripped = aRaw.replace(/\[.+\]/g, '').trim()
|
||||
var bStripped = bRaw.replace(/\[.+\]/g, '').trim()
|
||||
var aExact = (aRaw === searchPhrase || aStripped === searchPhrase) ? 1 : 0
|
||||
var bExact = (bRaw === searchPhrase || bStripped === searchPhrase) ? 1 : 0
|
||||
if (aExact !== bExact) return bExact - aExact
|
||||
|
||||
// 2. When optPrioritizeIngglish is enabled, sort [Ingglish: ...] matches above non-Ingglish matches
|
||||
if (typeof optPrioritizeIngglish !== "undefined" && optPrioritizeIngglish) {
|
||||
var aIng = isIngglishEntry(a[1]) ? 1 : 0
|
||||
var bIng = isIngglishEntry(b[1]) ? 1 : 0
|
||||
if (aIng !== bIng) return bIng - aIng
|
||||
}
|
||||
|
||||
// 3. Then sort by match score descending
|
||||
return b[0] - a[0]
|
||||
}
|
||||
|
||||
function searchDBcrossCipher() { // populate "queryResult" array with matching phrases
|
||||
var p, m, n
|
||||
queryResult = [] // reset matching phrases
|
||||
@@ -145,14 +170,10 @@ function searchDBcrossCipher() { // populate "queryResult" array with matching p
|
||||
}
|
||||
if (tmpArr[0] > 0) queryResult.push(tmpArr) // if total score is more than zero, add phrase to array
|
||||
}
|
||||
// Sort by score descending, but pin exact phrase match to top
|
||||
var searchPhrase = sVal().toLowerCase()
|
||||
// Sort by score descending, pinning exact match and (when enabled) [Ingglish: ...] matches to top
|
||||
var searchPhrase = sVal().toLowerCase().trim()
|
||||
queryResult.sort(function(a, b) {
|
||||
// Exact phrase match always first
|
||||
var aExact = a[1].toLowerCase() === searchPhrase ? 1 : 0
|
||||
var bExact = b[1].toLowerCase() === searchPhrase ? 1 : 0
|
||||
if (aExact !== bExact) return bExact - aExact
|
||||
return b[0] - a[0]; // then by score descending
|
||||
return compareQueryMatches(a, b, searchPhrase)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -185,13 +206,10 @@ function searchDBsameCipher() { // populate "queryResult" array with matching ph
|
||||
}
|
||||
if (tmpArr[0] > 0) queryResult.push(tmpArr) // if total score is more than zero, add phrase to array
|
||||
}
|
||||
// Sort by score descending, but pin exact phrase match to top
|
||||
var searchPhrase = sVal().toLowerCase()
|
||||
// Sort by score descending, pinning exact match and (when enabled) [Ingglish: ...] matches to top
|
||||
var searchPhrase = sVal().toLowerCase().trim()
|
||||
queryResult.sort(function(a, b) {
|
||||
var aExact = a[1].toLowerCase() === searchPhrase ? 1 : 0
|
||||
var bExact = b[1].toLowerCase() === searchPhrase ? 1 : 0
|
||||
if (aExact !== bExact) return bExact - aExact
|
||||
return b[0] - a[0];
|
||||
return compareQueryMatches(a, b, searchPhrase)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -267,9 +285,11 @@ function updateDatabaseQueryTable(stPos = 0, dItems, scrollBarEvent = false) { /
|
||||
|
||||
if (firstPhrase) { // open row on the first phrase
|
||||
firstPhrase = false
|
||||
var ingBtnClass = (typeof optPrioritizeIngglish !== "undefined" && optPrioritizeIngglish) ? "queryPageBtn ingPriorityBtn ingPriorityOn" : "queryPageBtn ingPriorityBtn"
|
||||
ms += '<tr class="cH"><td class="mPQ">'
|
||||
ms += queryResult.length.toLocaleString('en')+' matches'
|
||||
ms += '<br><br>'
|
||||
ms += '<br><input class="'+ingBtnClass+'" id="queryIngPriorityBtn" type="button" value="ING ↑" title="Toggle Ingglish [...] priority sort to top" onclick="event.stopPropagation();conf_PIM()">'
|
||||
ms += '<br>'
|
||||
ms += '<div style="display: inline-flex;">'
|
||||
ms += '<input class="queryPageBtn" id="queryPrevPageBtn" type="button" value="<" onclick="queryShowPrevPage()">'
|
||||
ms += '<input id="queryPosInput" type="tel" autocomplete="off" value="'+curPos+'">'
|
||||
|
||||
@@ -1636,6 +1636,23 @@ body {
|
||||
border: 1px solid var(--border-dark-accent);
|
||||
padding: 0em 0.35em;
|
||||
}
|
||||
.ingPriorityBtn {
|
||||
font-size: 82%;
|
||||
margin: 0.25em 0;
|
||||
padding: 0.1em 0.45em;
|
||||
cursor: pointer;
|
||||
opacity: 0.65;
|
||||
transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
|
||||
}
|
||||
.ingPriorityBtn:hover {
|
||||
opacity: 0.95;
|
||||
}
|
||||
.ingPriorityBtn.ingPriorityOn {
|
||||
opacity: 1;
|
||||
color: var(--border-accent);
|
||||
border-color: var(--border-accent);
|
||||
font-weight: 600;
|
||||
}
|
||||
#queryMinBtn {
|
||||
position: absolute;
|
||||
width: 24px;
|
||||
|
||||
@@ -44,6 +44,7 @@ var CALC_CONFIG = {
|
||||
// --- Defaults ---
|
||||
autoMatchDesktop: true,
|
||||
autoMatchMobile: false,
|
||||
prioritizeIngglishMatches: false, // sort [Ingglish: ...] matches to top of query results
|
||||
resultsPerPage: 12,
|
||||
newPhrasesOnTop: true,
|
||||
|
||||
|
||||
Reference in new issue
Block a user