9 |
this.id_cache = Array(); |
this.id_cache = Array(); |
10 |
// total number of hits |
// total number of hits |
11 |
this.hits = 0; |
this.hits = 0; |
12 |
// before all results |
|
13 |
this.html_full_pre = '<ul>'; |
// this function is called for each result |
14 |
// before result |
this.result = function (arr) { |
15 |
this.html_pre = '<li><a href="'; |
return '<li><a href="'+arr[1]+'">'+ |
16 |
// id from result |
(this.hits % 2 == 0 ? '<span style="background: #e0e0e0;">' : '') + |
17 |
this.html_mid = '">'; |
arr[0] + |
18 |
// title from result (which was searched also) |
(this.hits % 2 == 0 ? '</span>' : '') + |
19 |
this.html_post = '</a></li>'; |
'</a></li>'; |
20 |
// after all results |
} |
21 |
this.html_full_post = '</ul>'; |
|
22 |
// highlight for every second row in results |
// this function is called when updating innerHTML with results |
23 |
//this.html_hl_start = '<span style="background: #e0e0e0;">'; |
this.display = function (html) { |
24 |
//this.html_hl_end = '</span>'; |
return '<ul>'+html+'</ul>'; |
25 |
this.html_hl_start = ''; |
} |
26 |
this.html_hl_end = ''; |
|
27 |
|
|
28 |
if (! arr) { |
if (! arr) { |
29 |
this.debug("ERROR: can't search empty array"); |
this.debug("ERROR: can't search empty array"); |
90 |
// results_div.style.cursor = 'wait'; // 'auto' |
// results_div.style.cursor = 'wait'; // 'auto' |
91 |
var results_div = this.element_id("results"); |
var results_div = this.element_id("results"); |
92 |
if (clean) { |
if (clean) { |
93 |
results_div.innerHTML = html + "\n"; |
results_div.innerHTML = html; |
94 |
} else { |
} else { |
95 |
results_div.innerHTML += this.html_full_pre + html +"\n" + this.html_full_post; |
results_div.innerHTML += this.display(html); |
96 |
} |
} |
97 |
} |
} |
98 |
|
|
126 |
var mid = (low + high) / 2; |
var mid = (low + high) / 2; |
127 |
var aTry = (mid < 1) ? 0 : parseInt(mid); |
var aTry = (mid < 1) ? 0 : parseInt(mid); |
128 |
|
|
129 |
var curr = arr[aTry][1].substr(0,find.length).toLowerCase(); |
var curr = arr[aTry][0].substr(0,find.length).toLowerCase(); |
130 |
this.debug("low="+low+" high="+high+" lastTry="+lastTry+" "+aTry+": "+curr); |
this.debug("low="+low+" high="+high+" lastTry="+lastTry+" "+aTry+": "+curr); |
131 |
if (curr < find) { |
if (curr < find) { |
132 |
low = aTry + 1; |
low = aTry + 1; |
184 |
if (find.length == this.min_len) { |
if (find.length == this.min_len) { |
185 |
var html = ''; |
var html = ''; |
186 |
for (i = 0; i < this.arr[part].length; i++) { |
for (i = 0; i < this.arr[part].length; i++) { |
187 |
html += this.html_pre + |
html += this.result(this.arr[part][i]); |
|
this.arr[part][i][0] + |
|
|
this.html_mid + |
|
|
(this.hits % 2 == 0 ? this.html_hl_start : ''); |
|
|
//if (this.debug()) { html += i+": "; } |
|
|
html += this.arr[part][i][1] + |
|
|
(this.hits % 2 == 0 ? this.html_hl_end : '') + |
|
|
this.html_post + "\n"; |
|
188 |
this.hits++; |
this.hits++; |
189 |
} |
} |
190 |
this.results(html); |
this.results(html); |
199 |
html = ''; |
html = ''; |
200 |
|
|
201 |
for(i = from ; i < this.arr[part].length ; i++) { |
for(i = from ; i < this.arr[part].length ; i++) { |
202 |
if (this.arr[part][i][1].substring(0,find.length).toLowerCase() != find_lc) { |
if (this.arr[part][i][0].substring(0,find.length).toLowerCase() != find_lc) { |
203 |
this.debug("loop exit at "+i); |
this.debug("loop exit at "+i); |
204 |
break; |
break; |
205 |
} |
} |
206 |
html += this.html_pre + |
html += this.result(this.arr[part][i]); |
|
this.arr[part][i][0] + |
|
|
this.html_mid + |
|
|
(this.hits % 2 == 0 ? this.html_hl_start : ''); |
|
|
//if (this.debug()) { html += i+": "; } |
|
|
html += this.arr[part][i][1] + |
|
|
(this.hits % 2 == 0 ? this.html_hl_end : '') + |
|
|
this.html_post + "\n"; |
|
207 |
this.hits++; |
this.hits++; |
208 |
} |
} |
209 |
|
|
216 |
|
|
217 |
} |
} |
218 |
|
|
|
|
|