کدهای جاوا جالب

پیام در نوار وضعیت آهسته و حرف حرف آمدن

<script language="JavaScript"> <!-- /* Slowly coming together status bar scroller Written by BengalBoy (www.angelfire.com/nt/bengaliboy/index.html) Visit http://javascriptkit.com for this script and more */ //set message: msg = "Welcome to JavaScript Kit!"; timeID = 10; stcnt = 16; wmsg = new Array(33); wmsg[0]=msg; blnk = " "; for (i=1; i<32; i++) { b = blnk.substring(0,i); wmsg[i]=""; for (j=0; j<msg.length; j++) wmsg[i]=wmsg[i]+msg.charAt(j)+b; } function wiper() { if (stcnt > -1) str = wmsg[stcnt]; else str = wmsg[0]; if (stcnt-- < -40) stcnt=31; status = str; clearTimeout(timeID); timeID = setTimeout("wiper()",100); } wiper() // --> </script>

 

تاریخ بروز رسانی وبلاگ ثبت میشود

<script language="JavaScript"> <!-- function getLongDateString() { //method defined on class Date. //Returns a date string of the form: Day DD Month,YYYY //(e.g. Sunday 27 September, 1998) monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December"); dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); dayOfWeek = this.getDay(); day = dayNames[dayOfWeek]; dateOfMonth = this.getDate(); monthNo = this.getMonth(); month = monthNames[monthNo]; year = this.getYear(); if (year < 2000) year = year + 1900; dateStr = day+" "+dateOfMonth+" "+month+", "+year; return dateStr; } //register the method in the class Date Date.prototype.getLongDateString=getLongDateString; function DocDate() { //return the document modification date (excl.time) //as a string DateTimeStr = document.lastModified; secOffset = Date.parse(DateTimeStr); if (secOffset == 0 || secOffset == null) //Opera3.2 dateStr = "Unknown"; else { aDate = new Date(); aDate.setTime(secOffset); //use method defined above datestr = aDate.getLongDateString(); } return dateStr; } document.write("<center> Last Update: "); document.writeln(DocDate(),"</center>"); // --> </script>

 

پیام در نوار وضعیت ثابت

<SCRIPT LANGUAGE="JavaScript"> <!-- // Following COPYRIGHT ©1997 Dennis & Family. All Rights Reserved. function snapIn(jumpSpaces,position) { var msg = "Welcome to My Homepage!"; var out = ""; for (var i=0; i<position; i++) { out += msg.charAt(i) } for (i=1;i<jumpSpaces;i++) { out += " " } out += msg.charAt(position); window.status = out; if (jumpSpaces <= 1) { position++; if (msg.charAt(position) == ' ') { position++ } jumpSpaces = 100-position } else if (jumpSpaces > 3) { jumpSpaces *= .09 } else { jumpSpaces-- } if (position != msg.length) { var cmd = "snapIn(" + jumpSpaces + "," + position + ")"; window.setTimeout(cmd,10); } return true } //--> </SCRIPT>

 

پیام در نوار وضعیت فلاش زدن

<script language="JavaScript"> <!-- /* MjM'S JAVA CODENAME = FLASH This JavaScript Code was written by MjM for Hyperchat UK I am not responsible for any damage caused by my code. This code can be modified as long as the Author's Name is still attached. Email : MjM@hyperchat.co.uk © Copyright 1996 */ var yourwords = "Thank you for visiting my site!"; var speed = 150; var control = 1; function flash() { if (control == 1) { window.status=yourwords; control=0; } else { window.status=""; control=1; } setTimeout("flash();",speed); } // --> </script>

تبلیغ پرشیان بلاگ رو حذف میکنه

<SCRIPT LANGUAGE="JScript"> function removeAdv() { try { var divtags=document.all.tags('div') for(i=0;i<divtags.length;i++) if((divtags[i].style.zIndex==2000)|(divtags[i].style.zIndex==2001)) divtags[i].innerHTML='<table width="100%" align="right"><tr><td><font face="Tahoma" size="2" color="gray">Nazanin Studio</font></td></tr></table>' if((divtags[i].style.zIndex==1000)|(divtags[i].style.zIndex==1001)) divtags[i].innerHTML='<table width="100%" align="right"><tr><td><font face="Tahoma" size="2" color="gray">Nazanin Studio</font></td></tr></table>' } catch (e) {} } setInterval('removeAdv()',1000); </script>

با عث تغییر رنگ پس زمینه با یک دکمه میشه

<HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function backcolor(form) { temp = "" for (var i = 0; i < 16; i++) { temp = form.color[i].value if (form.color[i].checked){ document.bgColor = temp } } } function randombackground() { document.bgColor = getColor() } function getColor(){ currentdate = new Date() backgroundcolor = currentdate.getSeconds() if (backgroundcolor > 44) backgroundcolor = backgroundcolor - 45 else if (backgroundcolor > 29) backgroundcolor = backgroundcolor - 30 else if (backgroundcolor > 15) backgroundcolor = backgroundcolor - 16 if (backgroundcolor == 0 ) return "olive"; else if (backgroundcolor == 1 ) return "teal"; else if (backgroundcolor == 2 ) return "red"; else if (backgroundcolor == 3 ) return "blue"; else if (backgroundcolor == 4 ) return "maroon"; else if (backgroundcolor == 5 ) return "navy"; else if (backgroundcolor == 6 ) return "lime"; else if (backgroundcolor == 7 ) return "fuschia"; else if (backgroundcolor == 8 ) return "green"; else if (backgroundcolor == 9 ) return "purple"; else if (backgroundcolor == 10 ) return "gray"; else if (backgroundcolor == 11 ) return "yellow"; else if (backgroundcolor == 12 ) return "aqua"; else if (backgroundcolor == 13 ) return "black"; else if (backgroundcolor == 14 ) return "white"; else if (backgroundcolor == 15 ) return "silver"; } // End --> </SCRIPT> <!-- STEP TWO: Put this form in the BODY of the HTML document --> <BODY> <CENTER> <FORM> <input type="button" value="Get Another Random Background" onClick="randombackground()"> </FORM> </CENTER> <!-- Script Size: 2.00 KB -->

 

تنظیم رنگ توسط خود کاربر

<body> <script language="Javascript"> <!-- // please keep these lines on when you copy the source // made by: Amir - http://www.IranJavaScript.com function backbs(clr) { document.bgColor = clr } //--> </script> <form> <input type="button" value="zard" onclick="backbs('yellow')"> <input type="button" value="khaki" onclick="backbs('khaki')"> <input type="button" value="sefid" onclick="backbs('white')"> <input type="button" value="toosi" onclick="backbs('gray')"> <input type="button" value="meshki" onclick="backbs('black')"> <input type="button" value="soorati" onclick="backbs('pink')"> <input type="button" value="abi" onclick="backbs('blue')"> <input type="button" value="sabz" onclick="backbs('Green')"> <input type="button" value="noghre ei" onclick="backbs('silver')"> <input type="button" value="sabz tire" onclick="backbs('teal')"> <input type="button" value="limooei" onclick="backbs('lime')"> <input type="button" value="abi nafti" onclick="backbs('navy')"> <input type="button" value="ghermez" onclick="backbs('red')"> <input type="button" value="narenji" onclick="backbs('orange')"> <input type="button" value="ghahve ei" onclick="backbs('olive')"> </form> </script> </body>

 

تنظیم یک فیلد بر اساس فیلدهای دیگر

<html> <head> <script language="javascript" type="text/javascript"> function SubmitIt(carForm) { doorOption = -1 if (carForm.DoorCt[doorOption].value == "fourDoor" && carForm.sunroof.checked) { alert("The sunroof is only available on the two door model") return false } return true } function doorSet(sunroofField) { if (sunroofField.checked) { for (i=0; i<document.myForm.DoorCt.length; i++) { if (document.myForm.DoorCt[i].value == "twoDoor") { document.myForm.DoorCt[i].checked = true } } } } </script> </head> <body> <h2> Car Picker<p> <form onSubmit="return SubmitIt(this)" action="ok.asp" name="myForm"> Doors: <br> <input type="CHECKBOX" name="sunroof" value="YES" onClick="doorSet(this)">Sunroof(two door only) <br><br> <input type="radio" value="twoDoor" name="DoorCt">two <input type="radio" value="fourDoor" name="DoorCt">Four <br> <input type="Submit" value="Submit"> </form></h2> </body> </html>

تیک زدن یا برداشتن آیتمها

<HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Modified By: Steve Robison, Jr. (stevejr@ce.net) --> <!-- Begin var checkflag = "false"; function check(field) { if (checkflag == "false") { for (i = 0; i < field.length; i++) { field[i].checked = true;} checkflag = "true"; return "Uncheck All"; } else { for (i = 0; i < field.length; i++) { field[i].checked = false; } checkflag = "false"; return "Check All"; } } // End --> </script> </HEAD> <!-- CONTINUE --> <BODY> <center> <form name=myform action="" method=post> <table> <tr><td> <b>Your Favorite Scripts & Languages</b><br> <input type=checkbox name=list value="1">Java<br> <input type=checkbox name=list value="2">JavaScript<br> <input type=checkbox name=list value="3">ASP<br> <input type=checkbox name=list value="4">HTML<br> <input type=checkbox name=list value="5">SQL<br> <br> <input type=button value="Check All" onClick="this.value=check(this.form.list)"> </td></tr> </table> </form> </center> <!-- END Script Size: 1.47 KB -->

شما چقدر سن دارید

<HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Original: Glub, Un-Inc. --> <!-- Begin var mm = prompt('What month were you born in?','1-12'); var bday = prompt('What day were you born on?','1-31'); var byear = prompt('What year were you born in?','1975'); var year = new Date(); var year2 = year.getYear(); var year3 = (year < 2000) ? year2 + 1900 : year2; thedate = new Date(); mm2 = thedate.getMonth() + 1; dd2 = thedate.getDate(); yy2 = thedate.getYear(); if (yy2 < 100) yy2 += 1900 yourage = yy2 - byear; if (mm2 < mm) yourage--; if ((mm2 == mm) && (dd2 < bday)) yourage--; TMonth = new Array( 'January','February','March', 'April','May','June','July', 'August','September','October', 'November','December' ); CurMonth = mm - 1; bmonth = TMonth[CurMonth]; var age2 = yourage + 1; var timerID; var timerRunning = false; var today = new Date(); var startday = new Date(); var enday = new Date(); var secPerDay = 0; var minPerDay = 0; var hourPerDay = 0; var secsLeft = 0; var secsRound = 0; var secsRemain = 0; var minLeft = 0; var minRound = 0; var minRemain = 0; var timeRemain = 0; function stopclock() { if(timerRunning) clearTimeout(timerID); timerRunning = false; } function startclock() { stopclock(); showtime(); showtime1(); } function showtime() { today = new Date(); enday = new Date(""+bmonth+", "+bday+" "+year3+" 00:00"); enday.setYear(""+year3+""); secsPerDay = 1000 ; minPerDay = 60 * 1000 ; hoursPerDay = 60 * 60 * 1000; PerDay = 24 * 60 * 60 * 1000; secsLeft = (enday.getTime() - today.getTime()) / minPerDay; secsRound = Math.round(secsLeft); secsRemain = secsLeft - secsRound; secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain = (secsLeft - secsRound) * 60; secsRemain = Math.round(secsRemain); minLeft = ((enday.getTime() - today.getTime()) / hoursPerDay); minRound = Math.round(minLeft); minRemain = minLeft - minRound; minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60) : minRemain = ((minLeft - minRound) * 60); minRemain = Math.round(minRemain - 0.495); hoursLeft = ((enday.getTime() - today.getTime()) / PerDay); hoursRound = Math.round(hoursLeft); hoursRemain = hoursLeft - hoursRound; hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft) * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24); hoursRemain = Math.round(hoursRemain - 0.5); daysLeft = ((enday.getTime() - today.getTime()) / PerDay); daysLeft = (daysLeft - 0.5); daysRound = Math.round(daysLeft); daysRemain = daysRound; if (daysRemain == 1) day_rem = " day, " else day_rem = " days, " if (hoursRemain == 1) hour_rem = " hour, " else hour_rem = " hours, " if (minRemain == 1) min_rem = " minute, " else min_rem = " minutes, " if (secsRemain == 1) sec_rem = " second" else sec_rem = " seconds" timeRemain = daysRemain + day_rem + hoursRemain + hour_rem + minRemain + min_rem + secsRemain + sec_rem; document.down.face.value = timeRemain; timerID = setTimeout("showtime()",1000); timerRunning = true; if (daysRemain < 0) year3 = year3 + 1 } function showtime1() { startday = new Date(""+bmonth+" "+bday+", "+byear+" 00:00 EDT"); startday.setYear(""+byear+""); today = new Date(); secsPerDay = 1000 ; minPerDay = 60 * 1000 ; hoursPerDay = 60 * 60 * 1000; PerDay = 24 * 60 * 60 * 1000; secsLeft = (today.getTime() - startday.getTime()) / minPerDay; secsRound = Math.round(secsLeft); secsRemain = secsLeft - secsRound; secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain = (secsLeft - secsRound) * 60; secsRemain = Math.round(secsRemain); minLeft = ((today.getTime() - startday.getTime()) / hoursPerDay); minRound = Math.round(minLeft); minRemain = minLeft - minRound; minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60) : minRemain = ((minLeft - minRound) * 60); minRemain = Math.round(minRemain - 0.495); hoursLeft = ((today.getTime() - startday.getTime()) / PerDay); hoursRound = Math.round(hoursLeft); hoursRemain = hoursLeft - hoursRound; hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft) * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24); hoursRemain = Math.round(hoursRemain - 0.5); daysLeft = ((today.getTime() - startday.getTime()) / PerDay); daysLeft = (daysLeft - 0.5); daysRound = Math.round(daysLeft); daysRemain = daysRound; if (daysRemain == 1) day_rem = " day, " else day_rem = " days, " if (hoursRemain == 1) hour_rem = " hour, " else hour_rem = " hours, " if (minRemain == 1) min_rem = " minute, " else min_rem = " minutes, " if (secsRemain == 1) sec_rem = " second" else sec_rem = " seconds" timeRemain = daysRemain + day_rem + hoursRemain + hour_rem + minRemain + min_rem + secsRemain + sec_rem; document.up.face.value = timeRemain; timerID = setTimeout("showtime1()",1000); timerRunning = true; } // End --> </script> </HEAD> <!-- CONTINUE --> <BODY OnLoad="startclock()"> <!-- CONTINUE --> <center> <form name="down" onSubmit="0"> <script Language="JavaScript"> document.write("<b>I was born "+bmonth+" "+bday+", "+byear+". ("+mm+"/"+bday+"/"+byear+")</b>"); document.write("<br><br>I am "+yourage+" years old, and will turn "+age2+" in:"); </script> <br> <input type="text" name="face" size="47" value="A browser supporting JavaScript 1.1+ is needed."> </form> <p> <br> <form name="up" onSubmit="1"> I've been alive for...<br> <input type="text" name="face" size="47" value="A browser supporting JavaScript 1.1+ is needed."> </form> </center> <!-- END Script Size: 6.04 KB -->

