-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
71 lines (57 loc) · 1.73 KB
/
index.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>OpenJUB SDK DEMO</title>
</head>
<body>
<h1>OpenJUB SDK DEMO</h1>
<div id='container' style='border:1px solid #999;'></div>
<div id='results'></div>
<!-- Load libraries -->
<script src="dist/openjub.js"></script>
<script src='https://lorenzoongithub.github.io/completely/complete.ly.1.0.1.min.js'></script>
<script>
var client = new JUB.Client();
var lastId = -1;
var doSearch = JUB.utils.debounce(function(text){
if(text.length === 0){
return;
}
var myId = (new Date()).getTime();
lastId = myId;
document.getElementById('results').textContent = 'Searching ...';
client.search(text, [], function(err, res){
if(err){
console.error(err);
return;
}
if(lastId === myId){
document.getElementById('results').textContent = JSON.stringify(res.data, null, 4);
}
});
}, 1000);
var auto = completely(document.getElementById('container'), {
fontSize : '24px',
fontFamily : 'Arial',
color:'#933',
});
auto.options = [];
auto.startIndex = 0;
auto.repaint();
auto.onChange = function(text){
var completion = client.complete(text, 20);
auto.options = completion.completions;
auto.startFrom = completion.startIndex;
auto.repaint();
doSearch(text);
};
client.ready(function(){
auto.onChange('');
});
</script>
</body>
</html>