Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<h1>Test Your Reaction</h1>
<p>Click on the shapes asap!</p>
</div>
<div class="container">
<a class="btn btn-1" id="play">Start</a>
<a class="btn btn-2" id="pause">Pause</a>
<a class="btn btn-3" id="restart">Restart</a>
</div>
<div id="text">
<h3>Time taken: <span id="timerTime"></span></h3>
</div>
Expand All @@ -20,4 +25,4 @@ <h3>Time taken: <span id="timerTime"></span></h3>
<script type="text/javascript" src="testReaction.js"></script>
</body>

</html>
</html>
148 changes: 96 additions & 52 deletions testReaction.css
Original file line number Diff line number Diff line change
@@ -1,53 +1,97 @@
#shape {
height: 100px;
width: 100px;
border-radius: 0px;
background-color: black;
display: none;
position: relative;
top: 100px;
left: 100px;
/* border: black 1px solid; */
}

#shape {
height: 100px;
width: 100px;
border-radius: 0px;
background-color: black;
display: none;
position: relative;
top: 100px;
left: 100px;
/* border: black 1px solid; */
}

body {

margin: 0;
padding: 0;
}

h1 {
color: black;
/* text-shadow: px 10px 5px #FFFFFF; */
font-family: 'Annie Use Your Telescope';
/* background-color: whitesmoke; */
/* align-self: center; */
font-size: 400%;

}

p {
padding: 0;
margin: 0;
/* align-self: center; */
/* background-color: whitesmoke; */
}

#title {
display: flex;
justify-content: center;
align-items: center;
border: 10px #FDC9B3 solid;
height: 200px;
flex-direction: column;


}

#text {
display: flex;
flex-direction: column;
align-items: flex-start;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
margin: 0;
padding: 0;
}

h1 {
color: black;
/* text-shadow: px 10px 5px #FFFFFF; */
font-family: 'Annie Use Your Telescope';
/* background-color: whitesmoke; */
/* align-self: center; */
font-size: 400%;
margin-bottom: 0px;
margin-top: 5px;
}

p {
padding: 0;
margin: 0;
/* align-self: center; */
/* background-color: whitesmoke; */
}

#title {
display: flex;
justify-content: center;
align-items: center;
border: 10px #FDC9B3 solid;
min-height: 150px;
flex-direction: column;
}

#text {
display: flex;
flex-direction: column;
align-items: flex-start;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}


/* garima */

.container {
display: flex;
justify-content: center;
align-items: center;
align-content: center;
flex-wrap: wrap;
width: 60vw;
margin: 0 auto;
}

.btn {
flex: 1 1 auto;
margin: 20px;
padding: 5px;
text-align: center;
text-transform: uppercase;
transition: 0.5s;
background-size: 200% auto;
/* color: white; */
color: black;
/* text-shadow: 0px 0px 10px rgba(0,0,0,0.2);*/
box-shadow: 0 0 20px #eee;
border-radius: 10px;
font-size: 150%;
font-family: 'Annie Use Your Telescope';
}

.btn:hover {
background-position: right center;
/* change the direction of the change here */
}

.btn-1 {
background-image: linear-gradient(to right, #f6d365 0%, #fda085 51%, #f6d365 100%);
}

.btn-2 {
background-image: linear-gradient(to right, #fbc2eb 0%, #a6c1ee 51%, #fbc2eb 100%);
}

.btn-3 {
background-image: linear-gradient(to right, #ffecd2 0%, #fcb69f 51%, #ffecd2 100%);
}
78 changes: 52 additions & 26 deletions testReaction.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,53 @@
var startTime = new Date().getTime();
function appearShape() {
var top = Math.random() * 400;
var left = Math.random() * 500;
var radius = Math.random() * 100;
var color = Math.floor(Math.random() * 16777215).toString(16);
document.getElementById("shape").style.display = "block";
document.getElementById("shape").style.top = top + "px";
document.getElementById("shape").style.left = left + "px";
document.getElementById("shape").style.borderRadius = radius + "px";
document.getElementById("shape").style.backgroundColor = "#" + color;
startTime = new Date().getTime();
}
function delayAppear() {

setTimeout(appearShape, Math.random() * 2000);
}
delayAppear();
document.getElementById("shape").onclick = function () {
var endTime = new Date().getTime();
document.getElementById("shape").style.display = "none";
var calTime = (endTime - startTime) / 1000
document.getElementById("timerTime").innerHTML = calTime + "s";

delayAppear();

}
var pstartTime = 0;

var pendTime = 0;


function appearShape() {

var top = Math.random() * 400;
var left = Math.random() * 500;
var radius = Math.random() * 100;
var color = Math.floor(Math.random() * 16777215).toString(16);
document.getElementById("shape").style.display = "block";
document.getElementById("shape").style.top = top + "px";
document.getElementById("shape").style.left = left + "px";
document.getElementById("shape").style.borderRadius = radius + "px";
document.getElementById("shape").style.backgroundColor = "#" + color;

startTime = new Date().getTime();

}

function delayAppear() {

setTimeout(appearShape, Math.random() * 2000);
}
delayAppear();
document.getElementById("shape").onclick = function() {

var endTime = new Date().getTime();

document.getElementById("shape").style.display = "none";
var calTime = ((endTime - startTime) - (pendTime - pstartTime)) / 1000;
pendTime = 0;
pstartTime = 0;

document.getElementById("timerTime").innerHTML = calTime + "s";


delayAppear();

}
document.getElementById("restart").onclick = function() {
startTime = new Date().getTime();
delayAppear();
}
document.getElementById("pause").onclick = function() {
pstartTime = new Date().getTime();
}
document.getElementById("play").onclick = function() {

pendTime = new Date().getTime();
}