-
Notifications
You must be signed in to change notification settings - Fork 4
/
quicksearch.js
42 lines (34 loc) · 1.15 KB
/
quicksearch.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
var i;
var content = "";
obj = inputstream;
for (i=0;i < obj.length; i++) {
name = obj[i].name;
image = "img/" + obj[i].image;
description = obj[i].description;
link = "https://github.com/open-dict-data/" + name;
content+= "<div class='searchable-item card'><a target='_blank' href='" + link + "'><h3>" + name + "</h3><br><a target='_blank' href='" + link + "'>" + "<img src='" + image + "'></a>" + "<br><br>" + description + "</a></div>";
}
document.getElementById("content").innerHTML = content
// quick search regex
var qsRegex;
// init Isotope
var grid = document.querySelector('.grid');
var iso;
imagesLoaded( grid, function() {
// init Isotope after all images have loaded
iso = new Isotope( grid, {
itemSelector: '.searchable-item',
percentPosition: true,
layoutMode: 'masonry'
});
});
// use value of search field to filter
var quicksearch = document.getElementsByClassName("quicksearch")[0];
quicksearch.onkeyup = function() {
qsRegex = new RegExp( quicksearch.value, 'gi' );
filterValue = function( itemElem ) {
var name = itemElem.textContent;
return name.match(qsRegex);
}
iso.arrange({ filter: filterValue });
}