-
Notifications
You must be signed in to change notification settings - Fork 0
/
codeW4Stop.js
193 lines (164 loc) · 6.08 KB
/
codeW4Stop.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
function countdownTimerRun() {
var currTime = 10;
//timer for 10 sec left
setTimeout(function () {
//code goes here for first timer
document.getElementById("countdownTimer").innerHTML = currTime;
currTime = currTime - 1;
}, 1000);
//timer for 9 sec left
setTimeout(function () {
//code goes here for timer
document.getElementById("countdownTimer").innerHTML = currTime;
currTime = currTime - 1;
}, 2000);
//timer for 8 sec left
setTimeout(function () {
//code goes here for timer
document.getElementById("countdownTimer").innerHTML = currTime;
currTime = currTime - 1;
}, 3000);
//timer for 7 sec left
setTimeout(function () {
//code goes here for timer
document.getElementById("countdownTimer").innerHTML = currTime;
currTime = currTime - 1;
}, 4000);
//timer for 6 sec left
setTimeout(function () {
//code goes here for timer
document.getElementById("countdownTimer").innerHTML = currTime;
currTime = currTime - 1;
}, 5000);
//timer for 5 sec left
setTimeout(function () {
//code goes here for timer
document.getElementById("countdownTimer").innerHTML = currTime;
currTime = currTime - 1;
}, 6000);
//timer for 4 sec left
setTimeout(function () {
//code goes here for timer
document.getElementById("countdownTimer").innerHTML = currTime;
currTime = currTime - 1;
}, 7000);
//timer for 3 sec left
setTimeout(function () {
//code goes here for timer
document.getElementById("countdownTimer").innerHTML = currTime;
currTime = currTime - 1;
}, 8000);
//timer for 2 sec left
setTimeout(function () {
//code goes here for timer
document.getElementById("countdownTimer").innerHTML = currTime;
currTime = currTime - 1;
}, 9000);
//timer for 1 sec left
setTimeout(function () {
//code goes here for timer
document.getElementById("countdownTimer").innerHTML = currTime;
currTime = currTime - 1;
}, 10000);
//timer for Blastoff
setTimeout(function () {
//code goes here for timer
document.getElementById("countdownTimer").innerHTML = "Blastoff!!!";
}, 11000);
}
function play() {
var die1 = Math.ceil(Math.random() * 6);
var die2 = Math.ceil(Math.random() * 6);
var sum = die1 + die2;
document.getElementById("die1Res").innerHTML = "die1 = " + die1;
document.getElementById("die2Res").innerHTML = "die2 = " + die2;
document.getElementById("sumRes").innerHTML = "sum = " + sum;
if (sum == 7 || sum == 11) {
document.getElementById("finalRes").innerHTML = "CRAPS - you lose";
}
else if (die1 == die2 && die1 % 2 == 0) {
document.getElementById("finalRes").innerHTML = "DOUBLES - you win";
} else {
document.getElementById("finalRes").innerHTML = "You did not win or lose, please try again.";
}
}
function funWithLoops() {
for (var i = 0; i <= 50; i = i + 5) {
document.write("The count is " + i + "<br>");
}
}
function betterCountdown() {
var currTime = 10;
for (var i = 1; i <= 11; i++) {
if (i == 11) {
setTimeout(function () {
//code goes here for timer
document.getElementById("countdownTimer").innerHTML = "Blastoff!!!";
}, 1000 * i);
} else if (i > 6) {
setTimeout(function () {
document.getElementById("countdownTimer").innerHTML =
"Warning Less than ½ way to launch, time left = " + currTime;
currTime = currTime - 1;
}, 1000 * i);
} else {
setTimeout(function () {
document.getElementById("countdownTimer").innerHTML = "the time left is " + currTime;
currTime = currTime - 1;
}, 1000 * i);
}
}
}
function start() {
document.getElementById("startButton").disabled = true;
document.getElementById("stopButton").disabled = false;
document.getElementById("data").rows["seconds"].innerHTML = "Reading Data...";
document.getElementById("data").rows["longitude"].innerHTML = "Start pushed...";
}
function stop() {
document.getElementById("data").rows["seconds"].innerHTML = "<td>Time Elapsed:</td><td>15 seconds</td>";
document.getElementById("data").rows["longitude"].innerHTML = "<td>Longitude:</td><td>0</td>";
document.getElementById("startButton").disabled = false;
document.getElementById("stopButton").disabled = true;
}
function checkCreds() {
var firstName = document.getElementById("fName").value;
var lastName = document.getElementById("lName").value;
var badgeNumb = document.getElementById("badgeID").value;
var fullName = firstName + " " + lastName;
if (fullName.length > 20 || fullName.length < 2) {
document.getElementById("loginStatus").innerHTML = "Full name has invalid number of characters!";
} else if (badgeNumb > 999 || badgeNumb < 0) {
document.getElementById("loginStatus").innerHTML = "Badge ID is an invalid number!";
} else {
alert("Access Granted, Welcome " + fullName + "!");
location.replace("indexW4.html");
}
}
function playStation() {
mySound = new sound("us-lab-background.mp3");
mySound.play();
}
function playOddity() {
mySound = new sound("David_Bowie_Space_Oddity.mp3");
mySound.play();
}
function playChief() {
mySound = new sound("hail_to_the_chief.mp3");
mySound.play();
}
function stopplayChief() {
mySound = new sound("hail_to_the_chief.mp3");
mySound.stop();
mySound.currTime = 0;
}
function sound(src) {
this.sound = document.createElement("audio");
this.sound.src = src;
this.play = function() {
this.sound.play();
}
// this.stop = function() {
// this.sound.pause();
// }
}