/
nameprompt.js
executable file
·92 lines (85 loc) · 2.6 KB
/
nameprompt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!-- Filename: cookie.js -->
<!-- Created December 3, 2003 by Leah Culver -->
<!-- Last modified 12/18/2003 by Leah Culver -->
//This div is supposed to look like a prompt box
//to prompt a user for their name after they have
//a high score.
document.write("<div id='highScoreDialogue'")
document.write("style='position:absolute;")
document.write("visibility: hidden;")
document.write("background-color:#ffffff; layer-background-color:#ffffff;'>")
document.write("<table width=300><tr><td class=border>")
document.write("<table width=100%><tr><td class=input align=center>")
document.write("<br>Congratulations!")
if(klondike)
document.write("<br>You have a high score.")
else if(freecell)
document.write("<br>You have a fast time.")
document.write("<br><br>Please enter your name:")
document.write("<br><input type=text id='inputName' size='14' maxlength=8 value ='' align=right style='color: #466782; font-family: verdana; font-weight: bold; font-size:12px'>")
document.write("<br><br><img name='ok' value='ok' onClick='updateRecord()' class='activeLink' src='buttons/ok.gif'>")
document.write("   <img name='cancel' value='cancel' onClick='cancelRecord()' class='activeLink' src='buttons/cancel.gif'>")
document.write("</td></tr></table></td></tr></table>")
document.write("</div>")
function cancelRecord()
{
if(klondike)
window.location.replace("solitaire.html")
else if(freecell)
window.location.replace("freecell.html")
}
function updateRecord()
{
nameField = document.getElementById("inputName")
playerName = nameField.value
if(klondike)
stringValue = score
else if(freecell)
stringValue = mins + ":" + secs
if(playerName == "")
{
r = Math.random()*3
n = Math.ceil(r)
if(n == 1)
playerName = "Dude"
else if(n == 2)
playerName = "No Name"
else
playerName = "Somebody"
}
if(index == 0) //top value
{
cn += playerName + "=" + stringValue + "&"
}
else
{
for(i=0; i < index; i++)
{
cn += players[i] + "=" + records[i] + "&"
}
}
if(index == records.length - 1) //last high score
{cn += playerName + "=" + stringValue}
else
{
if(index != 0)
{cn += playerName + "=" + stringValue + "&"}
for(i=index+1; i < records.length; i++)
{
if(i == records.length - 1)//last value in list
{cn += players[i-1] + "=" + records[i-1]}
else
{cn += players[i-1] + "=" + records[i-1] + "&"}
}
}
if(klondike)
{
setCookie("kscore", cn)
window.location.replace("solitaire.html")
}
else if(freecell)
{
setCookie("ftime", cn)
window.location.replace("freecell.html")
}
}