1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
|
'; //'
// Initialisation --------------------------------------------------------------
// how many matches to show at most (must be even!)
fh_showmatches=29;
var _d=document;
fh_matches=new Array();
fh_inmenu=fh_menupos=0;
fh_matchesjoined="";
fh_currenttext="";
// form shortcuts and autocomplete setting on input field
var f_p=_d.forms[0].pattern;
var f_s=_d.forms[0].show;
fh_EDropDownChange();
// Layer setup -----------------------------------------------------------------
if (_d.all && !window.opera) {
width="width:165px";
} else {
width="min-width:155px";
}
var funchelper = _d.createElement('div');
funchelper.setAttribute('style', 'background-color: white; border: 1px solid black; top: 90px;'+width+'; padding: 4px; font-size: 9px; display:none; position:absolute;');
var elems = _d.getElementsByTagName("*");
for (var i = 0; i < elems.length; i++) {
if (elems[i].tagName.toLowerCase() == 'body') {
elems[i].appendChild(funchelper);
break;
}
}
// Decompression ---------------------------------------------------------------
dcp=dcp.split("}");
for(a=0; a<dcp.length; a++) {
cpd=cpd.split(dcp[a].charAt(0)).join(dcp[a].substring(1,9));
}
function l(a) { return a[a.length-1]; }
fcl=new Array(); pst=new Array(""); ac="";
for (pos=0; pos<cpd.length; pos++) {
switch (ch=cpd.charAt(pos)) {
case ',': fcl[fcl.length]=l(pst)+ac; ac=""; break;
case '(': pst[pst.length]=l(pst)+ac; ac=""; break;
case ')': case ']': if(ac.length)fcl[fcl.length]=l(pst)+ac; ac=""; pst.length--; break;
case '[': fcl[fcl.length]=(a=l(pst)+ac); pst[pst.length]=a; ac=""; break;
default: ac=ac+ch;
}
}
// Functions -------------------------------------------------------------------
function ElLeft(eE)
{
var DL_bIE=_d.all?true:false;
var nLP=eE.offsetLeft;
var ePE=eE.offsetParent;
while (ePE!=null) {
if (DL_bIE) {
if (ePE.tagName=="TD") nLP+=ePE.clientLeft;
} else {
if (ePE.tagName=="TABLE") {
var nPB=parseInt(ePE.border);
if (isNaN(nPB)) {
var nPF=ePE.getAttribute('frame');
if (nPF!=null) nLeftPos+=1;
} else if (nPB>0) nLP+=nPB;
}
}
nLP+=ePE.offsetLeft;
ePE=ePE.offsetParent;
}
return nLP;
}
function fh_IsMatch(idx,pr)
{
if (fcl[idx].substring(0,pr.length)==pr) return true;
return false;
}
function fh_FindMatches(pr)
{
f=0;
l=fcl.length-1;
m=(f+l)>>1;
while(f<l) {
if (fcl[m]==pr) break;
if (fcl[m]<pr) f=m; else l=m;
nm=(f+l+1)>>1;
if (m==nm) break;
m=nm;
}
if (m&&fh_IsMatch(m-1,pr)) m--;
if (!fh_IsMatch(m,pr) && m<(fcl.length-1) && fh_IsMatch(m+1,pr)) m++;
res=new Array;
while (m<fcl.length && fh_IsMatch(m,pr)) res[res.length]=fcl[m++];
return res;
}
function fh_Show(what)
{
ts=funchelper.style;
if (what=="") {
if (ts.display!="none") ts.display="none";
} else {
ts.display="block";
ts.left=ElLeft(f_p)+"px";
funchelper.innerHTML=what;
}
}
function fh_HideAll()
{
fh_matches=new Array();
fh_matchesjoined="";
fh_inmenu=fh_menupos=0;
fh_Show("");
}
function fh_ShowNoMatch()
{
fh_Show("<font color=\"gray\">No such function</font>");
}
function fh_UpdateMenu()
{
flen=fh_matches.length;
if (flen<=fh_showmatches) {
beforedots=first=afterdots=0;
last=flen-1;
} else {
if (fh_inmenu) {
mid=fh_showmatches>>1;
if (fh_menupos<=mid) beforedots=first=0;
else {
beforedots=1;
first=fh_menupos-mid+1;
if (first>(flen-fh_showmatches+1)) first=flen-fh_showmatches+1;
}
if (fh_menupos>=(flen-mid-1)) {
afterdots=0;
last=flen-1;
} else {
afterdots=1;
last=fh_menupos+mid-1;
if (last<(fh_showmatches-2)) last=fh_showmatches-2;
}
} else {
first=beforedots=0;
last=fh_showmatches-2;
afterdots=1;
}
}
zh="";
if (beforedots) zh=zh+"...<br />";
for (pos=first; pos<=last; pos++) {
f=fh_matches[pos];
zh=zh+"<a href=\"/"+f+
"\" style=\"text-decoration:none;"+
(fh_inmenu&&fh_menupos==pos?"background-color:rgb(204,204,255);":"")+"\">"+f+"</a><br />";
}
if (afterdots) zh=zh+"...";
fh_Show(zh);
if (fh_inmenu) f_p.value=fh_matches[fh_menupos];
}
function fh_NewText()
{
t=f_p.value;
if (t=="") {
fh_HideAll();
return;
}
tmpmatches=fh_FindMatches(t);
if (tmpmatches.length==0) {
fh_matchesjoined="";
fh_ShowNoMatch();
return;
}
if (tmpmatches.join(",")==fh_matchesjoined) return; // do nothing
fh_inmenu=fh_menupos=0;
fh_matchesjoined=tmpmatches.join(",");
fh_matches=tmpmatches;
fh_UpdateMenu();
}
function fh_EFocus()
{
if (f_s.value=="quickref") {fh_NewText();}
}
// Timeout, so the user can click on a link before it disappears
function fh_EBlur() { setTimeout("fh_HideAll()", 200); }
function fh_EKeyPress(ev)
{
ev=ev||event||null;
if (f_s.value=="quickref"&&ev) {
var cc=ev.charCode||ev.keyCode||ev.which;
if (cc==32) {
f_p.value = f_p.value.replace(/\s/g, "");
return false;
}
//if ((cc>=97&&cc<=122)||(cc>=65&&cc<=90)||(cc>=48&&cc<=57)||cc==95) return true; // a-z A-Z 0-9 _
}
return true;
}
function fh_EKeyDown(ev)
{
ev=ev||event||null;
if (f_s.value=="quickref"&&ev&&fh_matches.length>0) {
var cc=ev.charCode||ev.keyCode||ev.which;
if (cc==38||cc==57385) { // up
if (fh_inmenu) {
if (--fh_menupos<0) fh_menupos=fh_matches.length-1;
} else {
fh_inmenu=1;
fh_menupos=fh_matches.length-1;
}
fh_UpdateMenu();
return false;
}
if (cc==40||cc==57386) { // down
if (fh_inmenu) {
if (++fh_menupos>=fh_matches.length) fh_menupos=0;
} else {
fh_inmenu=1;
fh_menupos=0;
}
fh_UpdateMenu();
return false;
}
if (cc==32) { // spacebar autocomplete
if ((p=f_p.value)=="") return false;
matches=fh_FindMatches(p);
if (matches.length==0) return false;
if (matches.length==1) { // full autocomplete in case of single match
f_p.value=matches[0];
return false;
}
if (!window.opera) {
len=0;
first=matches[0];
last=matches[matches.length-1]; matches.length--;
while (len<first.length && first.substring(0,len+1)==last.substring(0,len+1)) len++;
if (f_p.value!=first.substring(0,len)) {
f_p.value=first.substring(0,len);
}
}
return false;
}
}
return true;
}
function fh_EKeyUp(ev)
{
ev=ev||event||null;
if (f_s.value=="quickref"&&ev) {
var cc=ev.charCode||ev.keyCode||ev.which;
if (cc==38||cc==40||cc==57385||cc==57386) return false;
if (f_p.value!=fh_currenttext) {
fh_currenttext=f_p.value;
fh_NewText();
}
}
return true;
}
// turn off browser's built in autocomplete if in quickref mode
function fh_EDropDownChange(ev)
{
if(f_s.value=="quickref") {
f_p.setAttribute("autocomplete", "off");
} else {
f_p.setAttribute("autocomplete", "on");
}
}
// Event listener setup --------------------------------------------------------
f_p.onkeypress=fh_EKeyPress;
f_p.onfocus=fh_EFocus;
f_p.onblur=fh_EBlur;
f_p.onkeydown=fh_EKeyDown;
f_p.onkeyup=fh_EKeyUp;
f_s.onchange=fh_EDropDownChange;
|