From c943f869ae89e7791220440c7c9314642f37f8a3 Mon Sep 17 00:00:00 2001 From: erikslewis Date: Mon, 28 Nov 2016 08:40:34 -0500 Subject: [PATCH] timer --- index.html | 11 +++++++---- readme.md | 2 +- style.css | 30 ++++++++++++++++++++++++++---- timers.js | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index c1129f7..aaaae99 100644 --- a/index.html +++ b/index.html @@ -3,18 +3,21 @@ - i ♥ js + Eriks Stop Watch -

Stop Watch

+ +

0

- - +

ERIK'S STOP WATCH TIMER

+ + + diff --git a/readme.md b/readme.md index 902f652..3d7ef60 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@ Spend 10 minutes looking at [JavaScript Timers](https://developer.mozilla.org/en ####Take It Step By Step -This is a tough assignment, so don't stress over meeting all the requirements. Just take it step by step and try to meet the benchmarks below in order. +This is a tough assignment, so don't stress over meeting all the requirements. Just take it step by step and try to meet the benchmarks below in order. 1. Create Javascript selectors that target each of the timer buttons. 2. Create click handlers (empty, for now) for each of the timer buttons. diff --git a/style.css b/style.css index 6ddb643..ebdcc3e 100644 --- a/style.css +++ b/style.css @@ -9,22 +9,44 @@ h1 { font-family: Josefin Slab; font-size: 72px; text-align: center; + color: red; + border-bottom: 10px solid black; + text-shadow: 4px 0px black; } button { - background: #4479BA; - color: #FFF; + background: green; + color: black; font-family: Josefin Slab; font-size: 50px; text-align: center; - border: 1px solid black; + border: 10px solid black; margin: 20px; padding: 15px 25px; border-radius: 10px; box-shadow: 2px 2px black; + text-decoration: underline; } button:hover{ - background: #356094; + background: red; } +body { + background-image: url("file:///Users/Erik/Desktop/IMG_9438.jpg"); + background-position: center; + background-repeat: no-repeat; + background-color: black; +} + +p { + text-align: center; + color: red; + font-size: 40px; + text-shadow: 4px 0px black; +} + +img { + display: block; + margin-left: auto; + margin-right: auto } diff --git a/timers.js b/timers.js index fd40910..a1ca573 100644 --- a/timers.js +++ b/timers.js @@ -1,4 +1,43 @@ +let timer = { + seconds: 0, + timerId: 0, + run: false, + clock: { + timer: $("#timer"), + reset: $("#reset"), + start: $("#start"), + pause: $("#pause"), + }, + updateTime: function updateTime(){ + this.seconds++; + this.clock.timer.text('Time elapsed: ' + this.seconds); + }, + setupListeners: function () { + this.clock.start.on('click', function() { + console.log('start'); + this.clock.timer.text('Time elapsed: ' + this.seconds); + if (this.run === false){ + this.timerId = setInterval(this.updateTime.bind(this), 1000); + this.run = true; + } + }.bind(this)); + this.clock.pause.on('click', function() { + clearInterval(this.timerId); + this.run = false; + }.bind(this)); + + this.clock.reset.on('click', function() { + this.seconds = 0; + console.log('reset ' + this.seconds); + clearInterval(this.timerId); + this.run = false; + this.clock.timer.text('Stop Watch'); + }.bind(this)); + } +} + +timer.setupListeners();