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 |
this.html_pre = '<a href="'; |
// before all results |
13 |
|
this.html_full_pre = '<ul>'; |
14 |
|
// before result |
15 |
|
this.html_pre = '<li><a href="'; |
16 |
|
// id from result |
17 |
this.html_mid = '">'; |
this.html_mid = '">'; |
18 |
this.html_post = '</a><br/>'; |
// title from result (which was searched also) |
19 |
this.html_full_pre = ''; |
this.html_post = '</a></li>'; |
20 |
this.html_full_post = ''; |
// after all results |
21 |
|
this.html_full_post = '</ul>'; |
22 |
|
// highlight for every second row in results |
23 |
|
//this.html_hl_start = '<span style="background: #e0e0e0;">'; |
24 |
|
//this.html_hl_end = '</span>'; |
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"); |
63 |
} |
} |
64 |
} |
} |
65 |
} |
} |
66 |
|
return null; |
67 |
} |
} |
68 |
|
|
69 |
|
|
105 |
if (! html) { return 1; } |
if (! html) { return 1; } |
106 |
|
|
107 |
var debug_div = this.element_id("debug",1); |
var debug_div = this.element_id("debug",1); |
108 |
if (! debug_div) { return; } |
if (! debug_div) { return null; } |
109 |
|
|
110 |
if (debug_div.innerHTML) { |
debug_div.innerHTML += html + "<br>\n"; |
111 |
debug_div.innerHTML =+ html + "x<br>\n"; |
|
112 |
} else { |
return null; |
|
debug_div.innerHTML = html + "y<br>\n"; |
|
|
} |
|
113 |
} |
} |
114 |
|
|
115 |
|
|
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][1].substr(0,find.length).toLowerCase(); |
130 |
this.debug("low="+low+" high="+high+" lastTry="+lastTry+" "+aTry+": "+curr+"<br>"); |
this.debug("low="+low+" high="+high+" lastTry="+lastTry+" "+aTry+": "+curr); |
131 |
if (curr < find) { |
if (curr < find) { |
132 |
low = aTry + 1; |
low = aTry + 1; |
133 |
continue; |
continue; |
143 |
} |
} |
144 |
return aTry; |
return aTry; |
145 |
} |
} |
146 |
this.debug("lastTry="+lastTry+"<br>"); |
this.debug("lastTry="+lastTry); |
147 |
|
|
148 |
if (typeof (lastTry) != "undefined") { |
if (typeof (lastTry) != "undefined") { |
149 |
return lastTry; |
return lastTry; |
162 |
return; |
return; |
163 |
} |
} |
164 |
|
|
165 |
this.debug("filter: '"+find+"'<br>"); |
this.debug("filter: '"+find+"'"); |
166 |
|
|
167 |
var find_lc = find.toLowerCase(); |
var find_lc = find.toLowerCase(); |
168 |
|
|
178 |
// start anim icon |
// start anim icon |
179 |
//results("<img src=\"pie.gif\"> Please wait, filtering...\n",1); |
//results("<img src=\"pie.gif\"> Please wait, filtering...\n",1); |
180 |
|
|
181 |
|
var i; |
182 |
|
|
183 |
// full part? (optimization) |
// full part? (optimization) |
184 |
if (find.length == this.min_len) { |
if (find.length == this.min_len) { |
185 |
var html = ''; |
var html = ''; |
186 |
for (var i = 0; i < this.arr[part].length; i++) { |
for (i = 0; i < this.arr[part].length; i++) { |
187 |
html += this.html_pre + |
html += this.html_pre + |
188 |
this.arr[part][i][0] + |
this.arr[part][i][0] + |
189 |
this.html_mid + |
this.html_mid + |
190 |
(this.hits % 2 == 0 ? '<span style="background: #e0e0e0">' : ''); |
(this.hits % 2 == 0 ? this.html_hl_start : ''); |
191 |
//if (this.debug()) { html += i+": "; } |
//if (this.debug()) { html += i+": "; } |
192 |
html += this.arr[part][i][1] + |
html += this.arr[part][i][1] + |
193 |
(this.hits % 2 == 0 ? '</span>' : '') + |
(this.hits % 2 == 0 ? this.html_hl_end : '') + |
194 |
this.html_post + "\n"; |
this.html_post + "\n"; |
195 |
this.hits++; |
this.hits++; |
196 |
} |
} |
201 |
|
|
202 |
if (from != null) { |
if (from != null) { |
203 |
|
|
204 |
this.debug("loop "+from+" ... "+this.arr[part].length)+"<br>\n"; |
this.debug("loop "+from+" ... "+this.arr[part].length); |
205 |
|
|
206 |
var html = ''; |
html = ''; |
207 |
|
|
208 |
for(var i = from ; i < this.arr[part].length ; i++) { |
for(i = from ; i < this.arr[part].length ; i++) { |
209 |
if (this.arr[part][i][1].substring(0,find.length).toLowerCase() != find_lc) { |
if (this.arr[part][i][1].substring(0,find.length).toLowerCase() != find_lc) { |
210 |
this.debug("loop exit at "+i); |
this.debug("loop exit at "+i); |
211 |
break; |
break; |
213 |
html += this.html_pre + |
html += this.html_pre + |
214 |
this.arr[part][i][0] + |
this.arr[part][i][0] + |
215 |
this.html_mid + |
this.html_mid + |
216 |
(this.hits % 2 == 0 ? '<span style="background: #e0e0e0">' : ''); |
(this.hits % 2 == 0 ? this.html_hl_start : ''); |
217 |
//if (this.debug()) { html += i+": "; } |
//if (this.debug()) { html += i+": "; } |
218 |
html += this.arr[part][i][1] + |
html += this.arr[part][i][1] + |
219 |
(this.hits % 2 == 0 ? '</span>' : '') + |
(this.hits % 2 == 0 ? this.html_hl_end : '') + |
220 |
this.html_post + "\n"; |
this.html_post + "\n"; |
221 |
this.hits++; |
this.hits++; |
222 |
} |
} |