Javascript - Html kodları

Aşağıdaki kodları <body> kodundan sonra istediğiniz bir yere yapıştırın.

{codecitation class="brush: xml; gutter: false;" width="500px"}

<script language="JavaScript">

<!-- BreakOut - http://website.lineone.net/~kurt.grigg/javascript

function DownLoad(){

if(confirm("Tebrikler!! Siteme Gitmek İster Misin?"))

window.location.href='http://www.uzmanweb.net';

}

n6=(document.getElementById&&!document.all);

n4=(document.layers);

ie=(document.all);

now=null;

counter=null;

function Stopwatch(){

var myTime=new Date();

return((myTime.getTime() - counter)/1000);

}

function getSecs(){

var tSecs = Math.round(Stopwatch());

var iSecs = tSecs % 60;

var iMins = Math.round((tSecs-30)/60);

var sSecs ="" + ((iSecs > 9) ? iSecs : "0" + iSecs);

var sMins ="" + ((iMins > 9) ? iMins : "0" + iMins);

var tme= sMins+":"+sSecs;

document.form1.count.value=tme;

}

d=(n4||ie)?'document.':'document.getElementById("';

a=(n4||n6)?'':'all.';

n6r=(n6)?'")':'';

s=(n4)?'':'.style';

blocksleft=15;

vy=(n4)?'show':'visible';

vn=(n4)?'hide':'hidden';

blocks=15;//number of blocks

ballsleft=3;

displaycolors=new Array('#ff0000','#00aa00','#0000ff','#cc00cc','#000000','#eee000')

blockcolors=new Array('#ff0000','#00aa00','#0000ff','#cc00cc','#eee000')

spread=new Array();

B=4;//Ball size.

BD=50;//Block size.

D=270;//Initial ball direction.

Y=385;

X=128;

preY=0;

preX=0;

Q=0;

ts=0;

bs=0;

ls=0;

rs=0;

ty=0;

tx=0;

by=0;

bx=0;

ly=0;

lx=0;

ry=0;

rx=0;

t=null;

Top=1;

Left=0;

ini=-50;

for (i=0; i < blocks; i++){

spread[i] = ini+=51;

var col1=Math.floor(Math.random()*blockcolors.length);

var col2=Math.floor(Math.random()*blockcolors.length);

var col3=Math.floor(Math.random()*blockcolors.length);

var col4=Math.floor(Math.random()*displaycolors.length);

if (ie||n6)

document.write('<div id="G'+i+'" style="position:absolute;top:'+Top+'px;left:'+spread[i]+'px;height:'+BD+'px;width:'+BD+';background:'+blockcolors[col1]+';visibility:'+vy+'"></div>');

if (n4)

document.write('<layer name=G'+i+' top='+Top+' left='+spread[i]+' width='+BD+' height='+BD+' bgcolor='+blockcolors[col1]+' visibility='+vy+'></layer>');

if (i == 4){Top+=51;ini=-50;}

if (i == 9){Top+=51;ini=-50;}

}

TW=(n4)?198:(ie)?246:248;

TH=(n4)?438:437;//?

win="<font face=Verdana color=#00bb00 size=6>Kazandınız</font>";

lose="<font face=Verdana color=#ff0000 size=6>Kaybettiniz</font>";

document.write("<table height="+TH+" width=398 cellpadding=0 cellspacing=0 border=0><tr valign=top><td width="+TW+">&nbsp;</td><td align=center bgcolor="+displaycolors[col4]+">");

document.write("<font face=Verdana size=5 color=#ffffff>Break Out</font>");

document.write("<form name=form1><font face=Verdana size=2 color=#ffffff>Top Hızı</font><br><select name='amount'>");

document.write("<option value=5 selected>5");

for (i=10; i < 21; i+=5)

{document.write("<option value="+i+">"+i)}

