-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript1.js
More file actions
45 lines (44 loc) · 1.58 KB
/
javascript1.js
File metadata and controls
45 lines (44 loc) · 1.58 KB
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
document.getElementById("butt").onclick=function(){
document.getElementById("butt").innerHTML="End Game!";
document.getElementById("butt").onclick=function(){
alert("Your Average time was - "+((time/count).toFixed(2))+" seconds");
location.reload();
}
var count=0;
var time=0;
var i=new Date().getTime();
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
function makeappear(){
document.getElementById("shape").style.top=(Math.random()*400)+"px";
document.getElementById("shape").style.left=(Math.random()*500)+"px";
document.getElementById("shape").style.display="block";
document.getElementById("shape").style.width=(100+Math.random()*200)+"px";
document.getElementById("shape").style.height=(100+Math.random()*200)+"px";
document.getElementById("shape").style.backgroundColor=getRandomColor();
i=new Date().getTime();
if(Math.random()>=0.3)
document.getElementById("shape").style.borderRadius="50%";
else
document.getElementById("shape").style.borderRadius="0";
}
function delay(){
setTimeout(makeappear, Math.random()*1000);
}
delay();
document.getElementById("shape").onclick=function(){
document.getElementById("shape").style.display="none";
var f=new Date().getTime();
var t=(f-i)/1000;
time+=t;
document.getElementById("x").innerHTML=t+" seconds";
delay();
count++;
}
}