astro-accelerator 0.3.25 → 0.3.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -41,13 +41,25 @@ function enhanceSearchIcon() {
|
|
|
41
41
|
document.body.appendChild(dialog);
|
|
42
42
|
document.body.appendChild(scr);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
function openSearch(e) {
|
|
45
45
|
e.preventDefault();
|
|
46
46
|
dialog.showModal();
|
|
47
47
|
icon.setAttribute('aria-expanded', 'true');
|
|
48
48
|
return false;
|
|
49
|
-
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Open search on CTRL + SPACE
|
|
52
|
+
window.onkeydown = function(e) {
|
|
53
|
+
if (e.ctrlKey && e.key == ' ') {
|
|
54
|
+
return openSearch(e);
|
|
55
|
+
}
|
|
56
|
+
if (e.ctrlKey) return false;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Open search on click
|
|
60
|
+
icon.addEventListener('click', openSearch);
|
|
50
61
|
|
|
62
|
+
// Close dialog
|
|
51
63
|
close.addEventListener('click', () => dialog.close());
|
|
52
64
|
dialog.addEventListener('close', () => icon.setAttribute('aria-expanded', 'false'));
|
|
53
65
|
});
|
package/public/js/search.js
CHANGED
|
@@ -323,8 +323,7 @@ async function search(s, r) {
|
|
|
323
323
|
|
|
324
324
|
cleanQuery.length > 0 && haystack.forEach( (item) => {
|
|
325
325
|
|
|
326
|
-
|
|
327
|
-
let isPhraseFound = false;
|
|
326
|
+
item.foundWords = 0;
|
|
328
327
|
item.score = 0;
|
|
329
328
|
item.matchedHeadings = [];
|
|
330
329
|
|
|
@@ -335,7 +334,8 @@ async function search(s, r) {
|
|
|
335
334
|
// Title
|
|
336
335
|
if (contains(item.safeTitle, currentQuery)) {
|
|
337
336
|
item.score = item.score + scoring.phraseTitle;
|
|
338
|
-
|
|
337
|
+
item.foundWords++;
|
|
338
|
+
item.foundWords++;
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
// Headings
|
|
@@ -343,21 +343,19 @@ async function search(s, r) {
|
|
|
343
343
|
if (contains(c.safeText, currentQuery)) {
|
|
344
344
|
item.score = item.score + scoring.phraseHeading;
|
|
345
345
|
item.matchedHeadings.push(c);
|
|
346
|
-
|
|
346
|
+
item.foundWords++;
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
349
|
|
|
350
350
|
// Description
|
|
351
351
|
if (contains(item.description, currentQuery)) {
|
|
352
352
|
item.score = item.score + scoring.phraseDescription;
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
if (isPhraseFound) {
|
|
357
|
-
foundWords++;
|
|
353
|
+
item.foundWords++;
|
|
358
354
|
}
|
|
359
355
|
|
|
360
356
|
// Part 2 - Term Matches, i.e. "Kitchen" or "Sink"
|
|
357
|
+
|
|
358
|
+
let foundWords = 0;
|
|
361
359
|
|
|
362
360
|
allTerms.forEach(term => {
|
|
363
361
|
let isTermFound = false;
|
|
@@ -405,7 +403,7 @@ async function search(s, r) {
|
|
|
405
403
|
}
|
|
406
404
|
});
|
|
407
405
|
|
|
408
|
-
item.foundWords
|
|
406
|
+
item.foundWords += foundWords;
|
|
409
407
|
|
|
410
408
|
if (item.score > 0) {
|
|
411
409
|
needles.push(item);
|