document.write("</select><p>"

+"<font face=Verdana size=2 color=#ffffff>Zaman</font><br><input name=count type=text size=5 value='00:00'><p>"

+"<font face=Verdana size=2 color=#ffffff>Kalan Blok Sayısı</font><br><input name=lft type=text size=5 value='15'><p>"

+"<font face=Verdana size=2 color=#ffffff>Kalan Top Sayısı</font><br><input name=bll type=text size=5 value='3'><p>"

+"&nbsp;<br><input type='reset' value='Yeni Oyun' onClick='window.location.reload()'></form><p>&nbsp;<p>&nbsp;<br>"

+"<font face=Verdana size=2 color=#ffffff><a href=\"http://website.lineone.net/~kurt.grigg/javascript\">Kurt's Dhtml</a></font>"

+"</td></tr></table>");

if (ie||n6){

document.write("<div id='info'style='position:absolute;top:182px;left:60px'></div>");

document.write('<div id=ball style="position:absolute;top:385px;left:128px;height:'+B+'px;width:'+B+'px;font-size:'+B+'px;background:#000000"></div>');

document.write("<div id='go'style='position:absolute;top:340px;left:108px'><form><input type=button value='Start' onClick='now=new Date();counter=now.getTime();Move();this.style.visibility=\"hidden\"'></form></div>");

document.write("<div id='paddle' style='position:absolute;top:413px;left:110px;width:40px;height:2px;font-size:2px;background:#ff0000'></div>");

}

if (n4){

document.write("<layer name='info' left=62 top=182></layer>");

document.write('<layer name=ball top=385 left=128 width='+B+' height='+B+' bgcolor=#000000></layer>');

document.write("<layer name='go' left=108 top=340><form><input type=button value='Basla' onClick='now=new Date();counter=now.getTime();Move()'></form></layer>");

document.write("<layer name='paddle' left=110 top=412 width=40 height=2 bgcolor=#ff0000></layer>");

}



xpos=0;

temppaddle=eval(d+a+"paddle"+n6r+s);

(n4||n6)?window.captureEvents(Event.MOUSEMOVE):0;

function Mouse(evnt){

xpos = (n4||n6)?evnt.pageX-20:event.x-20;

if (xpos < 1) xpos=0;

if (xpos > 216) xpos=216;

temppaddle.left=xpos;

}

(n4)?window.onMouseMove=Mouse:document.onmousemove=Mouse;

