| 
									
										
										
										
											2014-08-18 10:44:46 +02:00
										 |  |  | if(searx.autocompleter) { | 
					
						
							|  |  |  |     window.addEvent('domready', function() { | 
					
						
							| 
									
										
										
										
											2015-02-16 14:45:42 +01:00
										 |  |  | 	    new Autocompleter.Request.JSON('q', './autocompleter', { | 
					
						
							| 
									
										
										
										
											2014-08-18 10:44:46 +02:00
										 |  |  | 		    postVar:'q', | 
					
						
							|  |  |  | 		    postData:{ | 
					
						
							|  |  |  | 			    'format': 'json' | 
					
						
							|  |  |  | 		    }, | 
					
						
							|  |  |  | 		    ajaxOptions:{ | 
					
						
							|  |  |  | 		        timeout: 5   // Correct option?
 | 
					
						
							|  |  |  | 		    }, | 
					
						
							|  |  |  | 		    'minLength': 4, | 
					
						
							|  |  |  | 		    // 'selectMode': 'type-ahead',
 | 
					
						
							|  |  |  | 		    cache: true, | 
					
						
							|  |  |  | 		    delay: 300 | 
					
						
							|  |  |  | 	    }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | (function (w, d) { | 
					
						
							|  |  |  |     'use strict'; | 
					
						
							|  |  |  |     function addListener(el, type, fn) { | 
					
						
							|  |  |  |         if (el.addEventListener) { | 
					
						
							|  |  |  |             el.addEventListener(type, fn, false); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             el.attachEvent('on' + type, fn); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function placeCursorAtEnd() { | 
					
						
							|  |  |  |         if (this.setSelectionRange) { | 
					
						
							|  |  |  |             var len = this.value.length * 2; | 
					
						
							|  |  |  |             this.setSelectionRange(len, len); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     addListener(w, 'load', function () { | 
					
						
							|  |  |  |         var qinput = d.getElementById('q'); | 
					
						
							|  |  |  |         if (qinput !== null && qinput.value === "") { | 
					
						
							|  |  |  |             addListener(qinput, 'focus', placeCursorAtEnd); | 
					
						
							|  |  |  |             qinput.focus(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | })(window, document); | 
					
						
							|  |  |  | 
 |