actb_bgColor = ''; actb_textColor = ''; actb_hColor = ''; actb_fFamily = ''; actb_fSize = ''; actb_hStyle = ''; actb_POS = "right"; function adtb(obj,sMan,sFamily,sDeviceName,sOtherName,sDeviceID,nImageExistsArr,sURL){ /* ---- Public Variables ---- */ this.actb_timeOut = -1; // Autocomplete Timeout in ms (-1: autocomplete never time out) this.actb_lim = 20; // Number of elements autocomplete can show (-1: no limit) this.actb_firstText = false; // should the auto complete be limited to the beginning of keyword? this.actb_mouse = true; // Enable Mouse Support this.actb_delimiter = new Array(';',','); // Delimiter for multiple autocomplete. Set it to empty array for single autocomplete this.actb_startcheck = 2; // Show widget only after this number of characters is typed in. /* ---- Public Variables ---- */ /* ---- Private Variables ---- */ var actb_delimwords = new Array(); var actb_cdelimword = 0; var actb_delimchar = new Array(); var actb_display = false; var actb_pos = 0; var actb_total = 0; var actb_curr = null; var actb_rangeu = 0; var actb_ranged = 0; var actb_bool = new Array(); var actb_pre = 0; var actb_toid; var actb_tomake = false; var actb_getpre = ""; var actb_mouse_on_list = 1; var actb_kwcount = 0; var actb_caretmove = false; this.actb_keywords = new Array(); this.actb_TargetURL = unescape(sURL) /* ---- Private Variables---- */ this.actb_keywords = sDeviceName; this.actb_pids = sDeviceID; this.actb_manufacturer = sMan; this.actb_family = sFamily; this.actb_imageExists = nImageExistsArr this.actb_other = sOtherName; var actb_self = this; actb_curr = obj; addEvent(actb_curr,"focus",actb_setup); function actb_setup(){ addEvent(document,"keydown",actb_checkkey); addEvent(actb_curr,"blur",actb_clear); addEvent(document,"keypress",actb_keypress); } function actb_clear(evt){ if (!evt) evt = event; removeEvent(document,"keydown",actb_checkkey); removeEvent(actb_curr,"blur",actb_clear); removeEvent(document,"keypress",actb_keypress); actb_removedisp(); } function actb_parse(n){ if (actb_self.actb_delimiter.length > 0){ var t = actb_delimwords[actb_cdelimword].trim().addslashes(); var plen = actb_delimwords[actb_cdelimword].trim().length; }else{ var t = actb_curr.value.addslashes(); var plen = actb_curr.value.length; } var tobuild = ''; var i; if (actb_self.actb_firstText){ var re = new RegExp("^" + t, "i"); }else{ var re = new RegExp(t, "i"); } var p = n.search(re); for (i=0;i-1) { tobuild += "" } if(p==-1) { p2 = 0 } else { p2 = p } for (i=p2;i-1) { tobuild += ""; } for (i=plen+p;i -1) { sTargetURL = actb_self.actb_TargetURL + "&deviceid="+ actb_self.actb_pids[i] } else { sTargetURL = actb_self.actb_TargetURL + "?deviceid="+ actb_self.actb_pids[i] } if(actb_self.actb_family[i]!=actb_self.actb_manufacturer[i]) { c.innerHTML = '' + actb_parse(actb_self.actb_manufacturer[i] + " " + actb_self.actb_family[i] + " " + actb_self.actb_keywords[i].substr(0,40)) + ""; } else { c.innerHTML = '' + actb_parse(actb_self.actb_family[i] + " " + actb_self.actb_keywords[i].substr(0,40)) + ""; } c.id = 'tat_td'+(j); c.className = "device_popupsearchCell" c.setAttribute('pos',j); c.setAttribute('TargetURL',sTargetURL); if (actb_self.actb_mouse){ c.style.cursor = 'pointer'; c.onclick=actb_mouseclick; c.onmouseover = actb_table_highlight; c.onmouseout = actb_table_unhighlight; } j++; } if (j - 1 == actb_self.actb_lim && j < actb_total){ r = a.insertRow(-1); r.className = "device_popupsearchRow"; c = r.insertCell(-1); c.style.color = actb_textColor; c.style.fontFamily = 'arial narrow'; c.style.fontSize = actb_fSize; c.align='center'; replaceHTML(c,'\\/'); if (actb_self.actb_mouse){ c.style.cursor = 'pointer'; c.onclick = actb_mouse_down; } break; } } actb_rangeu = 1; actb_ranged = j-1; actb_display = true; if (actb_pos <= 0) actb_pos = 1; } function actb_remake(){ document.body.removeChild(document.getElementById('device_popupsearch')); a = document.createElement('table'); a.cellSpacing='0px'; a.cellPadding='3px'; a.style.position='absolute'; a.style.zIndex='10000'; a.style.top = eval(curTop(actb_curr) + actb_curr.offsetHeight) + "px"; a.id = 'device_popupsearch'; if (window.searchPOS === undefined) { a.style.left = eval(curLeft(actb_curr)) + "px" ; } else { if(searchPOS=="Left") { a.style.left = eval(curLeft(actb_curr)) + "px" ; } else { var docWidth = document.body.clientWidth a.style.right = eval(docWidth - (curLeft(actb_curr) + actb_curr.offsetWidth)) + "px" ; } } if (actb_self.actb_mouse){ a.onmouseout= actb_table_unfocus; a.onmouseover=actb_table_focus; } document.body.appendChild(a); var i; var first = true; var j = 1; if (actb_rangeu > 1){ r = a.insertRow(-1); r.className = "device_popupsearchRow"; c = r.insertCell(-1); c.style.color = actb_textColor; c.style.fontFamily = 'arial narrow'; c.style.fontSize = actb_fSize; c.align='center'; replaceHTML(c,'/\\'); if (actb_self.actb_mouse){ c.style.cursor = 'pointer'; c.onclick = actb_mouse_up; } } for (i=0;i= actb_rangeu && j <= actb_ranged){ r = a.insertRow(-1); r.className = "device_popupsearchRow"; r.id = 'tat_tr'+(j); c = r.insertCell(-1); c.style.color = actb_textColor; c.style.fontFamily = actb_fFamily; c.style.fontSize = actb_fSize; if(actb_self.actb_TargetURL.indexOf("?") > -1) { sTargetURL = actb_self.actb_TargetURL + "&deviceid="+ actb_self.actb_pids[i] } else { sTargetURL = actb_self.actb_TargetURL + "?deviceid="+ actb_self.actb_pids[i] } if(actb_self.actb_family[i]!=actb_self.actb_manufacturer[i]) { c.innerHTML = '' + actb_parse(actb_self.actb_manufacturer[i] + " " + actb_self.actb_family[i] + " " + actb_self.actb_keywords[i].substr(0,40)) + ""; } else { c.innerHTML = '' + actb_parse(actb_self.actb_family[i] + " " + actb_self.actb_keywords[i].substr(0,40)) + ""; } c.id = 'tat_td'+(j); c.setAttribute('pos',j); c.setAttribute('TargetURL',sTargetURL); if (actb_self.actb_mouse){ c.style.cursor = 'pointer'; c.onclick=actb_mouseclick; c.onmouseover = actb_table_highlight; c.onmouseout = actb_table_unhighlight; } j++; }else{ j++; } } if (j > actb_ranged) break; } if (j-1 < actb_total){ r = a.insertRow(-1); r.className = "device_popupsearchRow"; c = r.insertCell(-1); c.style.color = actb_textColor; c.style.fontFamily = 'arial narrow'; c.style.fontSize = actb_fSize; c.align='center'; replaceHTML(c,'\\/'); if (actb_self.actb_mouse){ c.style.cursor = 'pointer'; c.onclick = actb_mouse_down; } } } function actb_goup(){ if (!actb_display) return; if (actb_pos == 1) return; document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_bgColor; actb_pos--; if (actb_pos < actb_rangeu) actb_moveup(); document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_hColor; if (actb_toid) clearTimeout(actb_toid); if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut); } function actb_godown(){ if (!actb_display) return; if (actb_pos == actb_total) return; document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_bgColor; actb_pos++; if (actb_pos > actb_ranged) actb_movedown(); document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_hColor; if (actb_toid) clearTimeout(actb_toid); if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut); } function actb_movedown(){ actb_rangeu = eval(actb_rangeu + 19); actb_ranged = eval(actb_ranged + 19); if(actb_ranged>actb_total) { actb_pos = actb_total; } else { actb_pos = actb_ranged; } actb_remake(); } function actb_moveup(){ actb_rangeu = eval(actb_rangeu - 19); actb_ranged = eval(actb_ranged - 19); if(actb_ranged>actb_total) { actb_pos = actb_total; } else { actb_pos = actb_ranged; } actb_remake(); } /* Mouse */ function actb_mouse_down(){ document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_bgColor; actb_pos++; actb_movedown(); document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_hColor; actb_curr.focus(); actb_mouse_on_list = 0; if (actb_toid) clearTimeout(actb_toid); if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut); } function actb_mouse_up(evt){ if (!evt) evt = event; if (evt.stopPropagation){ evt.stopPropagation(); }else{ evt.cancelBubble = true; } document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_bgColor; actb_pos--; actb_moveup(); document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_hColor; actb_curr.focus(); actb_mouse_on_list = 0; if (actb_toid) clearTimeout(actb_toid); if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut); } function actb_mouseclick(evt){ window.location.href = this.getAttribute('TargetURL'); if (!evt) evt = event; if (!actb_display) return; actb_mouse_on_list = 0; actb_pos = this.getAttribute('pos'); actb_penter(); } function actb_table_focus(){ actb_mouse_on_list = 1; } function actb_table_unfocus(){ actb_mouse_on_list = 0; if (actb_toid) clearTimeout(actb_toid); if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut); } function actb_table_highlight(){ actb_mouse_on_list = 1; document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_bgColor; actb_pos = this.getAttribute('pos'); while (actb_pos < actb_rangeu) actb_moveup(); while (actb_pos > actb_ranged) actb_movedown(); document.getElementById('tat_tr'+actb_pos).className = "hovedevice_popupsearch"; if (actb_toid) clearTimeout(actb_toid); if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut); } function actb_table_unhighlight(){ actb_mouse_on_list = 1; document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_bgColor; actb_pos = this.getAttribute('pos'); while (actb_pos < actb_rangeu) actb_moveup(); while (actb_pos > actb_ranged) actb_movedown(); document.getElementById('tat_tr'+actb_pos).className = "device_popupsearchRow"; if (actb_toid) clearTimeout(actb_toid); if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut); } /* ---- */ function actb_insertword(a){ if (actb_self.actb_delimiter.length > 0){ str = ''; l=0; for (i=0;i=0;--j){ if (actb_delimwords[i].charAt(j) != ' ') break; postspace += ' '; } str += prespace; str += a; l = str.length; if (gotbreak) str += postspace; }else{ str += actb_delimwords[i]; } if (i != actb_delimwords.length - 1){ str += actb_delimchar[i]; } } actb_curr.value = str; setCaret(actb_curr,l); }else{ actb_curr.value = a; } actb_mouse_on_list = 0; actb_removedisp(); } function actb_penter(){ if (!actb_display) return; actb_display = false; var word = ''; var c = 0; for (var i=0;i<=actb_self.actb_keywords.length;i++){ if (actb_bool[i]) c++; if (c == actb_pos){ word = actb_self.actb_keywords[i]; break; } } actb_insertword(word); l = getCaretStart(actb_curr); } function actb_removedisp(){ if (actb_mouse_on_list==0){ actb_display = 0; if (document.getElementById('device_popupsearch')){ document.body.removeChild(document.getElementById('device_popupsearch')); } if (actb_toid) clearTimeout(actb_toid); } } function actb_keypress(e){ if (actb_caretmove) stopEvent(e); return !actb_caretmove; } function actb_checkkey(evt){ if (!evt) evt = event; a = evt.keyCode; caret_pos_start = getCaretStart(actb_curr); actb_caretmove = 0; switch (a){ case 38: actb_goup(); actb_caretmove = 1; return false; break; case 40: actb_godown(); actb_caretmove = 1; return false; break; case 13: case 9: SearchDevice(''); /* if (actb_display){ actb_caretmove = 1; actb_penter(); return false; }else{ return true; } break; */ default: setTimeout(function(){actb_tocomplete(a)},50); break; } } function actb_tocomplete(kc){ if (kc == 38 || kc == 40 || kc == 13) return; var i; if (actb_display){ var word = 0; var c = 0; for (var i=0;i<=actb_self.actb_keywords.length;i++){ if (actb_bool[i]) c++; if (c == actb_pos){ word = i; break; } } actb_pre = word; }else{ actb_pre = -1}; if (actb_curr.value == ''){ actb_mouse_on_list = 0; actb_removedisp(); return; } if (actb_self.actb_delimiter.length > 0){ caret_pos_start = getCaretStart(actb_curr); caret_pos_end = getCaretEnd(actb_curr); delim_split = ''; for (i=0;i= l && caret_pos_end <= l + actb_delimwords[i].length){ actb_cdelimword = i; } l+=actb_delimwords[i].length + 1; } var ot = actb_delimwords[actb_cdelimword].trim(); var t = actb_delimwords[actb_cdelimword].addslashes().trim(); }else{ var ot = actb_curr.value; var t = actb_curr.value.addslashes(); } if (ot.length == 0){ actb_mouse_on_list = 0; actb_removedisp(); } if (ot.length < actb_self.actb_startcheck) return this; if (actb_self.actb_firstText){ var re = new RegExp("^" + t, "i"); }else{ var re = new RegExp(t, "i"); } actb_total = 0; actb_tomake = false; actb_kwcount = 0; for (i=0;i 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut); actb_generate(); } return this; }