parent
f9b255e544
commit
7540e9910f
@ -0,0 +1,35 @@
|
||||
body {
|
||||
text-align: center;
|
||||
font-family: 'Orbitron', 'Courier New', monospace;
|
||||
}
|
||||
|
||||
#stopwatch {
|
||||
width: 400px;
|
||||
height: 100px;
|
||||
margin: 0 auto;
|
||||
border: 1px solid black;
|
||||
padding: 12px;
|
||||
|
||||
line-height: 100px;
|
||||
font-size: 75px;
|
||||
text-align: right;
|
||||
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#controls {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 24px 24px 16px 24px;
|
||||
background: mediumseagreen;
|
||||
border:none;
|
||||
border-bottom: 2px solid forestgreen;
|
||||
border-radius: 5px;
|
||||
|
||||
color: white;
|
||||
font-size: 24px;
|
||||
font-family: 'Orbitron', 'Courier New', monospace;
|
||||
font-weight: 700;
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link href='http://fonts.googleapis.com/css?family=Orbitron:400,700' rel='stylesheet' type='text/css'>
|
||||
<script src="js/app.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="stopwatch">
|
||||
0
|
||||
</div>
|
||||
|
||||
<div id="controls">
|
||||
<button id="start">Start</button>
|
||||
<button id="stop">Stop</button>
|
||||
<button id="reset">Reset</button>
|
||||
<button id="countdown">Countdown</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1 @@
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
body {
|
||||
text-align: center;
|
||||
font-family: 'Orbitron', 'Courier New', monospace;
|
||||
}
|
||||
|
||||
#stopwatch {
|
||||
width: 400px;
|
||||
height: 100px;
|
||||
margin: 0 auto;
|
||||
border: 1px solid black;
|
||||
padding: 12px;
|
||||
|
||||
line-height: 100px;
|
||||
font-size: 75px;
|
||||
text-align: right;
|
||||
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#controls {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 24px 24px 16px 24px;
|
||||
background: mediumseagreen;
|
||||
border:none;
|
||||
border-bottom: 2px solid forestgreen;
|
||||
border-radius: 5px;
|
||||
|
||||
color: white;
|
||||
font-size: 24px;
|
||||
font-family: 'Orbitron', 'Courier New', monospace;
|
||||
font-weight: 700;
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link href='http://fonts.googleapis.com/css?family=Orbitron:400,700' rel='stylesheet' type='text/css'>
|
||||
<script src="js/app.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="stopwatch">
|
||||
0
|
||||
</div>
|
||||
|
||||
<div id="controls">
|
||||
<button id="start">Start</button>
|
||||
<button id="stop">Stop</button>
|
||||
<button id="reset">Reset</button>
|
||||
<button id="countdown">Countdown</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,36 @@
|
||||
window.onload = function() {
|
||||
document.getElementById("start").addEventListener("click", startTimer);
|
||||
document.getElementById("stop").addEventListener("click", stopTimer);
|
||||
document.getElementById("reset").addEventListener("click", resetTimer);
|
||||
document.getElementById("countdown").addEventListener("click", countdownTimer);
|
||||
};
|
||||
|
||||
var startTimer = function() {
|
||||
var time = parseInt(document.getElementById("stopwatch").textContent); //move variable declarations outside the window.onload so that each function can have acess to the variables.
|
||||
stopWatchHandle = setInterval(function() {
|
||||
time += 1;
|
||||
var timer = document.getElementById("stopwatch");
|
||||
timer.textContent = time;
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
var resetTimer = function() {
|
||||
clearInterval(stopWatchHandle);
|
||||
var timer = document.getElementById("stopwatch");
|
||||
timer.textContent = "0";
|
||||
};
|
||||
|
||||
var countdownTimer = function () {
|
||||
clearInterval(stopWatchHandle);
|
||||
var time = parseInt(document.getElementById("stopwatch").textContent);
|
||||
stopWatchHandle = setInterval(function() {
|
||||
time -= 1;
|
||||
var timer = document.getElementById("stopwatch");
|
||||
timer.textContent = time;
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
var stopTimer = function() {
|
||||
clearInterval(stopWatchHandle);
|
||||
};
|
||||
|
||||
Loading…
Reference in new issue