-
Notifications
You must be signed in to change notification settings - Fork 25
/
example.html
50 lines (38 loc) · 1.07 KB
/
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
50
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="./jssearch.js"></script>
<script src="./jssearch.index.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
$('#searchbox').on("keyup", function() {
var result = jssearch.search($(this).val());
$('#query').html(jssearch.queryWords.join(' '));
$('#results').html('');
var i = 0;
result.forEach(function(item) {
if (i++ > 20) {
return;
}
var div = $('#results');
div.html(div.html() + '<li>"' + item.file.title + '" ' + item.file.url + ' w:' + item.weight + '</li>');
});
});
});
</script>
<title>Example</title>
</head>
<body>
<h1>Example</h1>
<label for="searchbox" style="display: inline-block; width: 160px;">Search: </label>
<input id="searchbox" type="text" value="">
<br/>
<label for="query" style="display: inline-block; width: 160px;">Actual query: </label>
<span id="query"></span>
<ul id="results">
<li>No results</li>
</ul>
</body>
</html>