Upload app.js
Browse files- static/app.js +10 -2
static/app.js
CHANGED
|
@@ -43,6 +43,8 @@ const HISTORY_KEY = "vomebook_search_history";
|
|
| 43 |
const SEARCH_CACHE_LIMIT = 60;
|
| 44 |
const SEARCH_CACHE_TTL = 8 * 60 * 1000;
|
| 45 |
const REQUEST_TIMEOUT_MS = 12000;
|
|
|
|
|
|
|
| 46 |
const folderContentsPending = new Map();
|
| 47 |
const folderTreePending = new Map();
|
| 48 |
const sidebarRetryCounts = new Map();
|
|
@@ -107,8 +109,14 @@ function highlightText(text, query) {
|
|
| 107 |
const patterns = getHighlightPatterns(query);
|
| 108 |
if (!safeText || !patterns.length) return safeText;
|
| 109 |
let output = safeText;
|
|
|
|
| 110 |
for (const pattern of patterns) {
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
}
|
| 113 |
return output;
|
| 114 |
}
|
|
@@ -1550,7 +1558,7 @@ function attachEvents() {
|
|
| 1550 |
addHistory(STATE.query);
|
| 1551 |
renderHistoryDropdown();
|
| 1552 |
doSearch();
|
| 1553 |
-
},
|
| 1554 |
});
|
| 1555 |
DOM.searchInput.addEventListener("compositionstart", () => {
|
| 1556 |
searchComposing = true;
|
|
|
|
| 43 |
const SEARCH_CACHE_LIMIT = 60;
|
| 44 |
const SEARCH_CACHE_TTL = 8 * 60 * 1000;
|
| 45 |
const REQUEST_TIMEOUT_MS = 12000;
|
| 46 |
+
const MAX_HIGHLIGHTS_PER_TEXT = 16;
|
| 47 |
+
const SEARCH_DEBOUNCE_MS = 250;
|
| 48 |
const folderContentsPending = new Map();
|
| 49 |
const folderTreePending = new Map();
|
| 50 |
const sidebarRetryCounts = new Map();
|
|
|
|
| 109 |
const patterns = getHighlightPatterns(query);
|
| 110 |
if (!safeText || !patterns.length) return safeText;
|
| 111 |
let output = safeText;
|
| 112 |
+
let remaining = MAX_HIGHLIGHTS_PER_TEXT;
|
| 113 |
for (const pattern of patterns) {
|
| 114 |
+
if (!remaining) break;
|
| 115 |
+
output = output.replace(pattern, (match) => {
|
| 116 |
+
if (!remaining) return match;
|
| 117 |
+
remaining -= 1;
|
| 118 |
+
return `<mark>${match}</mark>`;
|
| 119 |
+
});
|
| 120 |
}
|
| 121 |
return output;
|
| 122 |
}
|
|
|
|
| 1558 |
addHistory(STATE.query);
|
| 1559 |
renderHistoryDropdown();
|
| 1560 |
doSearch();
|
| 1561 |
+
}, SEARCH_DEBOUNCE_MS);
|
| 1562 |
});
|
| 1563 |
DOM.searchInput.addEventListener("compositionstart", () => {
|
| 1564 |
searchComposing = true;
|