1/** 2 * AJAX functions for the pagename quicksearch 3 * 4 * This script is a near 1:1 clone of the standard DokuWiki qsearch script. 5 * 6 * @license GPL2 (http://www.gnu.org/licenses/gpl.html) 7 * @author Andreas Gohr <andi@splitbrain.org> 8 * @author Adrian Lang <lang@cosmocode.de> 9 * @author Gabriel Birke <lang@cosmocode.de> 10 */ 11 12addInitEvent(function () { 13 var inID = 'solr_qsearch__in'; 14 var outID = 'solr_qsearch__out'; 15 var inObj = document.getElementById(inID); 16 var outObj = document.getElementById(outID); 17 // objects found? 18 if (inObj === null){ return; } 19 if (outObj === null){ return; } 20 function clear_results(){ 21 outObj.style.display = 'none'; 22 outObj.innerHTML = ''; 23 } 24 var sack_obj = new sack(DOKU_BASE + 'lib/exe/ajax.php'); 25 sack_obj.AjaxFailedAlert = ''; 26 sack_obj.encodeURIString = false; 27 sack_obj.onCompletion = function () { 28 var data = sack_obj.response; 29 if (data === '') { return; } 30 outObj.innerHTML = data; 31 outObj.style.display = 'block'; 32 }; 33 // attach eventhandler to search field 34 var delay = new Delay(function () { 35 clear_results(); 36 var value = inObj.value; 37 if(value === ''){ return; } 38 sack_obj.runAJAX('call=solr_qsearch&q=' + encodeURI(value)); 39 }); 40 addEvent(inObj, 'keyup', function () {clear_results(); delay.start(); }); 41 // attach eventhandler to output field 42 addEvent(outObj, 'click', function () {outObj.style.display = 'none'; }); 43}); 44