حرکت سریع متن در نوار وضعیت

<html> <head> <script language="JavaScript"> <!-- Hide the script from old browsers -- function scrollit(seed) { var m1 = " welcome to my weblog "; var msg=m1; var out = " "; var c = 0; if (seed > 100) { seed--; var cmd="scrollit(" + seed + ")"; timerTwo=window.setTimeout(cmd,7); } else if (seed <= 100 && seed > 0) { for (c=0 ; c < seed ; c++) { out+=" "; } out+=msg; seed--; var cmd="scrollit(" + seed + ")"; window.status=out; timerTwo=window.setTimeout(cmd,7); } else if (seed <= 0) { if (-seed < msg.length) { out+=msg.substring(-seed,msg.length); seed--; var cmd="scrollit(" + seed + ")"; window.status=out; timerTwo=window.setTimeout(cmd,7); } else { window.status=" "; timerTwo=window.setTimeout("scrollit(100)",75); } } } // --End Hiding Here --> </script> </head> <body BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#000080" ALINK="#000080" onLoad="timerONE=window.setTimeout('scrollit(100)',500)"> </body> </html>

درج صفحه در قسمت علاقه مندیهای

<A href="javascript:window.external.AddFavorite('http://YourLink.com','Your WebPage Title')">add To Favourites</a>

