HRA: HANGMAN (OBESENEC)

ID
Nazov / Name:
Popis / Description:
Dlzka / Length:
Testovane pod / Tested under:

 

159
p159.html / p159.zip
Hadanie slov po pismenach.
34429b
NN 4.04, IE 4.0

UKAZKA / CLICK HERE

Zdrojovy tvar / Source code:

<HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- function getCookie (name) { var dcookie = document.cookie; var cname = name + "="; var clen = dcookie.length; var cbegin = 0; while (cbegin < clen) { var vbegin = cbegin + cname.length; if (dcookie.substring(cbegin, vbegin) == cname) { var vend = dcookie.indexOf (";", vbegin); if (vend == -1) vend = clen; return unescape(dcookie.substring(vbegin, vend)); } cbegin = dcookie.indexOf(" ", cbegin) + 1; if (cbegin == 0) break; } return null; } function setCookie (name, value, expires) { if (!expires) expires = new Date(); document.cookie = name + "=" + escape (value) + "; expires=" + expires.toGMTString() + "; path=/"; } function delCookie (name) { var expireNow = new Date(); document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/"; } var Alphabet = new initAlphaArray() var NumOfWords = 42; var SaveData = ""; var ImageNum = ""; var LettersSelected = ""; var RandomWord = ""; var DisplayWord = ""; var position = 0; var word = new WordList(); var expdate = new Date(); var RandomNumber = (expdate.getSeconds())%NumOfWords; function initAlphaArray() { this.length = 26 this[0] = "A" this[1] = "B" this[2] = "C" this[3] = "D" this[4] = "E" this[5] = "F" this[6] = "G" this[7] = "H" this[8] = "I" this[9] = "J" this[10] = "K" this[11] = "L" this[12] = "M" this[13] = "N" this[14] = "O" this[15] = "P" this[16] = "Q" this[17] = "R" this[18] = "S" this[19] = "T" this[20] = "U" this[21] = "V" this[22] = "W" this[23] = "X" this[24] = "Y" this[25] = "Z" } function WordList() { this.length = NumOfWords; this[0] = "SLOVENSKO"; this[1] = "CESKA REPUBLIKA"; this[2] = "AUSTRALIA"; this[3] = "KANADA"; this[4] = "SPOJENE STATY AMERICKE"; this[5] = "RAKUSKO"; this[6] = "FRANCUZSKO"; this[7] = "NEMECKO"; this[8] = "POLSKO"; this[9] = "UKRAJINA"; this[10] = "SVEDSKO"; this[11] = "HOLANDSKO"; this[12] = "SPANIELSKO"; this[13] = "IRAK"; this[14] = "IRAN"; this[15] = "TALIANSKO"; this[16] = "TURECKO"; this[17] = "FINSKO"; this[18] = "BULHARSKO"; this[19] = "RUMUNSKO"; this[20] = "CHORVATSKO"; this[21] = "ISLAND"; this[22] = "MADARSKO"; this[23] = "VATIKAN"; this[24] = "BRAZILIA"; this[25] = "PORTUGALSKO"; this[26] = "CINA"; this[27] = "JAPONSKO"; this[28] = "NOVY ZELAND"; this[29] = "KOREA"; this[30] = "MONGOLSKO"; this[31] = "HONG KONG"; this[32] = "VELKA BRITANIA"; this[33] = "IRSKO"; this[34] = "NORSKO"; this[35] = "SVAJCIARSKO"; this[36] = "KUBA"; this[37] = "ALBANSKO"; this[38] = "GRONSKO"; this[39] = "EGYPT"; this[40] = "PAKISTAN"; this[41] = "MALTA"; } function availableLetters(i) { if (LettersSelected.charAt(i)==Alphabet[i]) document.write('<TD ALIGN=CENTER VALIGN=CENTER WIDTH=20 HEIGHT=12>' + '<B><A HREF="javascript:LoadNextPage('+i+',\''+Alphabet[i]+'\')">'+Alphabet[i]+'</A></B></TD>'); else document.write('<TD ALIGN=CENTER VALIGN=CENTER WIDTH=20 HEIGHT=12> </TD>'); } function LoadNextPage(selected,letter) { if (RandomWord.indexOf(letter) == -1) { if (ImageNum == "A") ImageNum = "B"; else if (ImageNum =="B") ImageNum = "C"; else if (ImageNum =="C") ImageNum = "D"; else if (ImageNum =="D") ImageNum = "E"; else if (ImageNum =="E") ImageNum = "F"; else if (ImageNum =="F") ImageNum = "G"; else if (ImageNum =="G") ImageNum = "H"; else if (ImageNum =="H") ImageNum = "I"; else if (ImageNum =="I") ImageNum = "J"; else ImageNum = "A"; } var j=0; var HoldLettersSelected = LettersSelected; LettersSelected = ""; if (selected == 0) { for (j=1; j<=25; j++) { LettersSelected += HoldLettersSelected.charAt(j); } LettersSelected = "^" + LettersSelected; } else if (selected == 25) { for (j=0; j<=24; j++) { LettersSelected += HoldLettersSelected.charAt(j); } LettersSelected += "^"; } else { for (j=0; j<selected; j++) { LettersSelected += HoldLettersSelected.charAt(j); } LettersSelected += "^"; for (j=selected+1; j<=25; j++) { LettersSelected += HoldLettersSelected.charAt(j); } } SaveData = ImageNum + LettersSelected + RandomWord + "*"; setCookie("_HangMan", SaveData, expdate); history.go(0); } expdate.setTime (expdate.getTime() + (1000*60*60*24*10)); if(getCookie("_HangMan") == null) { ImageNum = "A"; LettersSelected = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; RandomWord = word[RandomNumber]; SaveData = ImageNum + LettersSelected + RandomWord + "*"; setCookie("_HangMan", SaveData, expdate); } else { SaveData = getCookie("_HangMan"); ImageNum = SaveData.charAt(0); for (position=1; position<=26; position++) { LettersSelected += SaveData.charAt(position); } for (position=27; position<SaveData.indexOf("*"); position++) { RandomWord += SaveData.charAt(position); } } DisplayWord = ""; for (i=0; i<RandomWord.length; i++) { if (RandomWord.charAt(i) == ' ') { DisplayWord += " "; } else { MatchFound = false; for (j=0; j<=25; j++) { if ((LettersSelected.charAt(j) == "^") && (RandomWord.charAt(i) == Alphabet[j])) { DisplayWord += RandomWord.charAt(i); MatchFound = true; } } if (!MatchFound) DisplayWord += "-"; } } document.write('<TITLE>JavaScript DESTINATION - P159</TITLE>'); document.write('<BODY BGCOLOR="#FFFFFF"'); document.write('<CENTER><TABLE BORDER=0 BGCOLOR="#FFFFF0"'+' WIDTH=60% CELLSPACING=0>'); document.write('<TR><TD>'); document.write('<CENTER><FONT SIZE=6>JavaScript Hangman</FONT>'); document.write('<BR><B>'); document.write('<FONT COLOR=RED SIZE=4>KRAJINY SVETA</FONT>'); document.write('</B></CENTER>'); document.write('</TD></TR>'); document.write('</TABLE></CENTER><BR>'); document.write('<IMG HEIGHT=280 WIDTH=306 ALIGN=RIGHT ALT="Hangman"'+'SRC="hangman'+ImageNum+'.gif" >'); document.write('<CENTER>'); if (ImageNum == "J") { document.write('<FONT COLOR=RED SIZE=4>Prehral si!<BR>Odpoved: "' + RandomWord + '"</FONT>'); } else if (RandomWord == DisplayWord) { document.write('<FONT COLOR=RED SIZE=8>Vyhral si!</FONT>'); } else { document.write('<BR><FONT SIZE=4>Vyber si jedno z moznych pismen:</FONT>'); document.write('<TABLE>'); document.write('<TR>'); for (i=0; i<13; i++) availableLetters(i); document.write('</TR>'); document.write('<TR>'); for (i=13; i<26; i++) availableLetters(i); document.write('</TR>'); document.write('</TABLE>'); } document.write('<BR>'); document.write('<BR>'); document.write('<FONT SIZE=9><TT>'); document.write(DisplayWord); document.write('</TT></FONT>'); document.write('<FORM>'); document.write('<INPUT TYPE="button" VALUE="Vynuluj hru"'+ 'ONCLICK="delCookie(\'_HangMan\');history.go(0);">'); document.write('<INPUT TYPE="button" VALUE="Skonc hru"'+ 'ONCLICK="delCookie(\'_HangMan\');history.go(-1);">'); document.write('</FORM>'); document.write('</CENTER>'); // --> </SCRIPT> </HEAD> </BODY> </HTML>
[ Navrat / BACK ]