File tree Expand file tree Collapse file tree 2 files changed +66
-3
lines changed
Expand file tree Collapse file tree 2 files changed +66
-3
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ <h1 class="title">
4646 < div class ="hours "> </ div >
4747 < div class ="separator "> :</ div >
4848 < div class ="minutes "> </ div >
49- < div class ="persiod "> </ div >
49+ < div class ="period "> </ div >
5050 < div class ="seconds "> </ div >
5151 </ div >
5252 < div class ="wrapper "> </ div >
@@ -62,6 +62,6 @@ <h1 class="title">
6262 </ div >
6363 </ section >
6464 </ main >
65- < script src ="./js/main.js " type =" text/js " > </ script >
65+ < script src ="./js/main.js "> </ script >
6666 </ body >
6767</ html >
Original file line number Diff line number Diff line change 1- document . addEventListener ( "DOMContentLoaded" , function ( ) { } ) ;
1+ document . addEventListener ( "DOMContentLoaded" , function ( ) {
2+ // Clock Items
3+ const hourItem = document . getElementsByClassName ( "hours" ) ;
4+ const minutesItem = document . querySelector ( ".minutes" ) ;
5+ const secondsItem = document . getElementsByClassName ( "seconds" ) ;
6+ const periodItem = document . querySelector ( ".period" ) ;
7+
8+ // Calender Items
9+ const monthItem = document . getElementsByClassName ( "month" ) ;
10+ const dayItem = document . querySelector ( ".day" ) ;
11+ const dayNumberItem = document . getElementsByClassName ( "day-number" ) ;
12+ const yearItem = document . querySelector ( ".year" ) ;
13+
14+ // Easy Access To Days and Month
15+ const days = [
16+ "Sunday" ,
17+ "Monday" ,
18+ "Tuesday" ,
19+ "Wednesday" ,
20+ "Thursday" ,
21+ "Friday" ,
22+ "Saturday" ,
23+ ] ;
24+ const month = [
25+ "Jan" ,
26+ "Feb" ,
27+ "Mar" ,
28+ "Apr" ,
29+ "May" ,
30+ "Jun" ,
31+ "Jul" ,
32+ "Aug" ,
33+ "Sep" ,
34+ "Oct" ,
35+ "Nov" ,
36+ "Dec" ,
37+ ] ;
38+
39+ function setTimePeriod ( time ) {
40+ let period = "" ;
41+ if ( time < 12 ) {
42+ period = "AM" ;
43+ } else {
44+ period = "PM" ;
45+ }
46+ return period ;
47+ }
48+
49+ // Js Current Time And Add To Elements
50+ function clock ( ) {
51+ const currentDate = new Date ( ) ;
52+ const hours = currentDate . hours ( ) ;
53+ const minutes = currentDate . minutes ( ) ;
54+ const seconds = currentDate . seconds ( ) ;
55+
56+ // Add to HTML DOM
57+ hourItem . innerHTML = addZero ( hours ) ;
58+ minutesItem . innerHTML = addZero ( minutes ) ;
59+ secondsItem . innerHTML = addZero ( seconds ) ;
60+ periodItem . innerHTML = setTimePeriod ( hours ) ;
61+ }
62+ clock ( ) ;
63+
64+ } ) ;
You can’t perform that action at this time.
0 commit comments