10 |
// total number of hits |
// total number of hits |
11 |
this.hits = 0; |
this.hits = 0; |
12 |
|
|
13 |
|
this.results_html = null; |
14 |
|
|
15 |
// this function is called for each result |
// this function is called for each result |
16 |
this.result = function (arr) { |
this.result = function (arr) { |
17 |
return '<li><a href="'+arr[1]+'">'+ |
this.results_html += '<li><a href="'+arr[1]+'">'+ |
18 |
(this.hits % 2 == 0 ? '<span style="background: #e0e0e0;">' : '') + |
(this.hits % 2 == 0 ? '<span style="background: #e0e0e0;">' : '') + |
19 |
arr[0] + |
arr[0] + |
20 |
(this.hits % 2 == 0 ? '</span>' : '') + |
(this.hits % 2 == 0 ? '</span>' : '') + |
21 |
'</a></li>'; |
'</a></li>'; |
22 |
|
return true; |
23 |
} |
} |
24 |
|
|
25 |
// this function is called when updating innerHTML with results |
// this function is called when updating innerHTML with results |
26 |
this.display = function (html) { |
this.display = function () { |
27 |
return '<ul>'+html+'</ul>'; |
if (this.results_html) { |
28 |
|
return '<ul>'+this.results_html+'</ul>'; |
29 |
|
} else { |
30 |
|
return null; |
31 |
|
} |
32 |
} |
} |
33 |
|
|
34 |
|
|
99 |
if (clean) { |
if (clean) { |
100 |
results_div.innerHTML = html; |
results_div.innerHTML = html; |
101 |
} else { |
} else { |
102 |
results_div.innerHTML += this.display(html); |
html = this.display(); |
103 |
|
if (html) results_div.innerHTML += html; |
104 |
} |
} |
105 |
} |
} |
106 |
|
|
190 |
|
|
191 |
// full part? (optimization) |
// full part? (optimization) |
192 |
if (find.length == this.min_len) { |
if (find.length == this.min_len) { |
|
var html = ''; |
|
193 |
for (i = 0; i < this.arr[part].length; i++) { |
for (i = 0; i < this.arr[part].length; i++) { |
194 |
html += this.result(this.arr[part][i]); |
this.result(this.arr[part][i]); |
195 |
this.hits++; |
this.hits++; |
196 |
} |
} |
197 |
this.results(html); |
this.results(); |
198 |
} else { |
} else { |
199 |
|
|
200 |
var from = this.binarySearch(this.arr[part], find_lc); |
var from = this.binarySearch(this.arr[part], find_lc); |
203 |
|
|
204 |
this.debug("loop "+from+" ... "+this.arr[part].length); |
this.debug("loop "+from+" ... "+this.arr[part].length); |
205 |
|
|
|
html = ''; |
|
|
|
|
206 |
for(i = from ; i < this.arr[part].length ; i++) { |
for(i = from ; i < this.arr[part].length ; i++) { |
207 |
if (this.arr[part][i][0].substring(0,find.length).toLowerCase() != find_lc) { |
if (this.arr[part][i][0].substring(0,find.length).toLowerCase() != find_lc) { |
208 |
this.debug("loop exit at "+i); |
this.debug("loop exit at "+i); |
209 |
break; |
break; |
210 |
} |
} |
211 |
html += this.result(this.arr[part][i]); |
this.result(this.arr[part][i]); |
212 |
this.hits++; |
this.hits++; |
213 |
} |
} |
214 |
|
|
215 |
this.results(html); |
this.results(); |
216 |
} |
} |
217 |
|
|
218 |
} |
} |