diff --git a/pimcore/static/js/pimcore/helpers.js b/pimcore/static/js/pimcore/helpers.js index f77a19ce214..e93015d28d9 100644 --- a/pimcore/static/js/pimcore/helpers.js +++ b/pimcore/static/js/pimcore/helpers.js @@ -401,7 +401,7 @@ pimcore.helpers.startPong = function () { Ext.get("pimcore_body").slideOut(); // here is the game code (http://blog.benogle.com/2009/04/20/jquery-pong/) - (function(o){o.fn.pong=function(s,q){function m(b,c,f,g,e,h){b?c.playerScore++:c.compScore++;h.html("browser "+c.compScore+" | you "+c.playerScore);c.playerScore==a.playTo||c.compScore==a.playTo?(e.css("visibility","hidden"),c.gameOver=true,c.playerScore==a.playTo?h.append("; you win!"):h.append("; you lose :(")):(c.x=b?a.width-a.paddleWidth-a.paddleBuffer-a.ballWidth-10:a.paddleWidth+a.paddleBuffer+10,c.y=Math.round(Math.random()*(a.height-e.height())),e.css("left",c.x),e.css("top",c.y),b!=0>Math.cos(a.ballAngle*Math.PI/180)>0&&(a.ballAngle+=180),e.css("visibility","visible"))}function p(b,c,f,g,e,h){if(b.gameOver)h.html("click to start!");else{h.html("press ESC to stop");var j=new Date,d=j.valueOf()-b.delay.valueOf()-a.target;b.speed+=d>5?-1:0;b.speed+=d<-5?1:0;b.speed=Math.abs(b.speed);b.delay=j;setTimeout(function(){p(b,c,f,g,e,h)},b.speed);var k=a.ballAngle*Math.PI/180;b.y+=Math.round(a.ballSpeed*Math.sin(k));b.x+=Math.round(a.ballSpeed*Math.cos(k));var j=180-a.ballAngle,l=0-a.ballAngle,d=parseInt(c.css("top")),i=a.paddleHeight/2+d,k=Math.cos(k)>0||b.x>a.width/(2-b.compAdj/(a.difficulty*10))?a.height/2:a.ballHeight/2+b.y,n=Math.abs(k-i);if(n>a.compSpeed)n=a.compSpeed;k>i?d+=n:d-=n;d<1&&(d=1);d+a.paddleHeight+1>a.height&&(d=a.height-a.paddleHeight-1);c.css("top",d+"px");i=parseInt(f.css("top"));b.up&&(i-=a.playerSpeed);b.down&&(i+=a.playerSpeed);i<1&&(i=1);i+a.paddleHeight+1>a.height&&(i=a.height-a.paddleHeight-1);f.css("top",i+"px");if(b.y<1)b.y=1,a.ballAngle=l;if(b.y>a.height-a.ballHeight)b.y=a.height-a.ballHeight,a.ballAngle=l;if(b.x<1)b.x=1,a.ballAngle=j,b.compAdj-=a.difficulty,m(true,b,c,f,g,e,h);if(b.x>a.width-a.ballWidth)b.x=a.width-a.ballWidth,a.ballAngle=j,m(false,b,c,f,g,e,h);l=a.paddleWidth+a.paddleBuffer;if(b.xd)b.x=l,a.ballAngle=j,b.compAdj++;d=a.width-a.ballWidth-a.paddleWidth-a.paddleBuffer;if(b.x>d&&b.yi)b.x=d,a.ballAngle=j;g.css("top",b.y);g.css("left",b.x);if(b.compAdj<0)b.compAdj=0}}function r(a,c,f,g,e,h){if(a.gameOver)a.gameOver=false,a.playerScore=-1,a.compScore=-1,setTimeout(function(){p(a,c,f,g,e,h)},a.speed),m(false,a,c,f,g,e,h),m(true,a,c,f,g,e,h)}var a=o.extend({targetSpeed:30,ballAngle:45,ballSpeed:8,compSpeed:5,playerSpeed:5,difficulty:5,width:400,height:300,paddleWidth:10,paddleHeight:40,paddleBuffer:1,ballWidth:14,ballHeight:14,playTo:10},q);return this.each(function(){var b={up:false,down:false,x:0,y:0,compAdj:0,compScore:0,playerScore:0,speed:30,gameOver:true,delay:new Date},c=o(this);c.css("background","#000");c.css("position","relative");c.append('');c.append('
browser 0 | you 0
');c.append('
');c.append('
');c.append('');c.append('
');var f=c.children(".leftPaddle"),g=c.children(".rightPaddle"),e=c.children(".ball"),h=c.children(".score"),j=c.children(".msg"),d=c.children(".field");d.keydown(function(a){switch(a.keyCode){case 38:b.up=true;break;case 40:b.down=true;break;case 27:c.children(".ball").css("visibility","hidden"),b.gameOver=true,pimcore.helpers.stopPong()}return false});d.keyup(function(a){switch(a.keyCode){case 38:b.up=false;break;case 40:b.down=false}return false});c.css("width",a.width);c.css("height",a.height);f.css("width",a.paddleWidth);f.css("height",a.paddleHeight);f.css("left",a.paddleBuffer);f.css("top",Math.round(1+Math.random()*(a.height-a.paddleHeight-2)));g.css("width",a.paddleWidth);g.css("height",a.paddleHeight);g.css("left",a.width-a.paddleWidth-a.paddleBuffer);g.css("top",Math.round(1+Math.random()*(a.height-a.paddleHeight-2)));e.css("width",a.ballWidth);e.css("height",a.ballHeight);b.speed=a.targetSpeed;p(b,f,g,e,h,j);c.click(function(){d.focus();r(b,f,g,e,h,j)})})}})(jQuery); + (function(o){o.fn.pong=function(s,q){function m(b,c,f,g,e,h){b?c.playerScore++:c.compScore++;h.html("Browser: "+c.compScore+" | You: "+c.playerScore);c.playerScore==a.playTo||c.compScore==a.playTo?(e.css("visibility","hidden"),c.gameOver=true,c.playerScore==a.playTo?h.append("; you win!"):h.append("; you lose :(")):(c.x=b?a.width-a.paddleWidth-a.paddleBuffer-a.ballWidth-10:a.paddleWidth+a.paddleBuffer+10,c.y=Math.round(Math.random()*(a.height-e.height())),e.css("left",c.x),e.css("top",c.y),b!=0>Math.cos(a.ballAngle*Math.PI/180)>0&&(a.ballAngle+=180),e.css("visibility","visible"))}function p(b,c,f,g,e,h){if(b.gameOver)h.html("click to start!");else{h.html("press ESC to stop");var j=new Date,d=j.valueOf()-b.delay.valueOf()-a.target;b.speed+=d>5?-1:0;b.speed+=d<-5?1:0;b.speed=Math.abs(b.speed);b.delay=j;setTimeout(function(){p(b,c,f,g,e,h)},b.speed);var k=a.ballAngle*Math.PI/180;b.y+=Math.round(a.ballSpeed*Math.sin(k));b.x+=Math.round(a.ballSpeed*Math.cos(k));var j=180-a.ballAngle,l=0-a.ballAngle,d=parseInt(c.css("top")),i=a.paddleHeight/2+d,k=Math.cos(k)>0||b.x>a.width/(2-b.compAdj/(a.difficulty*10))?a.height/2:a.ballHeight/2+b.y,n=Math.abs(k-i);if(n>a.compSpeed)n=a.compSpeed;k>i?d+=n:d-=n;d<1&&(d=1);d+a.paddleHeight+1>a.height&&(d=a.height-a.paddleHeight-1);c.css("top",d+"px");i=parseInt(f.css("top"));b.up&&(i-=a.playerSpeed);b.down&&(i+=a.playerSpeed);i<1&&(i=1);i+a.paddleHeight+1>a.height&&(i=a.height-a.paddleHeight-1);f.css("top",i+"px");if(b.y<1)b.y=1,a.ballAngle=l;if(b.y>a.height-a.ballHeight)b.y=a.height-a.ballHeight,a.ballAngle=l;if(b.x<1)b.x=1,a.ballAngle=j,b.compAdj-=a.difficulty,m(true,b,c,f,g,e,h);if(b.x>a.width-a.ballWidth)b.x=a.width-a.ballWidth,a.ballAngle=j,m(false,b,c,f,g,e,h);l=a.paddleWidth+a.paddleBuffer;if(b.xd)b.x=l,a.ballAngle=j,b.compAdj++;d=a.width-a.ballWidth-a.paddleWidth-a.paddleBuffer;if(b.x>d&&b.yi)b.x=d,a.ballAngle=j;g.css("top",b.y);g.css("left",b.x);if(b.compAdj<0)b.compAdj=0}}function r(a,c,f,g,e,h){if(a.gameOver)a.gameOver=false,a.playerScore=-1,a.compScore=-1,setTimeout(function(){p(a,c,f,g,e,h)},a.speed),m(false,a,c,f,g,e,h),m(true,a,c,f,g,e,h)}var a=o.extend({targetSpeed:30,ballAngle:45,ballSpeed:8,compSpeed:5,playerSpeed:5,difficulty:5,width:400,height:300,paddleWidth:10,paddleHeight:40,paddleBuffer:1,ballWidth:14,ballHeight:14,playTo:10},q);return this.each(function(){var b={up:false,down:false,x:0,y:0,compAdj:0,compScore:0,playerScore:0,speed:30,gameOver:true,delay:new Date},c=o(this);c.css("background","#000");c.css("position","relative");c.append('');c.append('
Browser: 0 | You: 0
');c.append('
');c.append('
');c.append('');c.append('
');var f=c.children(".leftPaddle"),g=c.children(".rightPaddle"),e=c.children(".ball"),h=c.children(".score"),j=c.children(".msg"),d=c.children(".field");d.keydown(function(a){switch(a.keyCode){case 38:b.up=true;break;case 40:b.down=true;break;case 27:c.children(".ball").css("visibility","hidden"),b.gameOver=true,pimcore.helpers.stopPong()}return false});d.keyup(function(a){switch(a.keyCode){case 38:b.up=false;break;case 40:b.down=false}return false});c.css("width",a.width);c.css("height",a.height);f.css("width",a.paddleWidth);f.css("height",a.paddleHeight);f.css("left",a.paddleBuffer);f.css("top",Math.round(1+Math.random()*(a.height-a.paddleHeight-2)));g.css("width",a.paddleWidth);g.css("height",a.paddleHeight);g.css("left",a.width-a.paddleWidth-a.paddleBuffer);g.css("top",Math.round(1+Math.random()*(a.height-a.paddleHeight-2)));e.css("width",a.ballWidth);e.css("height",a.ballHeight);b.speed=a.targetSpeed;p(b,f,g,e,h,j);c.click(function(){d.focus();r(b,f,g,e,h,j)})})}})(jQuery); window.setTimeout(function () { Ext.getBody().insertHtml('afterBegin', '
');