-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_prepare.diff
More file actions
35 lines (31 loc) · 1.04 KB
/
Copy pathpatch_prepare.diff
File metadata and controls
35 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<<<<<<< SEARCH
async function loadPDFDatabase() {
=======
function prepareSearchIndex(data) {
const dateFormatter = new Intl.DateTimeFormat('en-US', {
year: 'numeric', month: 'short', day: 'numeric'
});
const now = new Date().getTime();
const SEVEN_DAYS = 7 * 24 * 60 * 60 * 1000;
for (let i = 0; i < data.length; i++) {
const pdf = data[i];
// 1. Precalculate search string
pdf._searchStr = (
(pdf.title || '') + ' ' +
(pdf.description || '') + ' ' +
(pdf.category || '') + ' ' +
(pdf.author || '')
).toLowerCase();
// 2. Precalculate date logic
const uploadDateObj = new Date(pdf.uploadDate);
if (!isNaN(uploadDateObj)) {
pdf._formattedDate = dateFormatter.format(uploadDateObj);
pdf._isNew = (now - uploadDateObj.getTime()) < SEVEN_DAYS;
} else {
pdf._formattedDate = 'Unknown Date';
pdf._isNew = false;
}
}
}
async function loadPDFDatabase() {
>>>>>>> REPLACE