User:Yair rand/wssearch.js

jQuery(document).ready(function($){ var d,p; $(".searchboxInput").attr('autocomplete','off').keyup(function(e){ var v = this.value, t = this;console.log(arguments) d = d || t.parentNode.insertBefore(newNode('div', {'style':'background-color:white;position:absolute;top:32px;border:1px #AAA solid;text-align:left;margin-left:2px;'}), t); if(e.keyCode==38 || e.keyCode==40){ $(p).mouseleave; if(p){ $(p = p[e.keyCode==38?'previousSibling':'nextSibling']).mouseenter; } else { $(p = d[e.keyCode==38?'lastChild':'firstChild']).mouseenter; }  return e.originalEvent.returnValue=false; } if(e.keyCode==13 && p){ $(p).click } JsMwApi({action:'query',generator:'backlinks',gbltitle:'Wikisaurus:'+(this.value||'dontlinkhere'),gblnamespace:110,prop:'revisions',rvprop:'content'},function(r){   $(d).empty;   if(r&&r.query){    zxc=r=r.query.pages;    $.each(r, function(i){ var rr=r[i].revisions[0]['*'], m=rr.match(RegExp("[\\s\\S]+\\{\\{ws sense\\|([^\\}]+)(?=[\\s\\S]+?\\{\\{ws\\|"+util.escapeRe(v)+"(\\}\\}|\\|))")), mm=rr.match(RegExp("[\\s\\S]+\n=====([^=]+)=====\n[\\s\\S]+?\\{\\{ws\\|(?="+util.escapeRe(v)+"(\\}\\}|\\|))")); if(m && m[1] && mm && mm[1]){ var dd=d.appendChild(newNode('div',{'style':'padding:0px 3px;cursor:pointer;'},mm[1]!="Synonyms"?newNode('i',mm[1]+' - '):'',m[1])); $(dd) .hover(function{$(p).mouseleave;p=this;this.className=os_HighlightClass},function{this.className=''}) .click(function{location.href=location.href.replace(wgPageName,r[i].title);$(d).empty}); }   })   }  }) }) })