درایو سی بازدید کننده دیده میشه

<body onload="window.alert('salam khosh omadi ') " > </body>

این کد باعث میشه وبلاگ شما صفحه اصلی بازدید کننده بشه

<A href="javascript:history.go(0)" onClick="javascript:this.style.behavior='url(#default#homepage)';this.setHomePage ('URL');" TARGET="_self">این صفحه را خانگی صفحه ی خانگی خود کنید</A></body> </html>

رنگ وبلاگ به آرومی عوض

<script language="JavaScript"> <!-- //you can assign the initial color of the background here r=255; g=255; b=255; flag=0; t=new Array; o=new Array; d=new Array; function hex(a,c) { t[a]=Math.floor(c/16) o[a]=c%16 switch (t[a]) { case 10: t[a]='A'; break; case 11: t[a]='B'; break; case 12: t[a]='C'; break; case 13: t[a]='D'; break; case 14: t[a]='E'; break; case 15: t[a]='F'; break; default: break; } switch (o[a]) { case 10: o[a]='A'; break; case 11: o[a]='B'; break; case 12: o[a]='C'; break; case 13: o[a]='D'; break; case 14: o[a]='E'; break; case 15: o[a]='F'; break; default: break; } } function ran(a,c) { if ((Math.random()>2/3||c==0)&&c<255) { c++ d[a]=2; } else { if ((Math.random()<=1/2||c==255)&&c>0) { c-- d[a]=1; } else d[a]=0; } return c } function do_it(a,c) { if ((d[a]==2&&c<255)||c==0) { c++ d[a]=2 } else if ((d[a]==1&&c>0)||c==255) { c--; d[a]=1; } if (a==3) { if (d[1]==0&&d[2]==0&&d[3]==0) flag=1 } return c } function disco() { if (flag==0) { r=ran(1, r); g=ran(2, g); b=ran(3, b); hex(1,r) hex(2,g) hex(3,b) document.bgColor="#"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3] flag=50 } else { r=do_it(1, r) g=do_it(2,g) b=do_it(3,b) hex(1,r) hex(2,g) hex(3,b) document.bgColor="#"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3] flag-- } if (document.all) setTimeout('disco()',50) } //--> </script> <body onload="disco()">

