From e2cecf0ecf41566ebc760dc56b98c938fec5f04b Mon Sep 17 00:00:00 2001 From: Bo Trethewey Date: Sat, 20 May 2017 01:10:58 -0700 Subject: [PATCH 1/2] added JS code for the clock --- index.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 877a3aa..90d94e8 100644 --- a/index.js +++ b/index.js @@ -1 +1,28 @@ -// Your code here +var updateTime = function() { + var startTime = new Date(); + var hour = startTime.getHours(); + var time = doubleDigits(hour) + ":" + doubleDigits(startTime.getMinutes()) + ":" + doubleDigits(startTime.getSeconds()); + + if (hour < 12) { + time += " AM"; + } else if ( hour >= 12) { + if (hour > 13) { + hour = hour % 12; + } + time += " PM"; + } + + $('#clock').text(time); +}; + +var doubleDigits = function(digit) { + if (digit < 10 ) { + return '0' + digit; + } else { + return digit; + } +}; + +$(document).ready(function() { + setInterval(updateTime, 1000); +}); From 6c8a6d400f1d767fbb15c11ec6189ca41690e076 Mon Sep 17 00:00:00 2001 From: Bo Trethewey Date: Sat, 20 May 2017 01:13:10 -0700 Subject: [PATCH 2/2] added jquery script --- index.html | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 191d3cc..60a13ff 100644 --- a/index.html +++ b/index.html @@ -1,14 +1,21 @@ - - Clock Tower - - - + + Clock Tower + + + - -
- - + +
+ + + - + +