function Move(){

t=setTimeout('Move()',20);

getSecs();

if(n4)document.go.visibility='hide';

getSpeed=document.form1.amount;

S=getSpeed.options[getSpeed.selectedIndex].value;

H=(n4||n6)?window.innerHeight:document.body.clientHeight;

W=(n4||n6)?window.innerWidth:document.body.clientWidth;

y=S*Math.sin(D*Math.PI/180);

x=S*Math.cos(D*Math.PI/180);

if (D < 0) D+=360;

Y+=y;

X+=x;

VB=180-D;

HB=0-D;



//Actual distance between speed h & v steps.

ay=Y+S*Math.sin(D*Math.PI/180);

ax=X+S*Math.cos(D*Math.PI/180);

dify = Y-ay;

difx = X-ax;

//Step before impact for all sides.

preY=Y+dify;

preX=X+difx;



for (i=0; i < blocks; i++){

block=eval(d+a+"G"+i+n6r+s);

TOP=(!ie)?parseInt(block.top):block.pixelTop;

BOTTOM=(!ie)?parseInt(block.top)+BD:block.pixelTop+BD;

LEFT=(!ie)?parseInt(block.left):block.pixelLeft;

RIGHT=(!ie)?parseInt(block.left)+BD:block.pixelLeft+BD;



//difference between top-centre & pre-hit.

ty=(ie)?block.pixelTop - (preY+B/2):parseInt(block.top) - (preY+B/2);

tx=(ie)?block.pixelLeft+(BD/2) - (preX+B/2):parseInt(block.left)+(BD/2) - (preX+B/2);

ts=Math.sqrt(tx*tx + ty*ty);



//difference between bottom-centre & pre-hit!

by=(ie)?(block.pixelTop+BD) - (preY+B/2):parseInt(block.top)+BD - (preY+B/2);

bx=(ie)?(block.pixelLeft+(BD/2)) - (preX+B/2):parseInt(block.left)+(BD/2) - (preX+B/2);

bs=Math.sqrt(by*by + bx*bx);



//difference between left-centre & pre-hit!

ly=(ie)?(block.pixelTop+(BD/2)) - (preY+B/2):parseInt(block.top)+(BD/2) - (preY+B/2);

lx=(ie)?block.pixelLeft - (preX+B/2):parseInt(block.left) - (preX+B/2)

ls=Math.sqrt(lx*lx + ly*ly);



//difference between right-centre & pre-hit!

ry=(ie)?(block.pixelTop+(BD/2)) - (preY+B/2):parseInt(block.top)+(BD/2) - (preY+B/2);

rx=(ie)?(block.pixelLeft+BD) - (preX+B/2):parseInt(block.left)+BD - (preX+B/2);

rs=Math.sqrt(rx*rx + ry*ry);







if((block.visibility==vy)&&(Y+B>TOP)&&(Y<BOTTOM)&&(X+B>LEFT)&&(X<RIGHT)){

block.visibility=vn;

blocksleft--;



//Top left corner hit.

if((ts==ls)&&(ts&&ls<rs&&bs)){Y=TOP-B;X=LEFT-B;D=225}

//Top right corner hit.

if((ts==rs)&&(ts&&rs<ls&&bs)){Y=TOP-B;X=RIGHT;D=315}

//Bottom left corner hit.

if((bs==ls)&&(bs&&ls<ts&&rs)){Y=BOTTOM;X=LEFT-B;D=135}

//Bottom right corner hit.

if((bs==rs)&&(bs&&rs<ls&&ts)){Y=BOTTOM;X=RIGHT;D=45}



//Top hit.

if ((ts<ls)&&(ts<rs)&&(ts<bs)){Q=TOP-(Y+B);Y=TOP-B;X=X+Q*Math.cos(D*Math.PI/180);D=HB;ts=0;Q=0}

//Left hit.

if ((ls<ts)&&(ls<rs)&&(ls<bs)){Q=LEFT-(X+B);Y=Y+Q*Math.sin(D*Math.PI/180);X=LEFT-B;D=VB;ls=0;Q=0}

//Bottom hit.

if ((bs<ls)&&(bs<rs)&&(bs<ts)){Q=BOTTOM-Y;Y=BOTTOM;X=X-Q*Math.cos(D*Math.PI/180);D=HB;bs=0;Q=0}

//Right hit.

if ((rs<ts)&&(rs<ls)&&(rs<bs)){Q=RIGHT-X;Y=Y-Q*Math.sin(D*Math.PI/180);X=RIGHT;D=VB;rs=0;Q=0}

}

}

E=(n4)?255:255;

//Edge rebounds!

if(Y<1){Y=2;D=HB}

if(X<1){X=2;D=VB}

if(X+B>E){X=E-B;D=VB}

//Corner rebounds! not necessary but looks nice.

if((Y<1)&&(X<1)){Y=2;X=2;D=45}

if((Y<1)&&(X+B>E)){Y=2;X=E-B;D=135}



//Paddle rebounds.

py=(ie)?temppaddle.pixelTop:parseInt(temppaddle.top);

px=(ie)?temppaddle.pixelLeft:parseInt(temppaddle.left);

if ((Y+B>py)&&(X+B>=px)&&(X<=px+20)){Y=py-B;D=215+Math.random()*45}

if ((Y+B>py)&&(X+B>=px+20)&&(X<=px+40)){Y=py-B;D=280+Math.random()*45}

if (Y+B>py){Y=155;X=128;D=90;ballsleft--}



b=eval(d+a+"ball"+n6r+s);

b.top=Y;

b.left=X;

document.form1.lft.value=blocksleft;

document.form1.bll.value=ballsleft;

if (ballsleft<0){

clearTimeout(t);

document.form1.bll.value='0';

if (n4){

tempinfo.document.write(lose)

tempinfo.document.close();

}

else{

tempinfo.innerHTML=lose;

}

}

tempinfo=eval(d+a+"info"+n6r);

if (blocksleft<=0){

clearTimeout(t);

if (n4){

tempinfo.document.write(win)

tempinfo.document.close();

setTimeout("DownLoad()",1000);

}

else{

tempinfo.innerHTML=win;

setTimeout("DownLoad()",1000);

}

}

}

//-->

</script>

{/codecitation}



Örnek demo için tıklayın >>