-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
39 lines (32 loc) · 837 Bytes
/
test.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
<html>
<head>
<title>Index component</title>
</head>
<body>
<h1>Index component</h1>
<h2>Perform a fuzzy search on the fruit</h2>
<ul id="fruit">
<li>Apple</li>
<li>Pear</li>
<li>Orange</li>
<li>Grape</li>
<li>Plum</li>
<li>Peach</li>
<li>Watermelon</li>
</ul>
<input id="search" type="text" placeholder="search for a fruit" autocomplete="off"><br><br>
Result: <span id="result"></span>
<script src="../build/build.js" type="text/javascript"></script>
<script type="text/javascript">
var Index = require('index'),
fruits = fruit.innerText.trim().split('\n')
index = Index(fruits);
search.oninput = function(e) {
var q = e.target.value;
if(!q) return;
var res = index.search(q);
result.innerHTML = res;
}
</script>
</body>
</html>