1var liveSearchReq = false; 2var t = null; 3var liveSearchLast = ""; 4var liveSearchQ = "*"; 5var liveSearchRoot = "www.ginetex.net"; 6var data_type = ""; 7var PreventEmptyRequest; 8 9var isIE = false; 10// on !IE we only have to initialize it once 11if (window.XMLHttpRequest) { 12 liveSearchReq = new XMLHttpRequest(); 13} 14 15var wpRoot = ""; 16 17// ---> working on the wp root stuff for the live search 18 19function liveSearchInit(type, onLoad, preventEmptyRequest, wpRoot) { 20 if (navigator.userAgent.indexOf("Safari") > 0) { 21 document.getElementById('livesearch').addEventListener("keydown", liveSearchKeyPress, false); 22 } else if (navigator.product == "Gecko") { 23 24 document.getElementById('livesearch').addEventListener("keypress", liveSearchKeyPress, false); 25 document.getElementById('livesearch').addEventListener("blur", liveSearchHideDelayed, false); 26 27 } else { 28 document.getElementById('livesearch').attachEvent('onkeydown', liveSearchKeyPress); 29 isIE = true; 30 } 31 32 this.wpRoot = wpRoot; 33 34 PreventEmptyRequest = preventEmptyRequest; 35 data_type = type; 36 37 document.getElementById('livesearch').setAttribute("autocomplete", "off"); 38 39 if (onLoad) 40 window.setTimeout("liveSearchStartSel()", 100); 41} 42 43function liveSearchHideDelayed() { 44 window.setTimeout("liveSearchHide()", 400); 45} 46 47function liveSearchHide() { 48 var highlight = document.getElementById("LSHighlight"); 49 if (highlight) { 50 highlight.removeAttribute("id"); 51 } 52} 53 54function liveSearchKeyPress(event) { 55 56 if (event.keyCode == 40) 57 //KEY DOWN 58 { 59 highlight = document.getElementById("LSHighlight"); 60 if (!highlight) { 61 highlight = document.getElementById("LSShadow").firstChild.firstChild; 62 } else { 63 highlight.removeAttribute("id"); 64 highlight = highlight.nextSibling; 65 } 66 if (highlight) { 67 highlight.setAttribute("id", "LSHighlight"); 68 } 69 if (!isIE) { event.preventDefault(); } 70 } 71 //KEY UP 72 else if (event.keyCode == 38) { 73 highlight = document.getElementById("LSHighlight"); 74 if (!highlight) { 75 highlight = document.getElementById("LSResult").firstChild.firstChild.lastChild; 76 } 77 else { 78 highlight.removeAttribute("id"); 79 highlight = highlight.previousSibling; 80 } 81 if (highlight) { 82 highlight.setAttribute("id", "LSHighlight"); 83 } 84 if (!isIE) { event.preventDefault(); } 85 } 86 //ESC 87 else if (event.keyCode == 27) { 88 highlight = document.getElementById("LSHighlight"); 89 if (highlight) { 90 highlight.removeAttribute("id"); 91 } 92 document.getElementById("LSResult").style.display = "none"; 93 } 94 //BACKSPACE - required for IE 95 else if (event.keyCode == 8 && isIE) { 96 liveSearchStart(); 97 } 98} 99 100function liveSearchStartSel() { 101 liveSearchLast = "---"; 102 liveSearchStart(); 103} 104 105function liveSearchStart() { 106 if (t) { 107 window.clearTimeout(t); 108 } 109 t = window.setTimeout("liveSearchDoSearch()", 200); 110} 111 112function liveSearchDoSearch() { 113 114 if (typeof liveSearchRoot == "undefined") { 115 liveSearchRoot = ""; 116 } 117 if (typeof liveSearchRootSubDir == "undefined") { 118 liveSearchRootSubDir = ""; 119 } 120 if (typeof liveSearchParams == "undefined") { 121 liveSearchParams2 = ""; 122 } else { 123 liveSearchParams2 = "&" + liveSearchParams; 124 } 125 if (liveSearchLast != document.forms.searchform.q.value) { 126 if (liveSearchReq && liveSearchReq.readyState < 4) { 127 liveSearchReq.abort(); 128 } 129 if (document.forms.searchform.q.value == "") { 130 liveSearchQ = ""; 131 liveSearchLast = ""; 132 } else { 133 liveSearchQ = document.forms.searchform.q.value; 134 } 135 136 var l = document.forms.searchform.l != null ? document.forms.searchform.l.value : null; 137 var d = document.forms.searchform.d != null ? document.forms.searchform.d.value : null; 138 var r = document.forms.searchform.r != null ? document.forms.searchform.r.value : null; 139 var q = document.forms.searchform.q != null ? document.forms.searchform.q.value : null; 140 var k = document.forms.searchform.k != null ? document.forms.searchform.k.value : null; 141 142 if (PreventEmptyRequest && q === "") { 143 document.getElementById("result").innerHTML = ""; 144 return; 145 } 146 jQuery.ajax({ 147 url: wpRoot + '/wp-admin/admin-ajax.php', 148 type: 'GET', 149 datatype: 'xml', 150 data: { 151 action: 'get_' + data_type, 152 l: l, 153 d: d, 154 q: q, 155 r: r, 156 k: k 157 }, 158 success: function (response) { 159 document.getElementById("result").innerHTML = response; 160 161 jQuery("#result td.sel").each(function () { 162 jQuery(this).parent().addClass("sel"); 163 }); 164 } 165 }); 166 } 167} 168 169function liveSearchProcessReqChange() { 170 171 if (liveSearchReq.readyState == 4) { 172 var res = document.getElementById("LSResult"); 173 res.style.display = "block"; 174 var sh = document.getElementById("LSShadow"); 175 176 sh.innerHTML = liveSearchReq.responseText; 177 178 } 179} 180 181function liveSearchSubmit(event) { 182 // if submit button is pressed -> enforce live search 183 liveSearchStartSel(); 184 event.preventDefault(); 185 return false; 186}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.