-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
87 lines (60 loc) · 2.96 KB
/
script.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
window.onload = function() {
const vol = document.getElementById('#vol');
const page = document.getElementById('#page');
const searchResults = document.getElementById('cases');
}
function updateSearchResults(keyword) {
document.getElementById('cases').innerHTML = '';
var volume = document.getElementById('vol').value;
var page = document.getElementById('page').value;
var keyword = document.getElementById('case-search').value;
var minYear = document.getElementById('min-year').value;
var maxYear = document.getElementById('max-year').value;
let caseList = [];
for (let element of cases) {
var volNum = element.cite.split(" ")[0];
var pageNum = element.cite.split(" ")[2];
if ((minYear.length == 0 || minYear <= element.year) && (maxYear.length == 0 || maxYear >= element.year)) {
if (keyword.length == 0 || keyword.toLowerCase().split(' ').every(k => element.case.toLowerCase().includes(k))) {
if (volume.length == 0 || volume.toString() == element.cite.split(" ")[0]) {
if ((page.length == 0) || (page.toString() == pageNum)) {
var dkt = "<br>";
if (element.images) {
dkt += 'Docket Sheet: '
for (let e of element.images) {
dkt += '<a href="'+ e + '" download target="_blank">['+ (element.images.indexOf(e)+1) + ']</a> ';
}
} else {
dkt += '[Docket Sheet Unavailable]';
}
while (volNum.length < 3) {
volNum = "0" + volNum;
}
while (pageNum.length < 3) {
pageNum = "0" + pageNum;
}
caseList.push(element.case + '<br>' + element.cite + ' (' + element.year + ')' + ' <a href="https://tile.loc.gov/storage-services/service/ll/usrep/usrep'+ volNum + '/usrep' + volNum + pageNum + '/usrep' + volNum + pageNum + '.pdf" download target="_blank">[Op.]</a>' + dkt);
if (caseList.length < 2 && element.images) {
var i = '';
for (let e of element.images) {
i+= '<img src="';
i += e;
i += '" loading="lazy">';
}
caseList.push(i);
}
}
}
}
}
if (caseList.length > 99) {
break;
}
}
caseList.forEach((e)=> {
document.getElementById('cases').innerHTML += '<p>' + e + '</p>';
});
if (caseList.length > 99) {
document.getElementById('cases').innerHTML += '<p>...</p>';
}
}