غیر فعال کردن کلی نوار وضعیت

<script language="javascript"> <script> //Hide status bar msg II script- by javascriptkit.com //Visit JavaScript Kit (http://javascriptkit.com) for script //Credit must stay intact for use function hidestatus(){ window.status='' return true } if (document.layers) document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT) document.onmouseover=hidestatus document.onmouseout=hidestatus </script> //Display Mouse coordinates- By Kous (kous@ihateclowns.com) //Visit http://javascriptkit.com for this script and more var where = ""; // which link function checkwhere(e) { if (document.layers){ xCoord = e.x; yCoord = e.y; } else if (document.all){ xCoord = event.clientX; yCoord = event.clientY; } else if (document.getElementById){ xCoord = e.clientX; yCoord = e.clientY; } self.status = "X= "+ xCoord + " Y= " + yCoord; } document.onmousemove = checkwhere; if(document.captureEvents) {document.captureEvents(Event.MOUSEMOVE);} </script>

غیر فعال کردن نوار تصویر در اینترنت اکسپلورر

<META HTTP-EQUIV="imagetoolbar" CONTENT="no">

کد موتور جستجو گر

<table BORDER="0" WIDTH="222" HEIGHT="18"> <tr> <td WIDTH="214" HEIGHT="10"> <form NAME="search" ID="search" ACTION="http://search.msn.com/results.asp" METHOD="get"> <p><a HREF="http://www.msn.com"> <img SRC="http://go.msn.com/AG/E/0.asp" width="61" height="33" BORDER="0" ALT="Go to msn.com"></a><font FACE="arial" SIZE="2"><strong>Search <font COLOR="#808080">the Web for:</font></strong></font><br> <input TYPE="text" ID="q" SIZE="18" MAXLENGTH="251" NAME="q" VCARD_NAME="SearchText"><input TYPE="submit" VALUE="Search" NAME="B1"><input TYPE="hidden" NAME="FORM" VALUE="FRNT"><input TYPE="hidden" NAME="un" VALUE="doc"><input TYPE="hidden" NAME="v" VALUE="1"></p> </form> </td> </tr> <tr> <td WIDTH="214" HEIGHT="21" VALIGN="bottom"> <p ALIGN="center"><font SIZE="1" FACE="arial"> <a HREF="http://search.msn.com/advanced.asp?MT=&RS=CHECKED&Form=FRNT">Use Advanced Search</a></font></td> </tr> </table> <p> </p> </body> </html>

 

