-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
71 lines (42 loc) · 1.11 KB
/
index.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
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
// TODO : Clear this file up.
var a = Trie();
must_words = ['Apple', 'Ball', 'Cow', 'Dog', 'Eagle', 'Fox', 'Goat', 'Hen', 'Ivan', 'Joker', 'Killer','Lemon','Mango', 'Nose','Orange', 'Pick', 'Risk', 'Steave', 'Truck', 'Utopia', 'Van', 'Wheel', 'Xmas', 'Yolo', 'Zen', 'Zeal']
a.addWord('Hello');
a.addWord('Hall');
a.addWord('Hell');
a.addWord('Chaitya');
a.addWord('What');
a.addWord('Mello');
a.addWord('Champ');
a.addWord('Keep');
a.addWord('What is up?');
a.addWord('make it look good');
a.addWord('Apple');
a.addWord('Ball');
a.addWord('Cow');
a.addWord('Dog');
for(var i =0;i<must_words.length;i++){
a.addWord(must_words[i]);
}
must_words = null;
var suggestions = document.getElementById('suggestions');
var test = document.getElementById('test');
function save(){
var val = test.value;
a.addWord(val);
}
function cb(){
suggestions.innerHTML = '';
var val = test.value;
text = "";
var words = a.giveWords(val);
text="<ul id='sugList'>";
for(var i = 0;i<words.length;i++){
text+="<li>";
text+=words[i];
text+="</li>";
text+="<br/>";
}
text += "</ul>"
suggestions.innerHTML = text;
}