All pastes #986254 Raw Edit

Something

public javascript v1 · immutable
·published 2008-04-15 17:33 UTC
rendered paste body
if(typeof $WowheadPower=="undefined"){var $WowheadPower=new function(){function ce(z,p){var r=document.createElement(z);if(p){cO(r,p);}return r;}function ae(z,y){return z.appendChild(y);}function aE(z,y,x){if(window.attachEvent){z.attachEvent("on"+y,x);}else{z.addEventListener(y,x,false);}}function cO(d,s){for(var p in s){if(typeof s[p]=="object"){if(!d[p]){d[p]={};}cO(d[p],s[p]);}else{d[p]=s[p];}}}function $E(e){if(!e){e=event;}if(!e._button){e._button=e.which?e.which:e.button;e._target=e.target?e.target:e.srcElement;}return e;}function getWindowSize(){var _d=0,_e=0;if(typeof window.innerWidth=="number"){_d=window.innerWidth;_e=window.innerHeight;}else{if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){_d=document.documentElement.clientWidth;_e=document.documentElement.clientHeight;}else{if(document.body&&(document.body.clientWidth||document.body.clientHeight)){_d=document.body.clientWidth;_e=document.body.clientHeight;}}}return {w:_d,h:_e};}function getScroll(){var x=0,y=0;if(typeof (window.pageYOffset)=="number"){x=window.pageXOffset;y=window.pageYOffset;}else{if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){x=document.body.scrollLeft;y=document.body.scrollTop;}else{if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){x=document.documentElement.scrollLeft;y=document.documentElement.scrollTop;}}}return {x:x,y:y};}function getCursorPos(e){var x,y;if(window.innerHeight){x=e.pageX;y=e.pageY;}else{var _14=getScroll();x=e.clientX+_14.x;y=e.clientY+_14.y;}return {x:x,y:y};}var opt={applyto:3},_16,_17,_18,_19,_1a=document.getElementsByTagName("head")[0],_1b=[],_1c=[],_1d=[],_1e,_1f,_20,_21,_22=1,ie=!!(window.attachEvent&&!window.opera),ie7=navigator.userAgent.indexOf("MSIE 7.0")!=-1,ie6=navigator.userAgent.indexOf("MSIE 6.0")!=-1&&!ie7,_26={loading:"Loading...",noresponse:"No response from server :("},_27=0,_28=1,_29=2,_2a=3,_2b=4,_2c=3,_2d=5,_2e=6,_2f=15,_30=15,_31={3:[_1b,"item","Item"],5:[_1c,"quest","Quest"],6:[_1d,"spell","Spell"]};function init(){ae(_1a,ce("link",{type:"text/css",href:"http://www.wowhead.com/widgets/power/power.css?3",rel:"stylesheet"}));if(ie){ae(_1a,ce("link",{type:"text/css",href:"http://www.wowhead.com/widgets/power/power_ie.css?3",rel:"stylesheet"}));if(ie6){ae(_1a,ce("link",{type:"text/css",href:"http://www.wowhead.com/widgets/power/power_ie6.css?3",rel:"stylesheet"}));}}aE(document,"mouseover",onMouseOver);}function updateCursorPos(e){var pos=getCursorPos(e);_18=pos.x;_19=pos.y;}function scanElement(t,e){if(t.nodeName!="A"){return -2323;}if(!t.href.length){return;}var i1,i2,m;if(opt.applyto&1){i1=2;i2=3;m=t.href.match(/http:\/\/(www\.)?wowhead\.com\/\?(item|quest|spell)=([0-9]+)/);}if(m==null&&(opt.applyto&2)&&t.rel){i1=1;i2=2;m=t.rel.match(/(item|quest|spell).?([0-9]+)/);}if(m){if(!t.onmousemove){t.onmousemove=onMouseMove;t.onmouseout=onMouseOut;}updateCursorPos(e);if(m[i1]=="item"){display(_2c,m[i2]);}else{if(m[i1]=="quest"){display(_2d,m[i2]);}else{display(_2e,m[i2]);}}}}function onMouseOver(e){e=$E(e);var t=e._target;var i=0;while(t!=null&&i<3&&scanElement(t,e)==-2323){t=t.parentNode;++i;}}function onMouseMove(e){e=$E(e);updateCursorPos(e);moveTooltip();}function onMouseOut(){_16=null;hideTooltip();}function initTooltip(){if(!_1e){var d=ce("div"),t=ce("table"),tb=ce("tbody"),tr1=ce("tr"),tr2=ce("tr"),td=ce("td"),th1=ce("th"),th2=ce("th"),th3=ce("th");d.className="wowhead-tooltip";th1.style.backgroundPosition="top right";th2.style.backgroundPosition="bottom left";th3.style.backgroundPosition="bottom right";ae(tr1,td);ae(tr1,th1);ae(tb,tr1);ae(tr2,th2);ae(tr2,th3);ae(tb,tr2);ae(t,tb);_21=ce("p");_21.style.display="none";ae(_21,ce("div"));ae(d,_21);ae(d,t);ae(document.body,d);_1e=d;_1f=t;_20=td;if(opt.showlogo){var img=ce("div");img.className="wowhead-tooltip-powered";ae(d,img);}hideTooltip();}}function showTooltip(_47,_48){if(!_1e){initTooltip();}if(!_47){_47=_31[_16][2]+" not found :(";_48="Temp";}if(_22&&_48){_21.style.backgroundImage="url(http://static.wowhead.com/images/icons/medium/"+_48.toLowerCase()+".jpg)";_21.style.display="";}else{_21.style.backgroundImage="none";_21.style.display="none";}_1e.style.display="";_1e.style.width="320px";_20.innerHTML=_47;fixTooltip();moveTooltip();_1e.style.visibility="visible";}function hideTooltip(){if(!_1e){return;}_1e.style.display="none";_1e.style.visibility="hidden";}function fixTooltip(){var c=_20.childNodes;if(c.length>=2&&c[0].nodeName=="TABLE"&&c[1].nodeName=="TABLE"){var m;if(c[1].offsetWidth>300){m=Math.max(300,c[0].offsetWidth)+20;}else{m=Math.max(c[0].offsetWidth,c[1].offsetWidth)+20;}if(m>20){_1e.style.width=m+"px";c[0].style.width=c[1].style.width="100%";}}else{_1e.style.width=_1f.offsetWidth+"px";}}function moveTooltip(){if(!_1e){return;}if(_18==null){return;}var _4b=getWindowSize(),_4c=getScroll(),bcw=_4b.w,bch=_4b.h,bsl=_4c.x,bst=_4c.y,tow=_1f.offsetWidth,toh=_1f.offsetHeight,_53=_18+_2f,top=_19-toh-_30;if(_53+_2f+tow+4>=bsl+bcw){var foo=_18-tow-_2f;if(foo>=0){_53=foo;}else{_53=bsl+bcw-tow-_2f-4;}}if(top<bst){top=_19+_30;if(top+toh>bst+bch){top=bst+bch-toh;if(_22){if(_18>=_53-48&&_18<=_53&&_19>=top-4&&_19<=top+48){top-=48-(_19-top);}}}}_1e.style.left=_53+"px";_1e.style.top=top+"px";}function initElement(_56,id){var arr=_31[_56][0];if(arr[id]==null){arr[id]={};}if(arr[id].status==null){arr[id].status=_27;}}function display(_59,id){_16=_59;_17=id;initElement(_59,id);var arr=_31[_59][0];if(arr[id].status==_2b||arr[id].status==_2a){showTooltip(arr[id].tooltip,arr[id].icon);}else{if(arr[id].status==_28){showTooltip(_26.loading);}else{request(_59,id);}}}function request(_5c,id,_5e){var arr=_31[_5c][0];if(arr[id].status!=_27&&arr[id].status!=_29){return;}arr[id].status=_28;if(!_5e){arr[id].timer=setTimeout(function(){showLoading.apply(this,[_5c,id]);},333);}ajaxIshRequest("http://www.wowhead.com/?"+_31[_5c][1]+"="+id+"&power");}function ajaxIshRequest(url){ae(_1a,ce("script",{type:"text/javascript",src:url}));}function showLoading(_61,id){if(_16==_61&&_17==id){showTooltip(_26.loading);var arr=_31[_61][0];arr[id].timer=setTimeout(function(){notFound.apply(this,[_61,id]);},3850);}}function notFound(_64,id){var arr=_31[_64][0];arr[id].status=_29;if(_16==_64&&_17==id){showTooltip(_26.noresponse);}}this.register=function(_67,id,_69){var arr=_31[_67][0];clearTimeout(arr[id].timer);cO(arr[id],_69);if(arr[id].tooltip){arr[id].status=_2b;}else{arr[id].status=_2a;}if(_16==_67&&id==_17){showTooltip(arr[id].tooltip,arr[id].icon);}};this.registerItem=function(id,_6c){this.register(_2c,id,_6c);};this.registerQuest=function(id,_6e){this.register(_2d,id,_6e);};this.registerSpell=function(id,_70){this.register(_2e,id,_70);};this.set=function(foo){cO(opt,foo);};this.showTooltip=function(e,_73,_74){updateCursorPos(e);showTooltip(_73,_74);};this.hideTooltip=function(){hideTooltip();};this.moveTooltip=function(e){onMouseMove(e);};init();};}