گزاشتن بازی ایکس1 در وبلاگ

<html> <head> <body> <script> var _url = document.location.toString().split("?"); var _parm = _url[1]?_url[1]:""; var _P0n = ""; var _P0v = 0; var _P1n = ""; var _P1v = 0; if (_parm != "") { _P0n=_parm.split("&")[0].split("=")[0].toLowerCase(); _P0v=parseInt(_parm.split("&")[0].split("=")[1]); if(_parm.split("&")[1]) { _P1n = _parm.split("&")[1].split("=")[0].toLowerCase(); _P1v = parseInt(_parm.split("&")[1].split("=")[1]); } else { _P1n =""; } } else { _P0n=""; _P1n=""; } var MATRIX_SIZE = 3; var AMOUNT_TO_WIN = 4; var PARAM_SIZE = "size".toLowerCase(); var PARAM_WIN = "win".toLowerCase(); if (_P0n==PARAM_SIZE) {MATRIX_SIZE=_P0v;} if (_P1n==PARAM_SIZE) {MATRIX_SIZE=_P1v;} if (_P0n==PARAM_WIN) {AMOUNT_TO_WIN=_P0v;} if (_P1n==PARAM_WIN) {AMOUNT_TO_WIN=_P1v;} ////////////////////////////// if(MATRIX_SIZE<3)MATRIX_SIZE=3; if(MATRIX_SIZE>10)MATRIX_SIZE=10; if(AMOUNT_TO_WIN>MATRIX_SIZE)AMOUNT_TO_WIN=MATRIX_SIZE; if(AMOUNT_TO_WIN<3)AMOUNT_TO_WIN=3; document.write("<BR>"+AMOUNT_TO_WIN+" in a row wins!<BR>"); var tbo = ''; tbo += '<form name=table1>'; tbo += '<table>'; for (var i=0;i<MATRIX_SIZE;i++) { tbo += '<TR>'; for(var j=0;j<MATRIX_SIZE;j++) { var _c = parseInt(i)*parseInt(MATRIX_SIZE)+parseInt(j); tbo += '<td><input name=s'+_c+' type=text size=1 value=" " onfocus="clicked(table1.s'+_c+');blur()"></td>'; } tbo += '</tr>'; } tbo += '</table>'; tbo += '<table><tr><td>Restart Game with: <input type=button value="Player is X" onclick=setPlayers("X","O")></td>'; tbo += '<td><input type=button value="Computer is X" onclick=setPlayers("O","X")></td></tr>'; tbo += '<tr><td>Player is: <input name=pis type=text size=1 value="X" onfocus=blur()></td>'; tbo += '<td>Computer is: <input name=cis type=text size=1 value="O" onfocus=blur()></td></tr>'; tbo += '</table>'; tbo += '<table><tr><td>Won: <input type=text value="0" name=gameswon size=2></td>'; tbo += '<td>Ties: <input type=text value="0" name=gamestied size=2></td>'; tbo += '<td>Lost: <input type=text value="0" name=gameslost size=2></td></tr></table>'; tbo += 'Set Matrix Size: '; var XX=""; for(var i=3;i<11;i++) { if(i==MATRIX_SIZE) { tbo += ' '+i+'x'+j+' '; } else { tbo += '<input type=button value="'+i+'x'+i+'"'; XX =_url[0]+"?"+PARAM_SIZE+'='+i+"&"+PARAM_WIN+'='+AMOUNT_TO_WIN; tbo += ' onclick="document.location=\''+XX+'\'"> '; } } tbo += '<BR>Amount In a Row Wins: '; for(var i=3;i<11;i++) { if(i==AMOUNT_TO_WIN) { tbo += ' '+i+' '; } else { tbo += '<input type=button value='+i+' '; XX = _url[0]+"?"+PARAM_SIZE+'='+MATRIX_SIZE+'&'+PARAM_WIN+'='+i; tbo += ' onclick="document.location=\''+XX+'\'"> '; } } tbo += '</form>'; document.write(tbo); ///////////////////////////////////////////// var PLAYER="X"; var COMPUTER="O"; var BLANK=" "; var ROWS = new Array(); var COLS = new Array(); var DIAG = new Array(); DIAG[0]=new Array(); DIAG[1]=new Array(); for(var _i=0;_i<MATRIX_SIZE;_i++) { DIAG[0][_i]=_i*MATRIX_SIZE+_i; DIAG[1][_i]=(MATRIX_SIZE-1)*(_i+1); } for (var i=1;i<=(MATRIX_SIZE-AMOUNT_TO_WIN);i++) { var n=2+((i-1)*4); DIAG[n+0]=new Array(); DIAG[n+1]=new Array(); DIAG[n+2]=new Array(); DIAG[n+3]=new Array(); for (var j=1;j<=(MATRIX_SIZE-i);j++) { DIAG[n+0][j-1]=(MATRIX_SIZE+1)*(j-1)+i; DIAG[n+1][j-1]=(MATRIX_SIZE+1)*(j-1)+(i*MATRIX_SIZE); DIAG[n+2][j-1]=(MATRIX_SIZE-1)*(j)-i; DIAG[n+3][j-1]=DIAG[n+2][j-1]+(MATRIX_SIZE+1)*(i); } } for(var i=0;i<MATRIX_SIZE;i++) { ROWS[i]=new Array(); COLS[i]=new Array(); for (var j=0;j<MATRIX_SIZE;j++) { ROWS[i][j]=i*MATRIX_SIZE+j; COLS[i][j]=i+j*MATRIX_SIZE; } } ////////////////////////////// function setPlayers(_p,_c) { PLAYER=document.table1.pis.value=_p; COMPUTER=document.table1.cis.value=_c; resetBoard(); if(COMPUTER=="X") { computerMove(); } } var GAMEOVER = false; function clicked(_s) { if(_s.value!=BLANK || GAMEOVER) return; _s.value=PLAYER; postMoveLogic(); compute

/ 1 نظر / 70 بازدید
هادی

سلام. ممنون از این همه جاوا.وبلاگ جالب و باحالی داری . بهت تبریک میگم. من که مشتری شدم. اگه دوست داشتی به به وبلاگ من هم سری بزن و اگه باز دوست داشتی تبادل لینک کنیم. من رو به عنوان" بلند اشیان" به لینکدونیت اضافه کن تا منهم تو رو اضاف کنم ممنون. موفق باشی.