1 |
ef8b343d
|
Scott Ullrich
|
|
2 |
|
|
/* ---- Variables ---- */
|
3 |
|
|
var actb_timeOut = -1; // Autocomplete Timeout in ms (-1: autocomplete never time out)
|
4 |
ac95b982
|
Scott Ullrich
|
var actb_lim = 5; // Number of elements autocomplete can show (-1: no limit)
|
5 |
ef8b343d
|
Scott Ullrich
|
var actb_firstText = false; // should the auto complete be limited to the beginning of keyword?
|
6 |
|
|
/* ---- Variables ---- */
|
7 |
|
|
|
8 |
|
|
/* --- Styles --- */
|
9 |
ac95b982
|
Scott Ullrich
|
var actb_bgColor = '#FFFFFF';
|
10 |
|
|
var actb_textColor = '#000000';
|
11 |
|
|
var actb_hBgColor = '#990000';
|
12 |
|
|
var actb_htextColor = '#FFFFFF';
|
13 |
ef8b343d
|
Scott Ullrich
|
var actb_fFamily = 'Courier';
|
14 |
|
|
var actb_fSize = '14px';
|
15 |
|
|
var actb_hStyle = 'text-decoration:underline;font-weight="bold"';
|
16 |
|
|
/* --- Styles --- */
|
17 |
|
|
|
18 |
|
|
/* ---- Constants ---- */
|
19 |
|
|
var actb_keywords = new Array();
|
20 |
fba72685
|
Scott Ullrich
|
var actb_display = true;
|
21 |
ef8b343d
|
Scott Ullrich
|
var actb_pos = 0;
|
22 |
|
|
var actb_total = 0;
|
23 |
|
|
var actb_curr = null;
|
24 |
|
|
var actb_rangeu = 0;
|
25 |
|
|
var actb_ranged = 0;
|
26 |
|
|
var actb_bool = new Array();
|
27 |
|
|
var actb_pre = 0;
|
28 |
|
|
var actb_toid;
|
29 |
fba72685
|
Scott Ullrich
|
var actb_tomake = true;
|
30 |
ef8b343d
|
Scott Ullrich
|
/* ---- Constants ---- */
|
31 |
|
|
|
32 |
|
|
function actb_parse(n){
|
33 |
|
|
var t = escape(actb_curr.value);
|
34 |
|
|
var tobuild = '';
|
35 |
|
|
var i;
|
36 |
fba72685
|
Scott Ullrich
|
var re = "";
|
37 |
ef8b343d
|
Scott Ullrich
|
|
38 |
|
|
if (actb_firstText){
|
39 |
fba72685
|
Scott Ullrich
|
re = new RegExp("^" + t, "i");
|
40 |
ef8b343d
|
Scott Ullrich
|
}else{
|
41 |
fba72685
|
Scott Ullrich
|
re = new RegExp(t, "i");
|
42 |
ef8b343d
|
Scott Ullrich
|
}
|
43 |
|
|
var p = n.search(re);
|
44 |
|
|
|
45 |
|
|
for (i=0;i<p;i++){
|
46 |
|
|
tobuild += n.substr(i,1);
|
47 |
|
|
}
|
48 |
|
|
tobuild += ""
|
49 |
|
|
for (i=p;i<t.length+p;i++){
|
50 |
|
|
tobuild += n.substr(i,1);
|
51 |
|
|
}
|
52 |
|
|
tobuild += "";
|
53 |
|
|
for (i=t.length+p;i<n.length;i++){
|
54 |
|
|
tobuild += n.substr(i,1);
|
55 |
|
|
}
|
56 |
|
|
return tobuild;
|
57 |
|
|
}
|
58 |
|
|
function actb_generate(){
|
59 |
432d654e
|
Scott Ullrich
|
if(navigator.appName == "Microsoft Internet Explorer") {
|
60 |
f1d0c4cc
|
Scott Ullrich
|
if(window.location.protocol == 'https:') return;
|
61 |
432d654e
|
Scott Ullrich
|
if(actb_keywords.length < 1) return; // if no items setup, do not invoke code. prevent ie crashing.
|
62 |
39be62ce
|
Scott Ullrich
|
if (document.getElementById('tat_frame')) document.body.removeChild(document.getElementById('tat_frame'));
|
63 |
432d654e
|
Scott Ullrich
|
}
|
64 |
ef8b343d
|
Scott Ullrich
|
if (document.getElementById('tat_table')) document.body.removeChild(document.getElementById('tat_table'));
|
65 |
39be62ce
|
Scott Ullrich
|
if(navigator.appName == "Microsoft Internet Explorer") {
|
66 |
|
|
frame = document.createElement('iframe');
|
67 |
|
|
frame.cellSpacing='1px';
|
68 |
|
|
frame.cellPadding='2px';
|
69 |
|
|
frame.style.zIndex = 3;
|
70 |
|
|
frame.style.position='absolute';
|
71 |
|
|
frame.style.top = eval(curTop() + actb_curr.offsetHeight) + "px";
|
72 |
|
|
frame.style.left = curLeft() + "px";
|
73 |
|
|
frame.style.backgroundColor=actb_bgColor;
|
74 |
|
|
frame.id = 'tat_frame';
|
75 |
|
|
}
|
76 |
ef8b343d
|
Scott Ullrich
|
a = document.createElement('table');
|
77 |
|
|
a.cellSpacing='1px';
|
78 |
|
|
a.cellPadding='2px';
|
79 |
ac95b982
|
Scott Ullrich
|
a.style.border = '1px solid #990000';
|
80 |
fba72685
|
Scott Ullrich
|
a.style.zIndex = 5;
|
81 |
ef8b343d
|
Scott Ullrich
|
a.style.position='absolute';
|
82 |
|
|
a.style.top = eval(curTop() + actb_curr.offsetHeight) + "px";
|
83 |
|
|
a.style.left = curLeft() + "px";
|
84 |
|
|
a.style.backgroundColor=actb_bgColor;
|
85 |
|
|
a.id = 'tat_table';
|
86 |
39be62ce
|
Scott Ullrich
|
if(navigator.appName == "Microsoft Internet Explorer")
|
87 |
|
|
document.body.appendChild(frame);
|
88 |
ef8b343d
|
Scott Ullrich
|
document.body.appendChild(a);
|
89 |
|
|
var i;
|
90 |
|
|
var first = true;
|
91 |
|
|
var j = 1;
|
92 |
fba72685
|
Scott Ullrich
|
var height = 0;
|
93 |
ef8b343d
|
Scott Ullrich
|
var counter = 0;
|
94 |
|
|
for (i=0;i<actb_keywords.length;i++){
|
95 |
|
|
if (actb_bool[i]){
|
96 |
|
|
counter++;
|
97 |
|
|
r = a.insertRow(-1);
|
98 |
|
|
if (first && !actb_tomake){
|
99 |
ac95b982
|
Scott Ullrich
|
r.style.backgroundColor = actb_hBgColor;
|
100 |
ef8b343d
|
Scott Ullrich
|
first = false;
|
101 |
|
|
actb_pos = counter;
|
102 |
|
|
}else if(actb_pre == i){
|
103 |
ac95b982
|
Scott Ullrich
|
r.style.backgroundColor = actb_hBgColor;
|
104 |
ef8b343d
|
Scott Ullrich
|
first = false;
|
105 |
|
|
actb_pos = counter;
|
106 |
|
|
}else{
|
107 |
|
|
r.style.backgroundColor = actb_bgColor;
|
108 |
ac95b982
|
Scott Ullrich
|
r.style.color = actb_bgColor;
|
109 |
ef8b343d
|
Scott Ullrich
|
}
|
110 |
|
|
r.id = 'tat_tr'+(j);
|
111 |
|
|
c = r.insertCell(-1);
|
112 |
|
|
c.style.color = actb_textColor;
|
113 |
ac95b982
|
Scott Ullrich
|
counter = 0;
|
114 |
|
|
first = true;
|
115 |
|
|
if (first && !actb_tomake){
|
116 |
|
|
c.style.color = actb_htextColor;
|
117 |
|
|
first = false;
|
118 |
|
|
actb_pos = counter;
|
119 |
|
|
}else if(actb_pre == i){
|
120 |
|
|
c.style.color = actb_htextColor;
|
121 |
|
|
first = false;
|
122 |
|
|
actb_pos = counter;
|
123 |
|
|
}else{
|
124 |
|
|
c.style.color = actb_textColor;
|
125 |
|
|
}
|
126 |
ef8b343d
|
Scott Ullrich
|
c.style.fontFamily = actb_fFamily;
|
127 |
fba72685
|
Scott Ullrich
|
a.style.zIndex = 5;
|
128 |
ef8b343d
|
Scott Ullrich
|
c.style.fontSize = actb_fSize;
|
129 |
|
|
c.innerHTML = actb_parse(actb_keywords[i]);
|
130 |
|
|
c.id = 'tat_td'+(j);
|
131 |
fba72685
|
Scott Ullrich
|
height = height + c.offsetHeight;
|
132 |
|
|
width = c.offsetWidth;
|
133 |
ef8b343d
|
Scott Ullrich
|
j++;
|
134 |
|
|
}
|
135 |
|
|
if (j - 1 == actb_lim && j < actb_total){
|
136 |
|
|
r = a.insertRow(-1);
|
137 |
|
|
r.style.backgroundColor = actb_bgColor;
|
138 |
|
|
c = r.insertCell(-1);
|
139 |
|
|
c.style.color = actb_textColor;
|
140 |
fba72685
|
Scott Ullrich
|
a.style.zIndex = 5;
|
141 |
ef8b343d
|
Scott Ullrich
|
c.style.fontFamily = 'arial narrow';
|
142 |
|
|
c.style.fontSize = actb_fSize;
|
143 |
|
|
c.align='center';
|
144 |
|
|
c.innerHTML = '\\/';
|
145 |
|
|
break;
|
146 |
|
|
}
|
147 |
|
|
}
|
148 |
|
|
actb_rangeu = 1;
|
149 |
|
|
actb_ranged = j-1;
|
150 |
|
|
actb_display = true;
|
151 |
|
|
if (actb_pos <= 0) actb_pos = 1;
|
152 |
39be62ce
|
Scott Ullrich
|
if(navigator.appName == "Microsoft Internet Explorer") {
|
153 |
|
|
frame.width=width;
|
154 |
ffdb7521
|
Scott Ullrich
|
frame.height=height + 5;
|
155 |
39be62ce
|
Scott Ullrich
|
}
|
156 |
ef8b343d
|
Scott Ullrich
|
}
|
157 |
|
|
function curTop(){
|
158 |
|
|
actb_toreturn = 0;
|
159 |
|
|
obj = actb_curr;
|
160 |
|
|
while(obj){
|
161 |
|
|
actb_toreturn += obj.offsetTop;
|
162 |
|
|
obj = obj.offsetParent;
|
163 |
|
|
}
|
164 |
|
|
return actb_toreturn;
|
165 |
|
|
}
|
166 |
|
|
function curLeft(){
|
167 |
|
|
actb_toreturn = 0;
|
168 |
|
|
obj = actb_curr;
|
169 |
|
|
while(obj){
|
170 |
|
|
actb_toreturn += obj.offsetLeft;
|
171 |
|
|
obj = obj.offsetParent;
|
172 |
|
|
}
|
173 |
|
|
return actb_toreturn;
|
174 |
|
|
}
|
175 |
ac95b982
|
Scott Ullrich
|
function actb_remake() {
|
176 |
ef8b343d
|
Scott Ullrich
|
document.body.removeChild(document.getElementById('tat_table'));
|
177 |
39be62ce
|
Scott Ullrich
|
if(navigator.appName == "Microsoft Internet Explorer") {
|
178 |
|
|
document.body.removeChild(document.getElementById('tat_frame'));
|
179 |
|
|
frame = document.createElement('iframe');
|
180 |
|
|
frame.cellSpacing='2px';
|
181 |
|
|
frame.cellPadding='3px';
|
182 |
|
|
frame.style.position='absolute';
|
183 |
|
|
frame.style.zIndex = 5;
|
184 |
|
|
frame.style.top = eval(curTop() + actb_curr.offsetHeight) + "px";
|
185 |
|
|
frame.style.left = curLeft() + "px";
|
186 |
|
|
frame.style.backgroundColor=actb_bgColor;
|
187 |
|
|
frame.id = 'tat_frame';
|
188 |
|
|
}
|
189 |
ef8b343d
|
Scott Ullrich
|
a = document.createElement('table');
|
190 |
|
|
a.cellSpacing='2px';
|
191 |
|
|
a.cellPadding='3px';
|
192 |
|
|
a.style.position='absolute';
|
193 |
fba72685
|
Scott Ullrich
|
a.style.zIndex = 5;
|
194 |
ef8b343d
|
Scott Ullrich
|
a.style.top = eval(curTop() + actb_curr.offsetHeight) + "px";
|
195 |
|
|
a.style.left = curLeft() + "px";
|
196 |
|
|
a.style.backgroundColor=actb_bgColor;
|
197 |
|
|
a.id = 'tat_table';
|
198 |
39be62ce
|
Scott Ullrich
|
if(navigator.appName == "Microsoft Internet Explorer")
|
199 |
|
|
document.body.appendChild(frame);
|
200 |
ef8b343d
|
Scott Ullrich
|
document.body.appendChild(a);
|
201 |
fba72685
|
Scott Ullrich
|
var width = 0;
|
202 |
|
|
var height = 0;
|
203 |
ef8b343d
|
Scott Ullrich
|
var i;
|
204 |
|
|
var first = true;
|
205 |
|
|
var j = 1;
|
206 |
|
|
if (actb_rangeu > 1){
|
207 |
|
|
r = a.insertRow(-1);
|
208 |
|
|
r.style.backgroundColor = actb_bgColor;
|
209 |
|
|
c = r.insertCell(-1);
|
210 |
|
|
c.style.color = actb_textColor;
|
211 |
|
|
c.style.fontFamily = 'arial narrow';
|
212 |
fba72685
|
Scott Ullrich
|
a.style.zIndex = 5;
|
213 |
ef8b343d
|
Scott Ullrich
|
c.style.fontSize = actb_fSize;
|
214 |
|
|
c.align='center';
|
215 |
|
|
c.innerHTML = '/\\';
|
216 |
|
|
}
|
217 |
|
|
for (i=0;i<actb_keywords.length;i++){
|
218 |
|
|
if (actb_bool[i]){
|
219 |
|
|
if (j >= actb_rangeu && j <= actb_ranged){
|
220 |
|
|
r = a.insertRow(-1);
|
221 |
|
|
r.style.backgroundColor = actb_bgColor;
|
222 |
|
|
r.id = 'tat_tr'+(j);
|
223 |
|
|
c = r.insertCell(-1);
|
224 |
|
|
c.style.color = actb_textColor;
|
225 |
|
|
c.style.fontFamily = actb_fFamily;
|
226 |
fba72685
|
Scott Ullrich
|
a.style.zIndex = 5;
|
227 |
ef8b343d
|
Scott Ullrich
|
c.style.fontSize = actb_fSize;
|
228 |
|
|
c.innerHTML = actb_parse(actb_keywords[i]);
|
229 |
|
|
c.id = 'tat_td'+(j);
|
230 |
|
|
j++;
|
231 |
|
|
}else{
|
232 |
|
|
j++;
|
233 |
|
|
}
|
234 |
|
|
}
|
235 |
|
|
if (j > actb_ranged) break;
|
236 |
|
|
}
|
237 |
|
|
if (j-1 < actb_total){
|
238 |
|
|
r = a.insertRow(-1);
|
239 |
|
|
r.style.backgroundColor = actb_bgColor;
|
240 |
|
|
c = r.insertCell(-1);
|
241 |
|
|
c.style.color = actb_textColor;
|
242 |
|
|
c.style.fontFamily = 'arial narrow';
|
243 |
|
|
c.style.fontSize = actb_fSize;
|
244 |
|
|
c.align='center';
|
245 |
|
|
c.innerHTML = '\\/';
|
246 |
fba72685
|
Scott Ullrich
|
height = height + c.height;
|
247 |
|
|
width = c.width;
|
248 |
ef8b343d
|
Scott Ullrich
|
}
|
249 |
39be62ce
|
Scott Ullrich
|
if(navigator.appName == "Microsoft Internet Explorer") {
|
250 |
|
|
frame.width=width
|
251 |
|
|
frame.height=height;
|
252 |
|
|
}
|
253 |
ef8b343d
|
Scott Ullrich
|
}
|
254 |
|
|
function actb_goup(){
|
255 |
|
|
if (!actb_display) return;
|
256 |
|
|
if (actb_pos == 1) return;
|
257 |
|
|
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_bgColor;
|
258 |
ac95b982
|
Scott Ullrich
|
document.getElementById('tat_td'+actb_pos).style.color = actb_textColor;
|
259 |
ef8b343d
|
Scott Ullrich
|
actb_pos--;
|
260 |
|
|
if (actb_pos < actb_rangeu) actb_moveup();
|
261 |
ac95b982
|
Scott Ullrich
|
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_hBgColor;
|
262 |
|
|
document.getElementById('tat_td'+actb_pos).style.color = actb_htextColor;
|
263 |
ef8b343d
|
Scott Ullrich
|
if (actb_toid) clearTimeout(actb_toid);
|
264 |
|
|
if (actb_timeOut > 0) actb_toid = setTimeout("actb_removedisp()",actb_timeOut);
|
265 |
|
|
}
|
266 |
|
|
function actb_godown(){
|
267 |
|
|
if (!actb_display) return;
|
268 |
|
|
if (actb_pos == actb_total) return;
|
269 |
|
|
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_bgColor;
|
270 |
ac95b982
|
Scott Ullrich
|
document.getElementById('tat_td'+actb_pos).style.color = actb_textColor;
|
271 |
ef8b343d
|
Scott Ullrich
|
actb_pos++;
|
272 |
|
|
if (actb_pos > actb_ranged) actb_movedown();
|
273 |
ac95b982
|
Scott Ullrich
|
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_hBgColor;
|
274 |
|
|
document.getElementById('tat_td'+actb_pos).style.color= actb_htextColor;
|
275 |
ef8b343d
|
Scott Ullrich
|
if (actb_toid) clearTimeout(actb_toid);
|
276 |
|
|
if (actb_timeOut > 0) actb_toid = setTimeout("actb_removedisp()",actb_timeOut);
|
277 |
|
|
}
|
278 |
|
|
function actb_movedown(){
|
279 |
|
|
actb_rangeu++;
|
280 |
|
|
actb_ranged++;
|
281 |
|
|
actb_remake();
|
282 |
|
|
}
|
283 |
|
|
function actb_moveup(){
|
284 |
|
|
actb_rangeu--;
|
285 |
|
|
actb_ranged--;
|
286 |
|
|
actb_remake();
|
287 |
|
|
}
|
288 |
|
|
function actb_penter(){
|
289 |
|
|
if (!actb_display) return;
|
290 |
|
|
actb_display = 0;
|
291 |
|
|
var word = '';
|
292 |
|
|
var c = 0;
|
293 |
|
|
for (var i=0;i<=actb_keywords.length;i++){
|
294 |
|
|
if (actb_bool[i]) c++;
|
295 |
|
|
if (c == actb_pos){
|
296 |
|
|
word = actb_keywords[i];
|
297 |
|
|
break;
|
298 |
|
|
}
|
299 |
|
|
}
|
300 |
|
|
a = word;//actb_keywords[actb_pos-1];//document.getElementById('tat_td'+actb_pos).;
|
301 |
|
|
actb_curr.value = a;
|
302 |
|
|
actb_removedisp();
|
303 |
|
|
}
|
304 |
|
|
function actb_removedisp(){
|
305 |
|
|
actb_display = 0;
|
306 |
39be62ce
|
Scott Ullrich
|
if(navigator.appName == "Microsoft Internet Explorer")
|
307 |
|
|
if (document.getElementById('tat_frame')) document.body.removeChild(document.getElementById('tat_frame'));
|
308 |
ef8b343d
|
Scott Ullrich
|
if (document.getElementById('tat_table')) document.body.removeChild(document.getElementById('tat_table'));
|
309 |
|
|
if (actb_toid) clearTimeout(actb_toid);
|
310 |
|
|
}
|
311 |
fba72685
|
Scott Ullrich
|
function actb_checkkey(evt, sndr){
|
312 |
ef8b343d
|
Scott Ullrich
|
a = evt.keyCode;
|
313 |
|
|
if (a == 38){ // up key
|
314 |
|
|
actb_goup();
|
315 |
|
|
}else if(a == 40){ // down key
|
316 |
|
|
actb_godown();
|
317 |
|
|
}else if(a == 13){
|
318 |
|
|
actb_penter();
|
319 |
|
|
}
|
320 |
|
|
}
|
321 |
|
|
function actb_tocomplete(sndr,evt,arr){
|
322 |
|
|
if (arr) actb_keywords = arr;
|
323 |
|
|
if (evt.keyCode == 38 || evt.keyCode == 40 || evt.keyCode == 13) return;
|
324 |
|
|
var i;
|
325 |
|
|
if (actb_display){
|
326 |
|
|
var word = 0;
|
327 |
|
|
var c = 0;
|
328 |
fba72685
|
Scott Ullrich
|
for (i=0;i<=actb_keywords.length;i++){
|
329 |
ef8b343d
|
Scott Ullrich
|
if (actb_bool[i]) c++;
|
330 |
|
|
if (c == actb_pos){
|
331 |
|
|
word = i;
|
332 |
|
|
break;
|
333 |
|
|
}
|
334 |
|
|
}
|
335 |
|
|
actb_pre = word;//actb_pos;
|
336 |
|
|
}else{ actb_pre = -1};
|
337 |
|
|
|
338 |
fba72685
|
Scott Ullrich
|
if (!sndr) sndr = evt.srcElement;
|
339 |
ef8b343d
|
Scott Ullrich
|
actb_curr = sndr;
|
340 |
|
|
|
341 |
|
|
if (sndr.value == ''){
|
342 |
|
|
actb_removedisp();
|
343 |
|
|
return;
|
344 |
|
|
}
|
345 |
|
|
var t = sndr.value;
|
346 |
fba72685
|
Scott Ullrich
|
var re = "";
|
347 |
ef8b343d
|
Scott Ullrich
|
if (actb_firstText){
|
348 |
fba72685
|
Scott Ullrich
|
re = new RegExp("^" + t, "i");
|
349 |
ef8b343d
|
Scott Ullrich
|
}else{
|
350 |
fba72685
|
Scott Ullrich
|
re = new RegExp(t, "i");
|
351 |
ef8b343d
|
Scott Ullrich
|
}
|
352 |
|
|
|
353 |
|
|
actb_total = 0;
|
354 |
|
|
actb_tomake = false;
|
355 |
|
|
for (i=0;i<actb_keywords.length;i++){
|
356 |
|
|
actb_bool[i] = false;
|
357 |
|
|
if (re.test(actb_keywords[i])){
|
358 |
|
|
actb_total++;
|
359 |
|
|
actb_bool[i] = true;
|
360 |
|
|
if (actb_pre == i) actb_tomake = true;
|
361 |
|
|
}
|
362 |
|
|
}
|
363 |
|
|
if (actb_toid) clearTimeout(actb_toid);
|
364 |
|
|
if (actb_timeOut > 0) actb_toid = setTimeout("actb_removedisp()",actb_timeOut);
|
365 |
|
|
actb_generate(actb_bool);
|
366 |
|
|
}
|