/
omnifilter-example.html
49 lines (41 loc) · 1.33 KB
/
omnifilter-example.html
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
<script src="https://datat.vercel.app/basics.js"></script>
<script>
// Omnifilter Function
omnifilter = function (arr) {
/**
* In this example, we create a simple list of links
* using de "titulomaterial" key and "link" key in
* provided JSON registries.
*
* Every time the <input> element changes, the list
* will be rebuilt, filtering the JSON data, returnin
* only the entries that have values (in any of their
* keys) that match the content of the <input>.
*
*/
let htmlcode = "";
htmlcode = "<b>Total of " + arr.length + " results</b><br>";
for (let i = 0; i < arr.length; i++) {
htmlcode +=
"<a target='_blank' + href='" +
arr[i].link +
"'>" +
arr[i].titulomaterial +
"</a><br>";
}
console.table(arr);
document.getElementById("contents").innerHTML = htmlcode;
};
omnifilterfetchdata(
"https://opensheet.elk.sh/1d9eKw82lnM5GvVkBUe8wLcHSxpmDm5B6dUqWRbazOik/MATERIAIS_VISSE",
"myinput"
);
</script>
<meta charset="UTF-8" />
Look the console for the complete information been filtered/searched.<br />
Omnifilter searchs in every key/field of the JSON data.
<br />
<!-- YOU WILL NEED A INPUT TEXT ELEMENT, THIS IS THE xpto ELEMENT -->
<input type="text" id="myinput" />
<br /><br />
<div id="contents"></div>