]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - themes/default/moacdropdown.js
Convert to UTF-8
[SourceForge/phpwiki.git] / themes / default / moacdropdown.js
1 \r
2 function cBrowser(){var userAgent=navigator.userAgent.toLowerCase()\r
3 this.version=parseInt(navigator.appVersion)\r
4 this.subVersion=parseFloat(navigator.appVersion)\r
5 this.ns=((userAgent.indexOf('mozilla')!=-1)&&((userAgent.indexOf('spoofer')==-1)&&(userAgent.indexOf('compatible')==-1)))\r
6 this.ns2=(this.ns&&(this.version==2))\r
7 this.ns3=(this.ns&&(this.version==3))\r
8 this.ns4b=(this.ns&&(this.subVersion<4.04))\r
9 this.ns4=(this.ns&&(this.version==4))\r
10 this.ns5=(this.ns&&(this.version==5))\r
11 this.ie=(userAgent.indexOf('msie')!=-1)\r
12 this.ie3=(this.ie&&(this.version==2))\r
13 this.ie4=(this.ie&&(this.version==4)&&(userAgent.indexOf('msie 4.')!=-1))\r
14 this.ie5=(this.ie&&(this.version==4)&&(userAgent.indexOf('msie 5.0')!=-1))\r
15 this.ie55=(this.ie&&(this.version==4)&&(userAgent.indexOf('msie 5.5')!=-1))\r
16 this.ie6=(this.ie&&(this.version==4)&&(userAgent.indexOf('msie 6.0')!=-1))\r
17 this.op3=(userAgent.indexOf('opera')!=-1)\r
18 this.win=(userAgent.indexOf('win')!=-1)\r
19 this.mac=(userAgent.indexOf('mac')!=-1)\r
20 this.unix=(userAgent.indexOf('x11')!=-1)\r
21 this.name=navigator.appName\r
22 this.dom=this.ns5||this.ie5||this.ie55||this.ie6}\r
23 var bw=new cBrowser()\r
24 cDomEvent={e:null,type:'',button:0,key:0,x:0,y:0,pagex:0,pagey:0,target:null,from:null,to:null}\r
25 cDomEvent.init=function(e)\r
26 {if(window.event)e=window.event\r
27 this.e=e\r
28 this.type=e.type\r
29 this.button=(e.which)?e.which:e.button\r
30 this.key=(e.which)?e.which:e.keyCode\r
31 this.target=(e.srcElement)?e.srcElement:e.originalTarget\r
32 this.currentTarget=(e.currentTarget)?e.currentTarget:e.srcElement\r
33 this.from=(e.originalTarget)?e.originalTarget:(e.fromElement)?e.fromElement:null\r
34 this.to=(e.currentTarget)?e.currentTarget:(e.toElement)?e.toElement:null\r
35 this.x=(e.layerX)?e.layerX:(e.offsetX)?e.offsetX:null\r
36 this.y=(e.layerY)?e.layerY:(e.offsetY)?e.offsetY:null\r
37 this.screenX=e.screenX\r
38 this.screenY=e.screenY\r
39 this.pageX=(e.pageX)?e.pageX:e.x+document.body.scrollLeft\r
40 this.pageY=(e.pageY)?e.pageY:e.y+document.body.scrollTop}\r
41 cDomEvent.getEvent=function(e)\r
42 {if(window.event)e=window.event\r
43 return{e:e,type:e.type,button:(e.which)?e.which:e.button,key:(e.which)?e.which:e.keyCode,target:(e.srcElement)?e.srcElement:e.originalTarget,currentTarget:(e.currentTarget)?e.currentTarget:e.srcElement,from:(e.originalTarget)?e.originalTarget:(e.fromElement)?e.fromElement:null,to:(e.currentTarget)?e.currentTarget:(e.toElement)?e.toElement:null,x:(e.layerX)?e.layerX:(e.offsetX)?e.offsetX:null,y:(e.layerY)?e.layerY:(e.offsetY)?e.offsetY:null,screenX:e.screenX,screenY:e.screenY,pageX:(e.pageX)?e.pageX:(e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)),pageY:(e.pageY)?e.pageY:(e.clientY+(document.documentElement.scrollTop||document.body.scrollTop))}}\r
44 cDomEvent.cancelEvent=function(e)\r
45 {if(e.preventDefault)\r
46 {e.preventDefault()}\r
47 e.returnValue=false\r
48 e.cancelBubble=true\r
49 return false}\r
50 cDomEvent.addEvent=function(hElement,sEvent,handler,bCapture)\r
51 {if(hElement.addEventListener)\r
52 {hElement.addEventListener(sEvent,handler,bCapture)\r
53 return true}\r
54 else if(hElement.attachEvent)\r
55 {return hElement.attachEvent('on'+sEvent,handler)}\r
56 else if(document.all||hElement.captureEvents)\r
57 {if(hElement.captureEvents)eval('hElement.captureEvents( Event.'+sEvent.toUpperCase()+' )')\r
58 eval('hElement.on'+sEvent+' = '+handler)}\r
59 else\r
60 {alert('Not implemented yet!')}}\r
61 cDomEvent.encapsulateEvent=function(hHandler)\r
62 {return function(hEvent)\r
63 {hEvent=cDomEvent.getEvent(hEvent)\r
64 hHandler.call(hEvent.target,hEvent.e)}}\r
65 cDomEvent.addEvent2=function(hElement,sEvent,handler,bCapture)\r
66 {if(hElement)\r
67 {if(hElement.addEventListener)\r
68 {hElement.addEventListener(sEvent,cDomEvent.encapsulateEvent(handler),bCapture)\r
69 return true}\r
70 else if(hElement.attachEvent)\r
71 {return hElement.attachEvent('on'+sEvent,cDomEvent.encapsulateEvent(handler))}\r
72 else\r
73 {alert('Not implemented yet!')}}\r
74 else\r
75 {}}\r
76 cDomEvent.addCustomEvent2=function(hElement,sEvent,handler)\r
77 {if(hElement)\r
78 {hElement[sEvent]=handler}\r
79 else\r
80 {}}\r
81 cDomEvent.removeEvent=function(hElement,sEvent,handler,bCapture)\r
82 {if(hElement.addEventListener)\r
83 {hElement.removeEventListener(sEvent,handler,bCapture)\r
84 return true}\r
85 else if(hElement.attachEvent)\r
86 {return hElement.detachEvent('on'+sEvent,handler)}\r
87 else if(document.all||hElement.captureEvents)\r
88 {eval('hElement.on'+sEvent+' = null')}\r
89 else\r
90 {alert('Not implemented yet!')}}\r
91 function MouseButton()\r
92 {if(document.layers)\r
93 {this.left=1\r
94 this.middle=2\r
95 this.right=3}\r
96 else if(document.all)\r
97 {this.left=1\r
98 this.middle=4\r
99 this.right=2}\r
100 else\r
101 {this.left=0\r
102 this.middle=1\r
103 this.right=2}}\r
104 var MB=new MouseButton()\r
105 if(document.ELEMENT_NODE==null)\r
106 {document.ELEMENT_NODE=1\r
107 document.TEXT_NODE=3}\r
108 function getSubNodeByName(hNode,sNodeName)\r
109 {if(hNode!=null)\r
110 {var nNc=0\r
111 var nC=0\r
112 var hNodeChildren=hNode.childNodes\r
113 var hCNode=null\r
114 while(nC<hNodeChildren.length)\r
115 {hCNode=hNodeChildren.item(nC++)\r
116 if((hCNode.nodeType==1)&&(hCNode.nodeName.toLowerCase()==sNodeName))\r
117 {return hCNode}}}\r
118 return null}\r
119 function getPrevNodeSibling(hNode)\r
120 {if(hNode!=null)\r
121 {do{hNode=hNode.previousSibling}while(hNode!=null&&hNode.nodeType!=1)\r
122 return hNode}}\r
123 function getNextNodeSibling(hNode)\r
124 {if(hNode!=null)\r
125 {do{hNode=hNode.nextSibling}while(hNode!=null&&hNode.nodeType!=1)\r
126 return hNode}}\r
127 function getLastSubNodeByName(hNode,sNodeName)\r
128 {if(hNode!=null)\r
129 {var nNc=0\r
130 var nC=0\r
131 var hNodeChildren=hNode.childNodes\r
132 var hCNode=null\r
133 var nLength=hNodeChildren.length-1\r
134 while(nLength>=0)\r
135 {hCNode=hNodeChildren.item(nLength)\r
136 if((hCNode.nodeType==1)&&(hCNode.nodeName.toLowerCase()==sNodeName))\r
137 {return hCNode}\r
138 nLength--}}\r
139 return null}\r
140 function getSubNodeByProperty(hNode,sProperty,sPropValue)\r
141 {if(hNode!=null)\r
142 {var nNc=0\r
143 var nC=0\r
144 var hNodeChildren=hNode.childNodes\r
145 var hCNode=null\r
146 var sAttribute\r
147 var hProp\r
148 sPropValue=sPropValue.toLowerCase()\r
149 while(nC<hNodeChildren.length)\r
150 {hCNode=hNodeChildren.item(nC++)\r
151 if(hCNode.nodeType==document.ELEMENT_NODE)\r
152 {hProp=eval('hCNode.'+sProperty)\r
153 if(typeof(sPropValue)!='undefined')\r
154 {if(hProp.toLowerCase()==sPropValue)\r
155 {return hCNode}}\r
156 else\r
157 {return hCNode}}\r
158 nNc++}}\r
159 return null}\r
160 function findAttribute(hNode,sAtt)\r
161 {sAtt=sAtt.toLowerCase()\r
162 for(var nI=0;nI<hNode.attributes.length;nI++)\r
163 {if(hNode.attributes.item(nI).nodeName.toLowerCase()==sAtt)\r
164 {return hNode.attributes.item(nI).nodeValue}}\r
165 return null}\r
166 function getSubNodeByAttribute(hNode,sAtt,sAttValue)\r
167 {if(hNode!=null)\r
168 {var nNc=0\r
169 var nC=0\r
170 var hNodeChildren=hNode.childNodes\r
171 var hCNode=null\r
172 var sAttribute\r
173 sAttValue=sAttValue.toLowerCase()\r
174 while(nC<hNodeChildren.length)\r
175 {hCNode=hNodeChildren.item(nC++)\r
176 if(hCNode.nodeType==document.ELEMENT_NODE)\r
177 {sAttribute=hCNode.getAttribute(sAtt)\r
178 if(sAttribute&&sAttribute.toLowerCase()==sAttValue)\r
179 return hCNode}\r
180 nNc++}}\r
181 return null}\r
182 function getLastSubNodeByAttribute(hNode,sAtt,sAttValue)\r
183 {if(hNode!=null)\r
184 {var nNc=0\r
185 var nC=0\r
186 var hNodeChildren=hNode.childNodes\r
187 var hCNode=null\r
188 var nLength=hNodeChildren.length-1\r
189 while(nLength>=0)\r
190 {hCNode=hNodeChildren.item(nLength)\r
191 if(hCNode.nodeType==document.ELEMENT_NODE)\r
192 {sAttribute=hCNode.getAttribute(sAtt)\r
193 if(sAttribute&&sAttribute.toLowerCase()==sAttValue)\r
194 return hCNode}\r
195 nLength--}}\r
196 return null}\r
197 function getParentByTagName(hNode,sParentTagName)\r
198 {while((hNode.tagName)&&!(/(body|html)/i.test(hNode.tagName)))\r
199 {if(hNode.tagName==sParentTagName)\r
200 {return hNode}\r
201 hNode=hNode.parentNode}\r
202 return null}\r
203 function getParentByAttribute(hNode,sAtt,sAttValue)\r
204 {while((hNode.tagName)&&!(/(body|html)/i.test(hNode.tagName)))\r
205 {var sAttr=hNode.getAttribute(sAtt)\r
206 if(sAttr!=null&&sAttr.toString().length>0)\r
207 {if(sAttValue!==null)\r
208 {if(sAttr==sAttValue)\r
209 {return hNode}}\r
210 else\r
211 {return hNode}}\r
212 hNode=hNode.parentNode}\r
213 return null}\r
214 function getParentByProperty(hNode,sProperty,sPropValue)\r
215 {while((hNode.tagName)&&!(/(body|html)/i.test(hNode.tagName)))\r
216 {var hProp=eval('hNode.'+sProperty)\r
217 if(hProp!=null&&hProp.toString().length>0)\r
218 {if(sPropValue!==null)\r
219 {if(hProp==sPropValue)\r
220 {return hNode}}\r
221 else\r
222 {return hNode}}\r
223 hNode=hNode.parentNode}\r
224 return null}\r
225 function getNodeText(hNode)\r
226 {if(hNode==null)\r
227 {return''}\r
228 var sRes\r
229 if(hNode.hasChildNodes())\r
230 {sRes=hNode.childNodes.item(0).nodeValue}\r
231 else\r
232 {sRes=hNode.text}\r
233 return sRes}\r
234 function cDomExtension(hParent,aSelectors,hInitFunction)\r
235 {this.hParent=hParent\r
236 this.aSelectors=aSelectors\r
237 this.hInitFunction=hInitFunction}\r
238 cDomExtensionManager={aExtensions:new Array()}\r
239 cDomExtensionManager.register=function(hDomExtension)\r
240 {cDomExtensionManager.aExtensions.push(hDomExtension)}\r
241 cDomExtensionManager.initSelector=function(hParent,sSelector,hInitFunction)\r
242 {var hSelectorRegEx\r
243 var hAttributeRegEx\r
244 var aSelectorData\r
245 var aAttributeData\r
246 var sAttribute\r
247 hSelectorRegEx=/([a-z0-9_]*)\[?([^\]]*)\]?/i\r
248 hAttributeRegEx=/([a-z0-9_]*)([\*\^\$]?)(=?)(([a-z0-9_=]*))/i\r
249 if(hSelectorRegEx.test(sSelector)&&!/[@#\.]/.test(sSelector))\r
250 {aSelectorData=hSelectorRegEx.exec(sSelector)\r
251 if(aSelectorData[1]!='')\r
252 {hGroup=hParent.getElementsByTagName(aSelectorData[1].toLowerCase())\r
253 for(nI=0;nI<hGroup.length;nI++)\r
254 {hGroup[nI].markExt=true}\r
255 for(nI=0;nI<hGroup.length;nI++)\r
256 {if(!hGroup[nI].markExt)\r
257 {continue}\r
258 else\r
259 {hGroup[nI].markExt=false}\r
260 if(aSelectorData[2]=='')\r
261 {if(hGroup[nI].tagName.toLowerCase()==aSelectorData[1].toLowerCase())\r
262 {hInitFunction(hGroup[nI])}}\r
263 else\r
264 {aAttributeData=hAttributeRegEx.exec(aSelectorData[2])\r
265 if(aAttributeData[1]=='class')\r
266 {sAttribute=hGroup[nI].className}\r
267 else\r
268 {sAttribute=hGroup[nI].getAttribute(aAttributeData[1])}\r
269 if(sAttribute!=null&&sAttribute.length>0)\r
270 {if(aAttributeData[3]=='=')\r
271 {if(aAttributeData[2]=='')\r
272 {if(sAttribute==aAttributeData[4])\r
273 {hInitFunction(hGroup[nI])}}\r
274 else\r
275 {switch(aAttributeData[2])\r
276 {case'^':if(sAttribute.indexOf(aAttributeData[4])==0)\r
277 {hInitFunction(hGroup[nI])}\r
278 break\r
279 case'$':if(sAttribute.lastIndexOf(aAttributeData[4])==sAttribute.length-aAttributeData[4].length)\r
280 {hInitFunction(hGroup[nI])}\r
281 break\r
282 case'*':if(sAttribute.indexOf(aAttributeData[4])>=0)\r
283 {hInitFunction(hGroup[nI])}\r
284 break}}}\r
285 else\r
286 {hInitFunction(hGroup[nI])}}}}\r
287 return}}\r
288 hSelectorRegEx=/([a-z0-9_]*)([\.#@]?)([a-z0-9_=~]*)/i\r
289 hAttributeRegEx=/([a-z0-9_]*)([=~])?([a-z0-9_]*)/i\r
290 aSelectorData=hSelectorRegEx.exec(sSelector)\r
291 if(aSelectorData[1]!='')\r
292 {var hGroup=hParent.getElementsByTagName(aSelectorData[1])\r
293 for(nI=0;nI<hGroup.length;nI++)\r
294 {hGroup[nI].markExt=true}\r
295 for(nI=0;nI<hGroup.length;nI++)\r
296 {if(!hGroup[nI].markExt)\r
297 {continue}\r
298 else\r
299 {hGroup[nI].markExt=false}\r
300 if(aSelectorData[2]!='')\r
301 {switch(aSelectorData[2])\r
302 {case'.':if(hGroup[nI].className==aSelectorData[3])\r
303 {hInitFunction(hGroup[nI])}\r
304 break\r
305 case'#':if(hGroup[nI].id==aSelectorData[3])\r
306 {hInitFunction(hGroup[nI])}\r
307 break\r
308 case'@':aAttributeData=hAttributeRegEx.exec(aSelectorData[3])\r
309 sAttribute=hGroup[nI].getAttribute(aAttributeData[1])\r
310 if(sAttribute!=null&&sAttribute.length>0)\r
311 {if(aAttributeData[3]!='')\r
312 {if(aAttributeData[2]=='=')\r
313 {if(sAttribute==aAttributeData[3])\r
314 {hInitFunction(hGroup[nI])}}\r
315 else\r
316 {if(sAttribute.indexOf(aAttributeData[3])>=0)\r
317 {hInitFunction(hGroup[nI])}}}\r
318 else\r
319 {hInitFunction(hGroup[nI])}}\r
320 break}}}}}\r
321 cDomExtensionManager.initialize=function()\r
322 {var hDomExtension=null\r
323 var aSelectors\r
324 for(var nKey in cDomExtensionManager.aExtensions)\r
325 {aSelectors=cDomExtensionManager.aExtensions[nKey].aSelectors\r
326 for(var nKey2 in aSelectors)\r
327 {cDomExtensionManager.initSelector(cDomExtensionManager.aExtensions[nKey].hParent,aSelectors[nKey2],cDomExtensionManager.aExtensions[nKey].hInitFunction)}}}\r
328 if(window.addEventListener)\r
329 {window.addEventListener('load',cDomExtensionManager.initialize,false)}\r
330 else if(window.attachEvent)\r
331 {window.attachEvent('onload',cDomExtensionManager.initialize)}\r
332 function cDomObject(sId)\r
333 {if(bw.dom||bw.ie)\r
334 {this.hElement=document.getElementById(sId)\r
335 this.hStyle=this.hElement.style}}\r
336 cDomObject.prototype.getWidth=function()\r
337 {return cDomObject.getWidth(this.hElement)}\r
338 cDomObject.getWidth=function(hElement)\r
339 {if(hElement.currentStyle)\r
340 {var nWidth=parseInt(hElement.currentStyle.width)\r
341 if(isNaN(nWidth))\r
342 {return parseInt(hElement.offsetWidth)}\r
343 else\r
344 {return nWidth}}\r
345 else\r
346 {return parseInt(hElement.offsetWidth)}}\r
347 cDomObject.prototype.getHeight=function()\r
348 {return cDomObject.getHeight(this.hElement)}\r
349 cDomObject.getHeight=function(hElement)\r
350 {if(hElement.currentStyle)\r
351 {var nHeight=parseInt(hElement.currentStyle.height)\r
352 if(isNaN(nHeight))\r
353 {return parseInt(hElement.offsetHeight)}\r
354 else\r
355 {return nHeight}}\r
356 else\r
357 {return parseInt(hElement.offsetHeight)}}\r
358 cDomObject.prototype.getLeft=function()\r
359 {return cDomObject.getLeft(this.hElement)}\r
360 cDomObject.getLeft=function(hElement)\r
361 {return parseInt(hElement.offsetLeft)}\r
362 cDomObject.prototype.getTop=function()\r
363 {return cDomObject.getTop(this.hElement)}\r
364 cDomObject.getTop=function(hElement)\r
365 {return parseInt(hElement.offsetTop)}\r
366 cDomObject.getOffsetParam=function(hElement,sParam,hLimitParent)\r
367 {var nRes=0\r
368 if(hLimitParent==null)\r
369 {hLimitParent=document.body.parentElement}\r
370 while(hElement!=hLimitParent)\r
371 {nRes+=eval('hElement.'+sParam)\r
372 if(!hElement.offsetParent){break}\r
373 hElement=hElement.offsetParent}\r
374 return nRes}\r
375 cDomObject.getScrollOffset=function(hElement,sParam,hLimitParent)\r
376 {nRes=0\r
377 if(hLimitParent==null)\r
378 {hLimitParent=document.body.parentElement}\r
379 while(hElement!=hLimitParent)\r
380 {nRes+=eval('hElement.scroll'+sParam)\r
381 if(!hElement.offsetParent){break}\r
382 hElement=hElement.parentNode}\r
383 return nRes}\r
384 function getDomDocumentPrefix(){if(getDomDocumentPrefix.prefix)\r
385 return getDomDocumentPrefix.prefix;var prefixes=["MSXML2","Microsoft","MSXML","MSXML3"];var o;for(var i=0;i<prefixes.length;i++){try{o=new ActiveXObject(prefixes[i]+".DomDocument");return getDomDocumentPrefix.prefix=prefixes[i];}\r
386 catch(ex){};}\r
387 throw new Error("Could not find an installed XML parser");}\r
388 function getXmlHttpPrefix(){if(getXmlHttpPrefix.prefix)\r
389 return getXmlHttpPrefix.prefix;var prefixes=["MSXML2","Microsoft","MSXML","MSXML3"];var o;for(var i=0;i<prefixes.length;i++){try{o=new ActiveXObject(prefixes[i]+".XmlHttp");return getXmlHttpPrefix.prefix=prefixes[i];}\r
390 catch(ex){};}\r
391 throw new Error("Could not find an installed XML parser");}\r
392 function XmlHttp(){}\r
393 XmlHttp.create=function(){try{if(window.XMLHttpRequest){var req=new XMLHttpRequest();if(req.readyState==null){req.readyState=1;req.addEventListener("load",function(){req.readyState=4;if(typeof req.onreadystatechange=="function")\r
394 req.onreadystatechange();},false);}\r
395 return req;}\r
396 if(window.ActiveXObject){return new ActiveXObject(getXmlHttpPrefix()+".XmlHttp");}}\r
397 catch(ex){}\r
398 throw new Error("Your browser does not support XmlHttp objects");};function XmlDocument(){}\r
399 XmlDocument.create=function(){try{if(document.implementation&&document.implementation.createDocument){var doc=document.implementation.createDocument("","",null);if(doc.readyState==null){doc.readyState=1;doc.addEventListener("load",function(){doc.readyState=4;if(typeof doc.onreadystatechange=="function")\r
400 doc.onreadystatechange();},false);}\r
401 return doc;}\r
402 if(window.ActiveXObject)\r
403 return new ActiveXObject(getDomDocumentPrefix()+".DomDocument");}\r
404 catch(ex){}\r
405 throw new Error("Your browser does not support XmlDocument objects");};if(window.DOMParser&&window.XMLSerializer&&window.Node&&Node.prototype&&Node.prototype.__defineGetter__){Document.prototype.loadXML=function(s){var doc2=(new DOMParser()).parseFromString(s,"text/xml");while(this.hasChildNodes())\r
406 this.removeChild(this.lastChild);for(var i=0;i<doc2.childNodes.length;i++){this.appendChild(this.importNode(doc2.childNodes[i],true));}};Document.prototype.__defineGetter__("xml",function(){return(new XMLSerializer()).serializeToString(this);});}\r
407 function cAutocomplete(sInputId)\r
408 {this.init(sInputId)}\r
409 var xmlrpc_url;cAutocomplete.CS_NAME='Autocomplete component'\r
410 cAutocomplete.CS_OBJ_NAME='AC_COMPONENT'\r
411 cAutocomplete.CS_LIST_PREFIX='ACL_'\r
412 cAutocomplete.CS_BUTTON_PREFIX='ACB_'\r
413 cAutocomplete.CS_INPUT_PREFIX='AC_'\r
414 cAutocomplete.CS_HIDDEN_INPUT_PREFIX='ACH_'\r
415 cAutocomplete.CS_INPUT_CLASSNAME='dropdown'\r
416 cAutocomplete.CB_AUTOINIT=true\r
417 cAutocomplete.CB_AUTOCOMPLETE=false\r
418 cAutocomplete.CB_FORCECORRECT=false\r
419 cAutocomplete.CB_MATCHSUBSTRING=false\r
420 cAutocomplete.CS_SEPARATOR=','\r
421 cAutocomplete.CS_ARRAY_SEPARATOR=','\r
422 cAutocomplete.CB_MATCHSTRINGBEGIN=true\r
423 cAutocomplete.CN_OFFSET_TOP=2\r
424 cAutocomplete.CN_OFFSET_LEFT=-1\r
425 cAutocomplete.CN_LINE_HEIGHT=19\r
426 cAutocomplete.CN_NUMBER_OF_LINES=10\r
427 cAutocomplete.CN_HEIGHT_FIX=2\r
428 cAutocomplete.CN_CLEAR_TIMEOUT=300\r
429 cAutocomplete.CN_SHOW_TIMEOUT=400\r
430 cAutocomplete.CN_REMOTE_SHOW_TIMEOUT=1000\r
431 cAutocomplete.CN_MARK_TIMEOUT=400\r
432 cAutocomplete.hListDisplayed=null\r
433 cAutocomplete.nCount=0\r
434 cAutocomplete.autoInit=function()\r
435 {var nI=0\r
436 var hACE=null\r
437 var sLangAtt\r
438 var nInputsLength=document.getElementsByTagName('INPUT').length\r
439 for(nI=0;nI<nInputsLength;nI++)\r
440 {if(document.getElementsByTagName('INPUT')[nI].type.toLowerCase()=='text')\r
441 {sLangAtt=document.getElementsByTagName('INPUT')[nI].getAttribute('acdropdown')\r
442 if(sLangAtt!=null&&sLangAtt.length>0)\r
443 {if(document.getElementsByTagName('INPUT')[nI].id==null||document.getElementsByTagName('INPUT')[nI].id.length==0)\r
444 {document.getElementsByTagName('INPUT')[nI].id=cAutocomplete.CS_OBJ_NAME+cAutocomplete.nCount}\r
445 hACE=new cAutocomplete(document.getElementsByTagName('INPUT')[nI].id)}}}\r
446 var nTALength=document.getElementsByTagName('TEXTAREA').length\r
447 for(nI=0;nI<nTALength;nI++)\r
448 {sLangAtt=document.getElementsByTagName('TEXTAREA')[nI].getAttribute('acdropdown')\r
449 if(sLangAtt!=null&&sLangAtt.length>0)\r
450 {if(document.getElementsByTagName('TEXTAREA')[nI].id==null||document.getElementsByTagName('TEXTAREA')[nI].id.length==0)\r
451 {document.getElementsByTagName('TEXTAREA')[nI].id=cAutocomplete.CS_OBJ_NAME+cAutocomplete.nCount}\r
452 hACE=new cAutocomplete(document.getElementsByTagName('TEXTAREA')[nI].id)}}\r
453 var nSelectsLength=document.getElementsByTagName('SELECT').length\r
454 var aSelect=null\r
455 for(nI=0;nI<nSelectsLength;nI++)\r
456 {aSelect=document.getElementsByTagName('SELECT')[nI]\r
457 sLangAtt=aSelect.getAttribute('acdropdown')\r
458 if(sLangAtt!=null&&sLangAtt.length>0)\r
459 {if(aSelect.id==null||aSelect.id.length==0)\r
460 {aSelect.id=cAutocomplete.CS_OBJ_NAME+cAutocomplete.nCount}\r
461 hACE=new cAutocomplete(aSelect.id)\r
462 nSelectsLength--\r
463 nI--}}}\r
464 if(cAutocomplete.CB_AUTOINIT)\r
465 {if(window.attachEvent)\r
466 {window.attachEvent('onload',cAutocomplete.autoInit)}\r
467 else if(window.addEventListener)\r
468 {window.addEventListener('load',cAutocomplete.autoInit,false)}}\r
469 cAutocomplete.prototype.init=function(sInputId)\r
470 {this.bDebug=false\r
471 this.sInputId=sInputId\r
472 this.sListId=cAutocomplete.CS_LIST_PREFIX+sInputId\r
473 this.sObjName=cAutocomplete.CS_OBJ_NAME+'_obj_'+(cAutocomplete.nCount++)\r
474 this.hObj=this.sObjName\r
475 this.hActiveSelection=null\r
476 this.nSelectedItemIdx=-1\r
477 this.sLastActiveValue=''\r
478 this.sActiveValue=''\r
479 this.bListDisplayed=false\r
480 this.nItemsDisplayed=0\r
481 this.bAssociative=true\r
482 this.sHiddenInputId=null\r
483 this.bHasButton=false\r
484 this.aData=null\r
485 this.aSearchData=new Array()\r
486 this.bSorted=false\r
487 this.nLastMatchLength=0\r
488 this.bForceCorrect=cAutocomplete.CB_FORCECORRECT\r
489 var sForceCorrect=document.getElementById(this.sInputId).getAttribute('autocomplete_forcecorrect')\r
490 if(sForceCorrect!=null&&sForceCorrect.length>0)\r
491 {this.bForceCorrect=eval(sForceCorrect)}\r
492 this.bMatchBegin=cAutocomplete.CB_MATCHSTRINGBEGIN\r
493 var sMatchBegin=document.getElementById(this.sInputId).getAttribute('autocomplete_matchbegin')\r
494 if(sMatchBegin!=null&&sMatchBegin.length>0)\r
495 {this.bMatchBegin=eval(sMatchBegin)}\r
496 this.bMatchSubstring=cAutocomplete.CB_MATCHSUBSTRING\r
497 var sMatchSubstring=document.getElementById(this.sInputId).getAttribute('autocomplete_matchsubstring')\r
498 if(sMatchSubstring!=null&&sMatchSubstring.length>0)\r
499 {this.bMatchSubstring=eval(sMatchSubstring)}\r
500 this.bAutoComplete=cAutocomplete.CB_AUTOCOMPLETE\r
501 this.bAutocompleted=false\r
502 var sAutoComplete=document.getElementById(this.sInputId).getAttribute('autocomplete_complete')\r
503 if(sAutoComplete!=null&&sAutoComplete.length>0)\r
504 {this.bAutoComplete=eval(sAutoComplete)}\r
505 this.formatOptions=null\r
506 var sFormatFunction=document.getElementById(this.sInputId).getAttribute('autocomplete_format')\r
507 if(sFormatFunction!=null&&sFormatFunction.length>0)\r
508 {this.formatOptions=eval(sFormatFunction)}\r
509 this.onSelect=null\r
510 var sOnSelectFunction=document.getElementById(this.sInputId).getAttribute('autocomplete_onselect')\r
511 if(sOnSelectFunction!=null&&sOnSelectFunction.length>0)\r
512 {this.onSelect=eval(sOnSelectFunction)}\r
513 if(this.getListArrayType()=='url'||this.getListArrayType()=='xmlrpc')\r
514 {this.bAssociative=false\r
515 this.bRemoteList=true\r
516 this.sListURL=this.getListURL()\r
517 this.hXMLHttp=XmlHttp.create()\r
518 this.bXMLRPC=(this.getListArrayType()=='xmlrpc')}\r
519 else\r
520 {this.bRemoteList=false}\r
521 var sAssociative=document.getElementById(this.sInputId).getAttribute('autocomplete_assoc')\r
522 if(sAssociative!=null&&sAssociative.length>0)\r
523 {this.bAssociative=eval(sAssociative)}\r
524 this.initListArray()\r
525 this.initListContainer()\r
526 this.initInput()\r
527 eval(this.hObj+'= this')}\r
528 cAutocomplete.prototype.initInput=function()\r
529 {var hInput=document.getElementById(this.sInputId)\r
530 hInput.hAutocomplete=this\r
531 var hContainer=document.getElementById(this.sListId)\r
532 hContainer.hAutocomplete=this\r
533 var nWidth=hInput.offsetWidth\r
534 if(!nWidth||nWidth==0)\r
535 {var hOWInput=hInput.cloneNode(true)\r
536 hOWInput.style.position='absolute'\r
537 hOWInput.style.top='-1000px'\r
538 document.body.appendChild(hOWInput)\r
539 var nWidth=hOWInput.offsetWidth\r
540 document.body.removeChild(hOWInput)}\r
541 var sInputName=hInput.name\r
542 var hForm=hInput.form\r
543 var bHasButton=false\r
544 var sHiddenValue=hInput.value\r
545 var sValue=hInput.type.toLowerCase()=='text'?hInput.value:''\r
546 var sHasButton=hInput.getAttribute('autocomplete_button')\r
547 if(sHasButton!=null&&sHasButton.length>0)\r
548 {bHasButton=true}\r
549 if(hInput.type.toLowerCase()=='select-one')\r
550 {bHasButton=true\r
551 if(hInput.selectedIndex>=0)\r
552 {sHiddenValue=hInput.options[hInput.selectedIndex].value\r
553 sValue=hInput.options[hInput.selectedIndex].text}}\r
554 if(hForm)\r
555 {var hHiddenInput=document.createElement('INPUT')\r
556 hHiddenInput.id=cAutocomplete.CS_HIDDEN_INPUT_PREFIX+this.sInputId\r
557 hHiddenInput.type='hidden'\r
558 hForm.appendChild(hHiddenInput)\r
559 if(this.bAssociative)\r
560 {hHiddenInput.name=sInputName\r
561 hInput.name=cAutocomplete.CS_INPUT_PREFIX+sInputName}\r
562 else\r
563 {hHiddenInput.name=cAutocomplete.CS_INPUT_PREFIX+sInputName}\r
564 hHiddenInput.value=sHiddenValue\r
565 this.sHiddenInputId=hHiddenInput.id}\r
566 if(bHasButton)\r
567 {this.bHasButton=true\r
568 var hInputContainer=document.createElement('DIV')\r
569 hInputContainer.className='acinputContainer'\r
570 hInputContainer.style.width=nWidth\r
571 var hInputButton=document.createElement('INPUT')\r
572 hInputButton.id=cAutocomplete.CS_BUTTON_PREFIX+this.sInputId\r
573 hInputButton.type='button'\r
574 hInputButton.className='button'\r
575 hInputButton.tabIndex=hInput.tabIndex+1\r
576 hInputButton.hAutocomplete=this\r
577 var hNewInput=document.createElement('INPUT')\r
578 if(this.bAssociative)\r
579 {hNewInput.name=cAutocomplete.CS_INPUT_PREFIX+sInputName}\r
580 else\r
581 {hNewInput.name=sInputName}\r
582 hNewInput.type='text'\r
583 hNewInput.value=sValue\r
584 hNewInput.style.width=nWidth-22\r
585 hNewInput.className=cAutocomplete.CS_INPUT_CLASSNAME\r
586 hNewInput.tabIndex=hInput.tabIndex\r
587 hNewInput.hAutocomplete=this\r
588 hInputContainer.appendChild(hNewInput)\r
589 hInputContainer.appendChild(hInputButton)\r
590 hInput.parentNode.replaceChild(hInputContainer,hInput)\r
591 hNewInput.id=this.sInputId\r
592 hInput=hNewInput}\r
593 if(hInput.attachEvent)\r
594 {hInput.attachEvent('onkeyup',cAutocomplete.onInputKeyUp)\r
595 hInput.attachEvent('onkeyup',cAutocomplete.saveCaretPosition)\r
596 hInput.attachEvent('onkeydown',cAutocomplete.onInputKeyDown)\r
597 hInput.attachEvent('onblur',cAutocomplete.onInputBlur)\r
598 hInput.attachEvent('onfocus',cAutocomplete.onInputFocus)\r
599 if(hInputButton)\r
600 {hInputButton.attachEvent('onclick',cAutocomplete.onButtonClick)}}\r
601 else if(hInput.addEventListener)\r
602 {hInput.addEventListener('keyup',cAutocomplete.onInputKeyUp,false)\r
603 hInput.addEventListener('keyup',cAutocomplete.saveCaretPosition,false)\r
604 hInput.addEventListener('keydown',cAutocomplete.onInputKeyDown,false)\r
605 hInput.addEventListener('keypress',cAutocomplete.onInputKeyPress,false)\r
606 hInput.addEventListener('blur',cAutocomplete.onInputBlur,false)\r
607 hInput.addEventListener('focus',cAutocomplete.onInputFocus,false)\r
608 if(hInputButton)\r
609 {hInputButton.addEventListener('click',cAutocomplete.onButtonClick,false)}}\r
610 hInput.setAttribute('autocomplete','OFF')\r
611 if(hForm)\r
612 {if(hForm.attachEvent)\r
613 {hForm.attachEvent('onsubmit',cAutocomplete.onFormSubmit)\r
614 if(this.bDebug){this.debug("attachEvent added")}}\r
615 else if(hForm.addEventListener)\r
616 {hForm.addEventListener('submit',cAutocomplete.onFormSubmit,false)\r
617 if(this.bDebug){this.debug("addEventListener")}}}}\r
618 cAutocomplete.prototype.initListContainer=function()\r
619 {var hInput=document.getElementById(this.sInputId)\r
620 var hContainer=document.createElement('DIV')\r
621 hContainer.className='autocomplete_holder'\r
622 hContainer.id=this.sListId\r
623 hContainer.style.zIndex=10000+cAutocomplete.nCount\r
624 hContainer.hAutocomplete=this\r
625 var hFirstBorder=document.createElement('DIV')\r
626 hFirstBorder.className='autocomplete_firstborder'\r
627 var hSecondBorder=document.createElement('DIV')\r
628 hSecondBorder.className='autocomplete_secondborder'\r
629 var hList=document.createElement('UL')\r
630 hList.className='autocomplete'\r
631 hSecondBorder.appendChild(hList)\r
632 hFirstBorder.appendChild(hSecondBorder)\r
633 hContainer.appendChild(hFirstBorder)\r
634 document.body.appendChild(hContainer)\r
635 if(hContainer.attachEvent)\r
636 {hContainer.attachEvent('onblur',cAutocomplete.onListBlur)\r
637 hContainer.attachEvent('onfocus',cAutocomplete.onListFocus)}\r
638 else if(hInput.addEventListener)\r
639 {hContainer.addEventListener('blur',cAutocomplete.onListBlur,false)\r
640 hContainer.addEventListener('focus',cAutocomplete.onListFocus,false)}\r
641 if(hContainer.attachEvent)\r
642 {hContainer.attachEvent('onclick',cAutocomplete.onItemClick)}\r
643 else if(hContainer.addEventListener)\r
644 {hContainer.addEventListener('click',cAutocomplete.onItemClick,false)}}\r
645 cAutocomplete.prototype.createList=function()\r
646 {var hInput=document.getElementById(this.sInputId)\r
647 var hContainer=document.getElementById(this.sListId)\r
648 var hList=hContainer.getElementsByTagName('UL')[0]\r
649 if(hList)\r
650 {hList=hList.parentNode.removeChild(hList)\r
651 while(hList.hasChildNodes())\r
652 {hList.removeChild(hList.childNodes[0])}}\r
653 var hListItem=null\r
654 var hListItemLink=null\r
655 var hArrKey=null\r
656 var sArrEl=null\r
657 var hArr=this.aData\r
658 var nI=0\r
659 var sRealText\r
660 for(hArrKey in hArr)\r
661 {sArrEl=hArr[hArrKey]\r
662 hListItem=document.createElement('LI')\r
663 hListItemLink=document.createElement('A')\r
664 hListItemLink.setAttribute('itemvalue',hArrKey)\r
665 var sArrData=sArrEl.split(cAutocomplete.CS_ARRAY_SEPARATOR)\r
666 if(sArrData.length>1)\r
667 {this.aData[hArrKey]=sArrData[0]\r
668 hListItemLink.setAttribute('itemdata',sArrEl.substring(sArrEl.indexOf(cAutocomplete.CS_ARRAY_SEPARATOR)+1))\r
669 sRealText=sArrData[0]}\r
670 else\r
671 {sRealText=sArrEl}\r
672 hListItemLink.href='#'\r
673 hListItemLink.appendChild(document.createTextNode(sRealText))\r
674 hListItemLink.realText=sRealText\r
675 if(nI==this.nSelectedItemIdx)\r
676 {this.hActiveSelection=hListItemLink\r
677 this.hActiveSelection.className='selected'}\r
678 hListItem.appendChild(hListItemLink)\r
679 hList.appendChild(hListItem)\r
680 this.aSearchData[nI++]=sRealText.toLowerCase()}\r
681 var hSecondBorder=hContainer.firstChild.firstChild\r
682 hSecondBorder.appendChild(hList)\r
683 this.bListUpdated=false}\r
684 cAutocomplete.prototype.initListArray=function()\r
685 {var hInput=document.getElementById(this.sInputId)\r
686 var hArr=null\r
687 if(hInput.type.toLowerCase()=='select-one')\r
688 {hArr=new Object()\r
689 for(var nI=0;nI<hInput.options.length;nI++)\r
690 {hArrKey=hInput.options.item(nI).value\r
691 sArrEl=hInput.options.item(nI).text\r
692 hArr[hArrKey]=sArrEl\r
693 if(hInput.options.item(nI).selected)\r
694 {this.nSelectedItemIdx=nI}}}\r
695 else\r
696 {var sAA=hInput.getAttribute('autocomplete_list')\r
697 var sAAS=hInput.getAttribute('autocomplete_list_sort')\r
698 var sArrayType=this.getListArrayType()\r
699 switch(sArrayType)\r
700 {case'array':hArr=eval(sAA.substring(6))\r
701 break\r
702 case'list':hArr=new Array()\r
703 var hTmpArray=sAA.substring(5).split('|')\r
704 var aValueArr\r
705 for(hKey in hTmpArray)\r
706 {aValueArr=hTmpArray[hKey].split(cAutocomplete.CS_ARRAY_SEPARATOR)\r
707 if(aValueArr.length==1)\r
708 {hArr[hKey]=hTmpArray[hKey]\r
709 this.bAssociative=false}\r
710 else\r
711 {hArr[aValueArr[0]]=aValueArr[1]}}\r
712 break}\r
713 if(sAAS!=null&&eval(sAAS))\r
714 {this.bSorted=true\r
715 this.aData=hArr.sort()\r
716 hArr=hArr.sort()}}\r
717 this.setArray(hArr)}\r
718 cAutocomplete.prototype.setArray=function(sArray)\r
719 {if(typeof sArray=='string')\r
720 {this.aData=eval(sArray)}\r
721 else\r
722 {this.aData=sArray}\r
723 this.bListUpdated=true}\r
724 cAutocomplete.prototype.setListArray=function(sArray)\r
725 {this.setArray(sArray)\r
726 this.updateAndShowList()}\r
727 cAutocomplete.prototype.getListArrayType=function()\r
728 {var hInput=document.getElementById(this.sInputId)\r
729 var sAA=hInput.getAttribute('autocomplete_list')\r
730 if(sAA!=null&&sAA.length>0)\r
731 {if(sAA.indexOf('array:')>=0)\r
732 {return'array'}\r
733 else if(sAA.indexOf('list:')>=0)\r
734 {return'list'}\r
735 else if(sAA.indexOf('url:')>=0)\r
736 {return'url'}\r
737 else if(sAA.indexOf('xmlrpc:')>=0)\r
738 {return'xmlrpc'}}}\r
739 cAutocomplete.prototype.getListURL=function()\r
740 {var hInput=document.getElementById(this.sInputId)\r
741 var sAA=hInput.getAttribute('autocomplete_list')\r
742 if(sAA!=null&&sAA.length>0)\r
743 {if(sAA.indexOf('url:')>=0)\r
744 {return sAA.substring(4)}\r
745 if(sAA.indexOf('xmlrpc:')>=0)\r
746 {return sAA.substring(7)}}}\r
747 cAutocomplete.prototype.setListURL=function(sURL)\r
748 {this.sListURL=sURL;}\r
749 cAutocomplete.prototype.onXmlHttpLoad=function()\r
750 {if(this.hXMLHttp.readyState==4)\r
751 {var hError=this.hXMLHttp.parseError\r
752 if(hError&&hError.errorCode!=0)\r
753 {alert(hError.reason)}\r
754 else\r
755 {this.afterRemoteLoad()}}}\r
756 cAutocomplete.prototype.onXMLRPCHttpLoad=function()\r
757 {if(this.hXMLHttp.readyState==4)\r
758 {var hError=this.hXMLHttp.parseError\r
759 if(hError&&hError.errorCode!=0)\r
760 {alert(hError.reason)}\r
761 else\r
762 {this.afterRemoteLoadXMLRPC()}}}\r
763 cAutocomplete.prototype.loadXMLRPCListArray=function()\r
764 {var sURL=this.sListURL\r
765 var xmlrpc_url=data_path+'/RPC2.php'\r
766 var aMethodArgs=sURL.split(' ')\r
767 var sMethodName=aMethodArgs[0]\r
768 var sStartWith=this.getStringForAutocompletion(this.sActiveValue,this.nInsertPoint)\r
769 sStartWith=sStartWith.replace(/^\s/,'')\r
770 sStartWith=sStartWith.replace(/\s$/,'')\r
771 if(sMethodName.indexOf('?')>0)\r
772 {sMethodName=sMethodName.replace('/^.+\?/','')\r
773 sURL=sURL.replace('/\?.+$/','')}\r
774 else\r
775 {sURL=xmlrpc_url}\r
776 if(sMethodName.length<1)\r
777 {var hInput=document.getElementById(this.sInputId)\r
778 hInput.value=this.sActiveValue\r
779 return}\r
780 var sRequest='<?xml version=\'1.0\' encoding="utf-8" ?>\n'\r
781 sRequest+='<methodCall><methodName>'+sMethodName+'</methodName>\n'\r
782 if(aMethodArgs.length<=1)\r
783 {sRequest+='<params/>\n'}\r
784 else\r
785 {sRequest+='<params>\n'\r
786 for(var nI=1;nI<aMethodArgs.length;nI++)\r
787 {var sArg=aMethodArgs[nI];if(sArg.indexOf('[S]')>=0)\r
788 {sArg=sArg.replace('[S]',sStartWith)}\r
789 sRequest+='<param><value><string>'\r
790 sRequest+=sArg\r
791 sRequest+='</string></value></param>\n'}\r
792 sRequest+='</params>\n'}\r
793 sRequest+='</methodCall>'\r
794 if(this.bDebug){this.debug('url: "'+sURL+'" sRequest: "'+sRequest.substring(20)+'"')}\r
795 this.hXMLHttp.open('POST',sURL,true)\r
796 var hAC=this\r
797 this.hXMLHttp.onreadystatechange=function(){hAC.onXMLRPCHttpLoad()}\r
798 this.hXMLHttp.send(sRequest)}\r
799 cAutocomplete.prototype.loadListArray=function()\r
800 {var sURL=this.sListURL\r
801 var sStartWith=this.getStringForAutocompletion(this.sActiveValue,this.nInsertPoint)\r
802 sStartWith=sStartWith.replace(/^\s/,'')\r
803 sStartWith=sStartWith.replace(/\s$/,'')\r
804 if(sURL.indexOf('[S]')>=0)\r
805 {sURL=sURL.replace('[S]',sStartWith)}\r
806 else\r
807 {sURL+=this.sActiveValue}\r
808 this.hXMLHttp.open('GET',sURL,true)\r
809 var hAC=this\r
810 this.hXMLHttp.onreadystatechange=function(){hAC.onXmlHttpLoad()}\r
811 this.hXMLHttp.send(null)}\r
812 cAutocomplete.prototype.afterRemoteLoad=function()\r
813 {var hInput=document.getElementById(this.sInputId)\r
814 var hArr=new Array()\r
815 var hTmpArray=this.hXMLHttp.responseText.split('|')\r
816 var aValueArr\r
817 for(hKey in hTmpArray)\r
818 {aValueArr=hTmpArray[hKey].split(cAutocomplete.CS_ARRAY_SEPARATOR)\r
819 if(aValueArr.length==1)\r
820 {hArr[hKey]=hTmpArray[hKey]}\r
821 else\r
822 {hArr[aValueArr[0]]=hTmpArray[hKey].substr(hTmpArray[hKey].indexOf(cAutocomplete.CS_ARRAY_SEPARATOR)+1)}}\r
823 hInput.className=''\r
824 hInput.readonly=false\r
825 hInput.value=this.sActiveValue\r
826 this.setListArray(hArr)}\r
827 cAutocomplete.prototype.afterRemoteLoadXMLRPC=function()\r
828 {var hInput=document.getElementById(this.sInputId)\r
829 var hArr=new Array()\r
830 sResult=this.hXMLHttp.responseText\r
831 if(this.bDebug){this.debug("response: "+sResult.substring(70,190))}\r
832 sResult.replace('\n','');sResult.replace('\r','');var hKey=0\r
833 var i=sResult.indexOf('<string>')\r
834 while(i>=0){var j\r
835 sResult=sResult.substring(i+8)\r
836 j=sResult.indexOf('</string>')\r
837 hArr[hKey]=sResult.substring(0,j)\r
838 hKey+=1\r
839 sResult=sResult.substring(j+9)\r
840 i=sResult.indexOf('<string>')}\r
841 hInput.className=''\r
842 hInput.readonly=false\r
843 hInput.value=this.sActiveValue\r
844 this.setListArray(hArr)}\r
845 cAutocomplete.prototype.prepareList=function(bFullList)\r
846 {var hInput=document.getElementById(this.sInputId)\r
847 this.sActiveValue=hInput.value\r
848 var sST=this.getStringForAutocompletion(this.sActiveValue,this.nInsertPoint)\r
849 var sLST=this.getStringForAutocompletion(this.sLastActiveValue,this.nInsertPoint)\r
850 if(sLST!=sST||bFullList||!this.bListDisplayed||this.bMatchSubstring)\r
851 {if(this.bRemoteList)\r
852 {hInput.className='search'\r
853 this.bXMLRPC?this.loadXMLRPCListArray():this.loadListArray()\r
854 return}\r
855 this.updateAndShowList(bFullList)}}\r
856 cAutocomplete.prototype.updateAndShowList=function(bFullList)\r
857 {var hContainer=document.getElementById(this.sListId)\r
858 var hList=hContainer.getElementsByTagName('UL')[0]\r
859 var hInput=document.getElementById(this.sInputId)\r
860 if(this.bListUpdated)\r
861 {this.createList()}\r
862 var sST=this.bMatchSubstring?this.getStringForAutocompletion(this.sActiveValue,this.nInsertPoint):this.sActiveValue\r
863 var sLST=this.bMatchSubstring?this.getStringForAutocompletion(this.sLastActiveValue,this.nInsertPoint):this.sLastActiveValue\r
864 if(sST==sLST)\r
865 {if(!this.bMatchSubstring)\r
866 {bFullList=true}}\r
867 this.filterOptions(bFullList)\r
868 if(this.nItemsDisplayed==0)\r
869 {if(this.bForceCorrect)\r
870 {var aPos=this.getInsertPos(this.sActiveValue,this.nInsertPoint,'')\r
871 cAutocomplete.markInputRange(hInput,this.nLastMatchLength,aPos[0])}}\r
872 this.sLastActiveValue=this.sActiveValue\r
873 if(this.nItemsDisplayed>0)\r
874 {if(!bFullList||this.bMatchSubstring)\r
875 {this.deselectOption()}\r
876 if(this.bAutoComplete&&this.nItemsDisplayed==1)\r
877 {var sStartWith=this.getStringForAutocompletion(this.sActiveValue,this.nInsertPoint)\r
878 var sItemText=hList.getElementsByTagName('LI')[this.nFirstDisplayed].getElementsByTagName('A')[0].realText\r
879 if(sStartWith.toLowerCase()==sItemText.toLowerCase())\r
880 {this.selectOption(hList.getElementsByTagName('LI')[this.nFirstDisplayed].getElementsByTagName('A')[0])\r
881 this.hideOptions()\r
882 return}}\r
883 if(this.bAutoComplete&&!bFullList)\r
884 {this.selectOption(hList.getElementsByTagName('LI')[this.nFirstDisplayed].getElementsByTagName('A')[0])}\r
885 this.showList()}\r
886 else\r
887 {this.clearList()}}\r
888 cAutocomplete.prototype.showList=function()\r
889 {if(cAutocomplete.hListDisplayed)\r
890 {cAutocomplete.hListDisplayed.clearList()}\r
891 var hInput=document.getElementById(this.sInputId)\r
892 var nTop=cDomObject.getOffsetParam(hInput,'offsetTop')\r
893 var nLeft=cDomObject.getOffsetParam(hInput,'offsetLeft')\r
894 var hContainer=document.getElementById(this.sListId)\r
895 var hList=hContainer.getElementsByTagName('UL')[0]\r
896 if(this.bHasButton)\r
897 {hContainer.style.width=document.getElementById(this.sInputId).parentNode.offsetWidth}\r
898 else\r
899 {hContainer.style.width=document.getElementById(this.sInputId).offsetWidth}\r
900 var nNumLines=(this.nItemsDisplayed<cAutocomplete.CN_NUMBER_OF_LINES)?this.nItemsDisplayed:cAutocomplete.CN_NUMBER_OF_LINES;hList.style.height=nNumLines*cAutocomplete.CN_LINE_HEIGHT+cAutocomplete.CN_HEIGHT_FIX+'px'\r
901 hContainer.style.top=nTop+hInput.offsetHeight+cAutocomplete.CN_OFFSET_TOP+'px'\r
902 hContainer.style.left=nLeft+cAutocomplete.CN_OFFSET_LEFT+'px'\r
903 hContainer.style.display='none'\r
904 hContainer.style.visibility='visible'\r
905 hContainer.style.display='block'\r
906 cAutocomplete.hListDisplayed=this\r
907 this.bListDisplayed=true}\r
908 cAutocomplete.prototype.binarySearch=function(sFilter)\r
909 {var nLow=0\r
910 var nHigh=this.aSearchData.length-1\r
911 var nMid\r
912 var nTry,nLastTry\r
913 var sData\r
914 var nLen=sFilter.length\r
915 var lastTry\r
916 while(nLow<=nHigh)\r
917 {nMid=(nLow+nHigh)/2\r
918 nTry=(nMid<1)?0:parseInt(nMid)\r
919 sData=this.aSearchData[nTry].substr(0,nLen)\r
920 if(sData<sFilter)\r
921 {nLow=nTry+1\r
922 continue}\r
923 if(sData>sFilter)\r
924 {nHigh=nTry-1\r
925 continue}\r
926 if(sData==sFilter)\r
927 {nHigh=nTry-1\r
928 nLastTry=nTry\r
929 continue}\r
930 return nTry}\r
931 if(typeof(nLastTry)!="undefined")\r
932 {return nLastTry}\r
933 else\r
934 {return null}}\r
935 cAutocomplete.prototype.getStringForAutocompletion=function(sString,nPos)\r
936 {if(sString==null||sString.length==0)\r
937 {return''}\r
938 if(this.bMatchSubstring)\r
939 {var nStartPos=sString.lastIndexOf(cAutocomplete.CS_SEPARATOR,nPos-1)\r
940 nStartPos=nStartPos<0?0:nStartPos\r
941 var nEndPos=sString.indexOf(cAutocomplete.CS_SEPARATOR,nPos)\r
942 nEndPos=nEndPos<0?sString.length:nEndPos\r
943 var sStr=sString.substr(nStartPos,nEndPos-nStartPos)\r
944 sStr=sStr.replace(/^(\,?)(\s*)(\S*)(\s*)(\,?)$/g,'$3')\r
945 return sStr}\r
946 else\r
947 {return sString}}\r
948 cAutocomplete.prototype.insertString=function(sString,nPos,sInsert)\r
949 {if(this.bMatchSubstring)\r
950 {var nStartPos=sString.lastIndexOf(cAutocomplete.CS_SEPARATOR,nPos-1)\r
951 nStartPos=nStartPos<0?0:nStartPos\r
952 var nEndPos=sString.indexOf(cAutocomplete.CS_SEPARATOR,nPos)\r
953 nEndPos=nEndPos<0?sString.length:nEndPos\r
954 var sStr=sString.substr(nStartPos,nEndPos-nStartPos)\r
955 sStr=sStr.replace(/^(\,?)(\s*)(\S?[\S\s]*\S?)(\s*)(\,?)$/g,'$1$2'+sInsert+'$4$5')\r
956 sStr=sString.substr(0,nStartPos)+sStr+sString.substr(nEndPos)\r
957 return sStr}\r
958 else\r
959 {return sInsert}}\r
960 cAutocomplete.prototype.getInsertPos=function(sString,nPos,sInsert)\r
961 {nPos=nPos==null?0:nPos\r
962 var nStartPos=sString.lastIndexOf(cAutocomplete.CS_SEPARATOR,nPos-1)\r
963 nStartPos=nStartPos<0?0:nStartPos\r
964 var nEndPos=sString.indexOf(cAutocomplete.CS_SEPARATOR,nPos)\r
965 nEndPos=nEndPos<0?sString.length:nEndPos\r
966 var sStr=sString.substr(nStartPos,nEndPos-nStartPos)\r
967 sStr=sStr.replace(/^(\,?)(\s*)(\S?[\S\s]*\S?)(\s*)(\,?)$/g,'$1$2'+sInsert)\r
968 return[nPos,nStartPos+sStr.length]}\r
969 cAutocomplete.prototype.filterOptions=function(bShowAll)\r
970 {if(this.hActiveSelection&&!bShowAll)\r
971 {this.hActiveSelection.className=''}\r
972 if(typeof bShowAll=='undefined')\r
973 {bShowAll=false}\r
974 var hInput=document.getElementById(this.sInputId)\r
975 var sStartWith=this.getStringForAutocompletion(this.sActiveValue,this.nInsertPoint)\r
976 if(bShowAll)\r
977 {sStartWith=''}\r
978 var hContainer=document.getElementById(this.sListId)\r
979 var hList=hContainer.getElementsByTagName('UL')[0]\r
980 var nItemsLength=hList.childNodes.length\r
981 var hLinkItem=null\r
982 var nCount=0\r
983 var hParent=hList.parentNode\r
984 var hList=hList.parentNode.removeChild(hList)\r
985 var hTItems=hList.childNodes\r
986 this.nItemsDisplayed=0\r
987 if(sStartWith.length==0)\r
988 {for(var nI=0;nI<nItemsLength;nI++)\r
989 {if(this.formatOptions)\r
990 {hTItems[nI].childNodes[0].innerHTML=this.formatOptions(hTItems[nI].childNodes[0].realText,nI)}\r
991 hTItems[nI].style.display='block'}\r
992 nCount=nItemsLength\r
993 if(nItemsLength>0)\r
994 {this.nFirstDisplayed=0\r
995 this.nLastDisplayed=nItemsLength-1}\r
996 else\r
997 {this.nFirstDisplayed=this.nLastDisplayed=-1}\r
998 var aPos=this.getInsertPos(this.sActiveValue,this.nInsertPoint,sStartWith)\r
999 this.nLastMatchLength=aPos[0]}\r
1000 else\r
1001 {this.nFirstDisplayed=this.nLastDisplayed=-1\r
1002 sStartWith=sStartWith.toLowerCase()\r
1003 var bEnd=false\r
1004 if(this.bSorted&&this.bMatchBegin)\r
1005 {var nStartAt=this.binarySearch(sStartWith)\r
1006 for(var nI=0;nI<nItemsLength;nI++)\r
1007 {hTItems[nI].style.display='none'\r
1008 if(nI>=nStartAt&&!bEnd)\r
1009 {if(!bEnd&&this.aSearchData[nI].indexOf(sStartWith)!=0)\r
1010 {bEnd=true\r
1011 continue}\r
1012 if(this.formatOptions)\r
1013 {hTItems[nI].childNodes[0].innerHTML=this.formatOptions(hTItems[nI].childNodes[0].realText,nI)}\r
1014 hTItems[nI].style.display='block'\r
1015 nCount++\r
1016 if(this.nFirstDisplayed<0)\r
1017 {this.nFirstDisplayed=nI}\r
1018 this.nLastDisplayed=nI}}}\r
1019 else\r
1020 {for(var nI=0;nI<nItemsLength;nI++)\r
1021 {hTItems[nI].style.display='none'\r
1022 if((this.bMatchBegin&&this.aSearchData[nI].indexOf(sStartWith)==0)||(!this.bMatchBegin&&this.aSearchData[nI].indexOf(sStartWith)>=0))\r
1023 {if(this.formatOptions)\r
1024 {hTItems[nI].childNodes[0].innerHTML=this.formatOptions(hTItems[nI].childNodes[0].realText,nI)}\r
1025 hTItems[nI].style.display='block'\r
1026 nCount++\r
1027 if(this.nFirstDisplayed<0)\r
1028 {this.nFirstDisplayed=nI}\r
1029 this.nLastDisplayed=nI}}}\r
1030 if(nCount>0)\r
1031 {var aPos=this.getInsertPos(this.sActiveValue,this.nInsertPoint,sStartWith)\r
1032 this.nLastMatchLength=aPos[0]}}\r
1033 hParent.appendChild(hList)\r
1034 this.nItemsDisplayed=nCount}\r
1035 cAutocomplete.prototype.hideOptions=function()\r
1036 {var hContainer=document.getElementById(this.sListId)\r
1037 hContainer.style.visibility='hidden'\r
1038 hContainer.style.display='none'\r
1039 this.hListDisplayed=null}\r
1040 cAutocomplete.prototype.markAutocompletedValue=function()\r
1041 {var hInput=document.getElementById(this.sInputId)\r
1042 var sValue=this.hActiveSelection.realText\r
1043 if(this.bMatchSubstring)\r
1044 {var aPos=this.getInsertPos(this.sLastActiveValue,this.nInsertPoint,sValue)\r
1045 var nStartPos=aPos[0]\r
1046 var nEndPos=aPos[1]}\r
1047 else\r
1048 {var nStartPos=this.nInsertPoint\r
1049 var nEndPos=sValue.length}\r
1050 this.nStartAC=nStartPos\r
1051 this.nEndAC=nEndPos\r
1052 if(this.hMarkRangeTimeout!=null)\r
1053 {clearTimeout(this.hMarkRangeTimeout)}\r
1054 this.hMarkRangeTimeout=setTimeout(function(){cAutocomplete.markInputRange2(hInput.id)},cAutocomplete.CN_MARK_TIMEOUT)}\r
1055 cAutocomplete.prototype.selectOptionByIndex=function(nOptionIndex)\r
1056 {if(this.bListUpdated)\r
1057 {this.createList()}\r
1058 var hContainer=document.getElementById(this.sListId)\r
1059 var hList=hContainer.getElementsByTagName('UL')[0]\r
1060 var nItemsLength=hList.childNodes.length\r
1061 if(nOptionIndex>=0&&nOptionIndex<nItemsLength)\r
1062 {this.selectOption(hList.childNodes[nOptionIndex].getElementsByTagName('A')[0])}}\r
1063 cAutocomplete.prototype.selectOptionByValue=function(sValue)\r
1064 {if(this.bListUpdated)\r
1065 {this.createList()}\r
1066 sValue=sValue.toLowerCase()\r
1067 var hContainer=document.getElementById(this.sListId)\r
1068 var hList=hContainer.getElementsByTagName('UL')[0]\r
1069 var nItemsLength=hList.childNodes.length\r
1070 var nSelectedIndex=-1\r
1071 for(var nI=0;nI<nItemsLength;nI++)\r
1072 {if(this.aSearchData[nI].indexOf(sValue)==0)\r
1073 {nSelectedIndex=nI}}\r
1074 if(nSelectedIndex>=0)\r
1075 {this.selectOption(hList.childNodes[nSelectedIndex].getElementsByTagName('A')[0])}}\r
1076 cAutocomplete.prototype.selectOption=function(hNewOption)\r
1077 {if(this.hActiveSelection)\r
1078 {if(this.hActiveSelection==hNewOption)\r
1079 {return}\r
1080 else\r
1081 {this.hActiveSelection.className=''}}\r
1082 this.hActiveSelection=hNewOption\r
1083 var hInput=document.getElementById(this.sInputId)\r
1084 if(this.hActiveSelection!=null)\r
1085 {if(this.sHiddenInputId!=null)\r
1086 {if(this.bMatchSubstring)\r
1087 {document.getElementById(this.sHiddenInputId).value=this.hActiveSelection.getAttribute('itemvalue')}\r
1088 else\r
1089 {document.getElementById(this.sHiddenInputId).value=this.hActiveSelection.getAttribute('itemvalue')}}\r
1090 this.hActiveSelection.className='selected'\r
1091 if(this.bAutoComplete)\r
1092 {hInput.value=this.insertString(this.sLastActiveValue,this.nInsertPoint,this.hActiveSelection.realText)\r
1093 this.bAutocompleted=true\r
1094 this.markAutocompletedValue()}\r
1095 else\r
1096 {var aPos=this.getInsertPos(this.sLastActiveValue,this.nInsertPoint,this.hActiveSelection.realText)\r
1097 hInput.value=this.insertString(this.sActiveValue,this.nInsertPoint,this.hActiveSelection.realText)\r
1098 cAutocomplete.setInputCaretPosition(hInput,aPos[1])}\r
1099 this.sActiveValue=hInput.value\r
1100 if(this.onSelect)\r
1101 {this.onSelect()}}\r
1102 else\r
1103 {hInput.value=this.sActiveValue\r
1104 cAutocomplete.setInputCaretPosition(hInput,this.nInsertPoint)}}\r
1105 cAutocomplete.prototype.deselectOption=function()\r
1106 {if(this.hActiveSelection!=null)\r
1107 {this.hActiveSelection.className=''\r
1108 this.hActiveSelection=null}}\r
1109 cAutocomplete.prototype.clearList=function()\r
1110 {this.hideOptions()\r
1111 this.bListDisplayed=false}\r
1112 cAutocomplete.prototype.getPrevDisplayedItem=function(hItem)\r
1113 {if(hItem==null)\r
1114 {var hContainer=document.getElementById(this.sListId)\r
1115 hItem=hContainer.getElementsByTagName('UL')[0].childNodes.item(hContainer.getElementsByTagName('UL')[0].childNodes.length-1)}\r
1116 else\r
1117 {hItem=getPrevNodeSibling(hItem.parentNode)}\r
1118 while(hItem!=null)\r
1119 {if(hItem.style.display=='block')\r
1120 {return hItem}\r
1121 hItem=hItem.previousSibling}\r
1122 return null}\r
1123 cAutocomplete.prototype.getNextDisplayedItem=function(hItem)\r
1124 {if(hItem==null)\r
1125 {var hContainer=document.getElementById(this.sListId)\r
1126 hItem=hContainer.getElementsByTagName('UL')[0].childNodes.item(0)}\r
1127 else\r
1128 {hItem=getNextNodeSibling(hItem.parentNode)}\r
1129 while(hItem!=null)\r
1130 {if(hItem.style.display=='block')\r
1131 {return hItem}\r
1132 hItem=hItem.nextSibling}\r
1133 return null}\r
1134 cAutocomplete.prototype.debug=function(s)\r
1135 {if(this.bDebug){var hInput=document.getElementById(this.sInputId)\r
1136 var hContainer=document.createElement('DIV')\r
1137 hContainer.className='debug'\r
1138 hContainer.innerHTML=s\r
1139 hInput.form.appendChild(hContainer)}}\r
1140 cAutocomplete.onInputKeyDown=function(hEvent)\r
1141 {if(hEvent==null)\r
1142 {hEvent=window.event}\r
1143 var hElement=(hEvent.srcElement)?hEvent.srcElement:hEvent.originalTarget\r
1144 var hAC=hElement.hAutocomplete\r
1145 var hContainer=document.getElementById(hAC.sListId)\r
1146 var hInput=document.getElementById(hAC.sInputId)\r
1147 var hList=hContainer.getElementsByTagName('UL')[0]\r
1148 var hEl=getParentByTagName(hElement,'A')\r
1149 if(hContainer!=null&&hAC.bListDisplayed)\r
1150 {var hLI=null\r
1151 var hLINext=null\r
1152 if((hEvent.keyCode==13)||(hEvent.keyCode==27))\r
1153 {var bItemSelected=hEvent.keyCode==13?true:false\r
1154 hAC.clearList()\r
1155 if(hAC.bDebug){hAC.debug("key "+hEvent.keyCode+" new active selection")}}\r
1156 if(hEvent.keyCode==38)\r
1157 {if(hAC.bDebug){hAC.debug("key "+hEvent.keyCode+" up")}\r
1158 hLINext=hAC.getPrevDisplayedItem(hAC.hActiveSelection)\r
1159 if(hLINext!=null)\r
1160 {hAC.selectOption(hLINext.childNodes.item(0))\r
1161 if(hAC.nItemsDisplayed>cAutocomplete.CN_NUMBER_OF_LINES)\r
1162 {if(hList.scrollTop<5&&hLINext.offsetTop>hList.offsetHeight)\r
1163 {hList.scrollTop=hList.scrollHeight-hList.offsetHeight}\r
1164 if(hLINext.offsetTop-hList.scrollTop<0)\r
1165 {hList.scrollTop-=hLINext.offsetHeight}}}\r
1166 else\r
1167 {hAC.selectOption(null)}}\r
1168 else if(hEvent.keyCode==40)\r
1169 {if(hAC.bDebug){hAC.debug("key "+hEvent.keyCode+" down")}\r
1170 hLINext=hAC.getNextDisplayedItem(hAC.hActiveSelection)\r
1171 if(hLINext!=null)\r
1172 {hAC.selectOption(hLINext.childNodes.item(0))\r
1173 if(hAC.nItemsDisplayed>cAutocomplete.CN_NUMBER_OF_LINES)\r
1174 {if(hList.scrollTop>0&&hList.scrollTop>hLINext.offsetTop)\r
1175 {hList.scrollTop=0}\r
1176 if(Math.abs(hLINext.offsetTop-hList.scrollTop-hList.offsetHeight)<5)\r
1177 {hList.scrollTop+=hLINext.offsetHeight}}}\r
1178 else\r
1179 {hAC.selectOption(null)}}}\r
1180 if(hInput.form)\r
1181 {hInput.form.bLocked=true\r
1182 if(hAC.bDebug){hAC.debug("onInputKeyDown form blocked")}}\r
1183 if(hEvent.keyCode==13||hEvent.keyCode==27||hEvent.keyCode==38||hEvent.keyCode==40)\r
1184 {if(hEvent.preventDefault)\r
1185 {hEvent.preventDefault()}else{if(hAC.bDebug){hAC.debug("no preventDefault return false")}}\r
1186 hEvent.cancelBubble=true\r
1187 hEvent.returnValue=false\r
1188 return false}}\r
1189 cAutocomplete.onInputKeyPress=function(hEvent)\r
1190 {if(hEvent.keyCode==13||hEvent.keyCode==38||hEvent.keyCode==40)\r
1191 {if(hEvent.preventDefault)\r
1192 {hEvent.preventDefault()}\r
1193 hEvent.cancelBubble=true\r
1194 hEvent.returnValue=false\r
1195 return false}}\r
1196 cAutocomplete.onInputKeyUp=function(hEvent)\r
1197 {if(hEvent==null)\r
1198 {hEvent=window.event}\r
1199 var hElement=(hEvent.srcElement)?hEvent.srcElement:hEvent.originalTarget\r
1200 var hAC=hElement.hAutocomplete\r
1201 var hInput=document.getElementById(hAC.sInputId)\r
1202 switch(hEvent.keyCode)\r
1203 {case 8:if(hAC.bAutoComplete&&hAC.bAutocompleted)\r
1204 {hAC.bAutocompleted=false\r
1205 return false}\r
1206 break\r
1207 case 38:case 40:if(hAC.bListDisplayed)\r
1208 {if(hEvent.preventDefault)\r
1209 {hEvent.preventDefault()}\r
1210 hEvent.cancelBubble=true\r
1211 hEvent.returnValue=false\r
1212 return false}\r
1213 break\r
1214 case 32:case 46:case 35:case 36:break;default:if(hEvent.keyCode<48)\r
1215 {if(hEvent.preventDefault)\r
1216 {hEvent.preventDefault()}\r
1217 if(hAC.bDebug){hAC.debug("keyUp: hEvent.returnValue = false")}\r
1218 hEvent.cancelBubble=true\r
1219 hEvent.returnValue=false\r
1220 return false}\r
1221 break}\r
1222 if(hAC.hMarkRangeTimeout!=null)\r
1223 {clearTimeout(hAC.hMarkRangeTimeout)}\r
1224 if(hAC.hShowTimeout)\r
1225 {clearTimeout(hAC.hShowTimeout)\r
1226 hAC.hShowTimeout=null}\r
1227 var nTimeout=hAC.bRemoteList?cAutocomplete.CN_REMOTE_SHOW_TIMEOUT:cAutocomplete.CN_SHOW_TIMEOUT\r
1228 hAC.hShowTimeout=setTimeout(function(){hAC.prepareList()},nTimeout)\r
1229 if(hAC.bDebug){hAC.debug("setTimeout "+nTimeout)}}\r
1230 cAutocomplete.onInputBlur=function(hEvent)\r
1231 {if(hEvent==null)\r
1232 {hEvent=window.event}\r
1233 var hElement=(hEvent.srcElement)?hEvent.srcElement:hEvent.originalTarget\r
1234 if(hElement.form)\r
1235 {hElement.form.bLocked=false}\r
1236 var hAC=hElement.hAutocomplete\r
1237 if(!hAC.hClearTimeout)\r
1238 {hAC.hClearTimeout=setTimeout(function(){hAC.clearList()},cAutocomplete.CN_CLEAR_TIMEOUT)}}\r
1239 cAutocomplete.onInputFocus=function(hEvent)\r
1240 {if(hEvent==null)\r
1241 {hEvent=window.event}\r
1242 var hElement=(hEvent.srcElement)?hEvent.srcElement:hEvent.originalTarget\r
1243 var hAC=hElement.hAutocomplete\r
1244 if(hAC.hClearTimeout)\r
1245 {clearTimeout(hAC.hClearTimeout)\r
1246 hAC.hClearTimeout=null}}\r
1247 cAutocomplete.saveCaretPosition=function(hEvent)\r
1248 {if(hEvent==null)\r
1249 {hEvent=window.event}\r
1250 var hElement=(hEvent.srcElement)?hEvent.srcElement:hEvent.originalTarget\r
1251 var hAC=hElement.hAutocomplete\r
1252 var hInput=document.getElementById(hAC.sInputId)\r
1253 if(hEvent.keyCode!=38&&hEvent.keyCode!=40)\r
1254 {hAC.nInsertPoint=cAutocomplete.getInputCaretPosition(hInput)}}\r
1255 cAutocomplete.getInputCaretPosition=function(hInput)\r
1256 {if(typeof hInput.selectionStart!='undefined')\r
1257 {if(hInput.selectionStart==hInput.selectionEnd)\r
1258 {return hInput.selectionStart}\r
1259 else\r
1260 {return hInput.selectionStart}}\r
1261 else if(hInput.createTextRange)\r
1262 {var hSelRange=document.selection.createRange()\r
1263 if(hInput.tagName.toLowerCase()=='textarea')\r
1264 {var hSelBefore=hSelRange.duplicate()\r
1265 var hSelAfter=hSelRange.duplicate()\r
1266 hSelRange.moveToElementText(hInput)\r
1267 hSelBefore.setEndPoint('StartToStart',hSelRange)\r
1268 return hSelBefore.text.length}\r
1269 else\r
1270 {hSelRange.moveStart('character',-1*hInput.value.length)\r
1271 var nLen=hSelRange.text.length\r
1272 return nLen}}\r
1273 return null}\r
1274 cAutocomplete.setInputCaretPosition=function(hInput,nPosition)\r
1275 {if(hInput.setSelectionRange)\r
1276 {hInput.setSelectionRange(nPosition,nPosition)}\r
1277 else if(hInput.createTextRange)\r
1278 {var hRange=hInput.createTextRange()\r
1279 hRange.moveStart('character',nPosition)\r
1280 hRange.moveEnd('character',nPosition)\r
1281 hRange.collapse(true)\r
1282 hRange.select()}}\r
1283 cAutocomplete.markInputRange=function(hInput,nStartPos,nEndPos)\r
1284 {if(hInput.setSelectionRange)\r
1285 {hInput.focus()\r
1286 hInput.setSelectionRange(nStartPos,nEndPos)}\r
1287 else if(hInput.createTextRange)\r
1288 {var hRange=hInput.createTextRange()\r
1289 hRange.collapse(true)\r
1290 hRange.moveStart('character',nStartPos)\r
1291 hRange.moveEnd('character',nEndPos-nStartPos)\r
1292 hRange.select()}}\r
1293 cAutocomplete.markInputRange2=function(sInputId)\r
1294 {var hInput=document.getElementById(sInputId)\r
1295 var nStartPos=hInput.hAutocomplete.nStartAC\r
1296 var nEndPos=hInput.hAutocomplete.nEndAC\r
1297 cAutocomplete.markInputRange(hInput,nStartPos,nEndPos)}\r
1298 cAutocomplete.onListBlur=function(hEvent)\r
1299 {if(hEvent==null)\r
1300 {hEvent=window.event}\r
1301 var hElement=(hEvent.srcElement)?hEvent.srcElement:hEvent.originalTarget\r
1302 hElement=getParentByProperty(hElement,'className','autocomplete_holder')\r
1303 var hAC=hElement.hAutocomplete\r
1304 if(!hAC.hClearTimeout)\r
1305 {hAC.hClearTimeout=setTimeout(function(){hAC.clearList()},cAutocomplete.CN_CLEAR_TIMEOUT)}}\r
1306 cAutocomplete.onListFocus=function(hEvent)\r
1307 {if(hEvent==null)\r
1308 {hEvent=window.event}\r
1309 var hElement=(hEvent.srcElement)?hEvent.srcElement:hEvent.originalTarget\r
1310 hElement=getParentByProperty(hElement,'className','autocomplete_holder')\r
1311 var hAC=hElement.hAutocomplete\r
1312 if(hAC.hClearTimeout)\r
1313 {clearTimeout(hAC.hClearTimeout)\r
1314 hAC.hClearTimeout=null}}\r
1315 cAutocomplete.onItemClick=function(hEvent)\r
1316 {if(hEvent==null)\r
1317 {hEvent=window.event}\r
1318 var hElement=(hEvent.srcElement)?hEvent.srcElement:hEvent.originalTarget\r
1319 var hContainer=getParentByProperty(hElement,'className','autocomplete_holder')\r
1320 var hEl=getParentByTagName(hElement,'A')\r
1321 if(hContainer!=null)\r
1322 {var hAC=hContainer.hAutocomplete\r
1323 hAC.selectOption(hEl)\r
1324 document.getElementById(hAC.sInputId).focus()\r
1325 hAC.clearList()}\r
1326 if(hEvent.preventDefault)\r
1327 {hEvent.preventDefault()}\r
1328 hEvent.cancelBubble=true\r
1329 hEvent.returnValue=false\r
1330 return false}\r
1331 cAutocomplete.onButtonClick=function(hEvent)\r
1332 {if(hEvent==null)\r
1333 {hEvent=window.event}\r
1334 var hElement=(hEvent.srcElement)?hEvent.srcElement:hEvent.originalTarget\r
1335 var hAC=hElement.hAutocomplete\r
1336 var hInput=document.getElementById(hAC.sInputId)\r
1337 if(hInput.disabled)\r
1338 {return}\r
1339 if(hAC.bDebug){hAC.debug("onButtonClick")}\r
1340 hAC.prepareList(true)\r
1341 var hInput=document.getElementById(hAC.sInputId)\r
1342 hInput.focus()}\r
1343 cAutocomplete.onFormSubmit=function(hEvent)\r
1344 {if(hEvent==null)\r
1345 {hEvent=window.event}\r
1346 var hElement=(hEvent.srcElement)?hEvent.srcElement:hEvent.originalTarget\r
1347 if(hElement.bLocked)\r
1348 {var hAC=hElement.hAutocomplete\r
1349 if(hAC.bDebug){hAC.debug("onSubmit: hElement.bLocked")}\r
1350 hElement.bLocked=false\r
1351 hEvent.returnValue=false\r
1352 if(hEvent.preventDefault)\r
1353 {hEvent.preventDefault()}\r
1354 return false}}