Template:ETH Zurich/myeggsJS
var beaconRush = function(){function j(){function c(a,b,c){this.rush=c;this.speed=3;this.x=a;this.y=b;this.height=70;this.width=25;this.isFinished=this.isKilling=!1;this.dPulsate=0;this.dom=e("<zergling>").css({width:this.width,height:this.height,position:"absolute",display:"block",left:a,top:b,zIndex:9999,'background':'url("") no-repeat','transform':'rotate(135deg)'}).appendTo(k)}function f(a){var b=this,d=this.zerglings=[];this.targets=[];for(var e=0;e<a;++e)d.push(new c(100*Math.random(),100*Math.random(),this));this.intervalID=setInterval(function(){b.step()},30)}window.Zergling=c;window.ZergRush=f;var h=document,k=h.body,g=Math.atan2,m=Math.cos,n=Math.sin,o=Math.PI,i=Math.random,p=Math.max;c.DATA_KEY="zergTargetData";c.MIN_TARGET_AREA=5E4;c.VISION=1E3;c.LIFE=50;c.isSuitableTarget=function(a){var b;if(!a)return!1;for(b=a;b=b.parentNode;)if(e.data(b,c.DATA_KEY)||/antiZerg/i.test(b.className))return!1;b=e.data(a,c.DATA_KEY);a=e(a);return!/zergling/i.test(a[0].nodeName)&&!/antiZerg/i.test(a[0].className)&&(!b||0<b.life)&&a.width()*a.height()<c.MIN_TARGET_AREA};c.prototype={calcMovement:function(){var a=this.target,b=a.position.left+i()*a.width-this.x,a=a.position.top+i()*a.height-this.y,b=g(a,b);this.dx=this.speed*m(b);this.dy=this.speed*n(b)},draw:function(){if(!this.isFinished){var a=this.target;if(this.isKilling)0<a.life?(a.life--,this.pulsate(),a.dom.css("opacity",a.life/c.LIFE)):(a.dom.css("visibility","hidden"),this.pulsate(0),this.isKilling=!1,this.target=null);else{if(!this.target||0>=this.target.life)if(this.findTarget())a=this.target,this.calcMovement();else{this.isFinished=!0;this.dom.fadeOut(100,function(){e(this).remove()});return}this.hasReachedTarget()?this.isKilling=!0:(this.x+=this.dx,this.y+=this.dy,this.dom.css({left:this.x,top:this.y}))}}},hasReachedTarget:function(){var a=this.target,b=a.position;return this.x>=b.left&&this.y>=b.top&&this.x<=b.left+a.width&&this.y<=b.top+a.height},findTarget:function(){var a,b,d,f,g=this.width/2,i=this.height/2,j=p(k.scrollTop,h.documentElement.scrollTop),l=p(k.scrollLeft,h.documentElement.scrollLeft);for(a=10;a<c.VISION;a+=50)for(b=0;360>b;b+=45)if(d=this.x+g+a*m(o/180*b)-l,f=this.y+i+a*n(o/180*b)-j,c.isSuitableTarget(d=h.elementFromPoint(d,f)))return d=e(d),a=this.target=d.data(c.DATA_KEY),a||(d.data(c.DATA_KEY,this.target={dom:d,position:d.offset(),width:d.width(),height:d.height(),life:c.LIFE,initialCSS:{visibility:"",opacity:d.css("opacity")||""}}),this.rush.registerTarget(this.target)),!0},pulsate:function(){(this.dPulsate=!this.dPulsate)?this.dom.css({left:this.x-2,top:this.y-2,width:40,height:85}):this.dom.css({left:this.x,top:this.y,width:25,height:70})}};f.prototype={step:function(){for(var a=!0,b=0;b<this.zerglings.length;++b)this.zerglings[b].draw(),a=a&&this.zerglings[b].isFinished;a&&clearInterval(this.intervalID)},destroy:function(){clearInterval(this.intervalID);for(var a=0;a<this.zerglings.length;++a)this.zerglings[a].dom.remove();for(a=0;a<this.targets.length;++a)this.targets[a].dom.css(this.targets[a].initialCSS),this.targets[a].dom.removeData(c.DATA_KEY)},registerTarget:function(a){this.targets.push(a)}}}var e,f=window.jQuery,g=document.createElement("script");g.src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js";document.body.appendChild(g);var l=setInterval(function(){if(f?window.jQuery!==f:window.jQuery)clearInterval(l),e=window.jQuery.noConflict(!0),j(),new ZergRush(10)},200)}
var state = 0, keys = [68,65,78,73,69,76,83,65,73,68], stateC = 0, keysC = [38,38,40,40,37,39,37,39,66,65,83], keysB = [66,69,65,67,79,78,82,85,83,72], stateB = 0;
var datcode = function(e) {
state = (e.keyCode == keys[state] ) ? (state +1) : 0; stateC = (e.keyCode == keysC[stateC]) ? (stateC+1) : 0; stateB = (e.keyCode == keysB[stateB]) ? (stateB+1) : 0;
if (state == keys.length) {document.getElementById("sandbox").innerHTML = "
THIS EASTER EGG DOESN'T MAKE ANY SENSE!!!
$("#sandbox").css({'padding-bottom':'20px','display':'block'}); state++; } if (stateC == keysC.length) { var life = "<img src=\"\">"; document.getElementById("runner").innerHTML = "<img id=\"runnerImg\" src=\"\">"; document.getElementById("lives").innerHTML = life+life+life+life; $("#lives").css({'display':'block'}); $("#runner").css({'display':'block'}); stateC++; } if (stateB == keysB.length) { beaconRush(); stateB++; }
}
$(window).load(function() {
if (window.outerWidth > 480) { $(document).keydown(datcode); }
});