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
15 changes: 9 additions & 6 deletions SpecRunner.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Jasmine Spec Runner v2.8.0</title>

<link rel="shortcut icon" type="image/png" href="jasmine/jasmine-2.8.0/jasmine_favicon.png" />
<link
rel="shortcut icon"
type="image/png"
href="jasmine/jasmine-2.8.0/jasmine_favicon.png"
/>
<link rel="stylesheet" href="jasmine/jasmine-2.8.0/jasmine.css" />

<script src="jasmine/jasmine-2.8.0/jasmine.js"></script>
<script src="jasmine/jasmine-2.8.0/jasmine-html.js"></script>
<script src="jasmine/jasmine-2.8.0/boot.js"></script>

<!-- Iterations 1 - 8 -->
<!-- Iterations 1 - 8 -->
<script src="src/chronometer.js"></script>
<script src="tests/chronometer.spec.js"></script>

<!-- Bonus Iteration 9: Centiseconds -->
<!-- <script src="src/chronometer-centiseconds.js"></script> -->
<!-- <script src="tests/chronometer-centiseconds.spec.js"></script> -->

<script src="src/chronometer-centiseconds.js"></script>
<script src="tests/chronometer-centiseconds.spec.js"></script>
</head>

<body></body>
Expand Down
85 changes: 42 additions & 43 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>JS Chronometer</title>
<link rel="stylesheet" href="styles/style.css">
</head>
<body>

<section id="splits-container">
<h3>Splits</h3>
<ol id="splits">
</ol>
</section>

<div class="leash leash-top"></div>

<section id="clock">
<div id="sphere">
<span id="minDec" class="number">0</span><span id="minUni" class="number">0</span><span>:</span><span id="secDec" class="number">0</span><span id="secUni" class="number">0</span>

<div id="centiseconds">
<span id="centisecDec">0</span><span id="centisecUni">0</span>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>JS Chronometer</title>
<link rel="stylesheet" href="styles/style.css" />
</head>
<body>
<section id="splits-container">
<h3>Splits</h3>
<ol id="splits"></ol>
</section>

<div class="leash leash-top"></div>

<section id="clock">
<div id="sphere">
<span id="minDec" class="number">0</span
><span id="minUni" class="number">0</span><span>:</span
><span id="secDec" class="number">0</span
><span id="secUni" class="number">0</span>

<div id="centiseconds">
<span id="centisecDec">0</span><span id="centisecUni">0</span>
</div>

<button id="btnLeft" class="btn start">START</button>
<button id="btnRight" class="btn reset">RESET</button>
</div>
</section>

<button id="btnLeft" class="btn start">START</button> <button id="btnRight" class="btn reset">RESET</button>
<div class="leash leash-bottom">
<div class="hole"></div>
<div class="hole"></div>
<div class="hole"></div>
</div>
</section>

<div class="leash leash-bottom">
<div class="hole"></div>
<div class="hole"></div>
<div class="hole"></div>
</div>
<!-- Iterations 1 - 8 -->
<script src="src/chronometer.js"></script>

<!-- Bonus Iteration 9: Centiseconds -->
<script src="src/chronometer-centiseconds.js"></script>


<!-- Iterations 1 - 8 -->
<script src="src/chronometer.js"></script>

<!-- Bonus Iteration 9: Centiseconds -->
<!-- <script src="src/chronometer-centiseconds.js"></script> -->


<!-- DOM manipulation logic -->
<script src="src/index.js"></script>
</body>
</html>
<!-- DOM manipulation logic -->
<script src="src/index.js"></script>
</body>
</html>
29 changes: 21 additions & 8 deletions src/chronometer.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,46 @@
class Chronometer {
constructor() {
// ... your code goes here
this.currentTime = 0;
this.intervalId = null;
}

start(printTimeCallback) {
// ... your code goes here
this.intervalId = setInterval(() => {
this.currentTime += 1;

if (printTimeCallback) {
printTimeCallback();
}
}, 10);
}

getMinutes() {
// ... your code goes here
return Math.floor(this.currentTime / 6000);
}

getSeconds() {
// ... your code goes here
return Math.floor(this.currentTime / 100) % 60;
}

getCentiseconds() {
return this.currentTime % 100;
}

computeTwoDigitNumber(value) {
// ... your code goes here
return value.toString().padStart(2, "0");
}

stop() {
// ... your code goes here
clearInterval(this.intervalId);
}

reset() {
// ... your code goes here
this.currentTime = 0;
}

split() {
// ... your code goes here
return `${this.computeTwoDigitNumber(this.getMinutes())}:
${this.computeTwoDigitNumber(this.getSeconds())}:
${this.computeTwoDigitNumber(this.getCentiseconds())}`;
}
}