-
Notifications
You must be signed in to change notification settings - Fork 3
/
script.js
66 lines (56 loc) · 2.09 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
var header = document.querySelector('header');
var section = document.querySelector('section');
var requestURL = 'https://bellerophons-pegasus.github.io/lobib/testItemsJS/test-old.json';
var request = new XMLHttpRequest();
request.open('GET', requestURL);
request.responseType = 'json';
request.send();
request.onload = function() {
var glypticLiterature = request.response;
showLiterature(glypticLiterature);
}
function showLiterature(jsonObj) {
var litlist = jsonObj['literature'];
for (var i = 0; i < litlist.length; i++) {
var bibReference = document.createElement('div');
bibReference.className = "referenceEntry";
var myH2 = document.createElement('h2');
var myPara1 = document.createElement('p');
var keyList = document.createElement('div');
keyList.className = 'keywords';
var myList = document.createElement('ul');
myH2.textContent = litlist[i].date;
myPara1.textContent = litlist[i].workLabel;
keyList.textContent = litlist[i].topics;
/* var superPowers = litlist[i].powers;
for (var j = 0; j < superPowers.length; j++) {
var listItem = document.createElement('li');
listItem.textContent = superPowers[j];
myList.appendChild(listItem);
}
*/
bibReference.appendChild(myH2);
bibReference.appendChild(myPara1);
bibReference.appendChild(keyList);
bibReference.appendChild(myList);
section.appendChild(bibReference);
}
}
function searchAllFun() {
// Declare variables
var input, filter, searchArea, ref, a, i, txtValue;
input = document.getElementById('searchAllSlot');
filter = input.value.toUpperCase();
searchArea = document.querySelector('section');
ref = searchArea.getElementsByClassName("referenceEntry");
// Loop through all list items, and hide those who don't match the search query
for (i = 0; i < ref.length; i++) {
a = ref[i].getElementsByTagName("p")[0];
txtValue = a.textContent || a.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
ref[i].style.display = "";
} else {
ref[i].style.display = "none";
}
}
}