File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
77 < title > Agent's Site</ title >
88 < script src ="index.js "> </ script >
9- < link rel ="stylesheet " href ="index.css ">
109</ head >
1110< body >
12- < h1 > come back later when theres something interesting here </ h1 >
11+ < a href =" ./precise-age/index.html " > Precise Age Calculator </ a >
1312</ body >
1413</ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7+ < title > Precise Age Calculator</ title >
8+ < link rel ="stylesheet " href ="./stylesheet.css ">
9+ </ head >
10+ < body >
11+ < h1 > Precise Age Calculator</ h1 >
12+ < p > Birth Date</ p >
13+ < input type ="datetime-local " id ="date ">
14+ < br >
15+ < br >
16+ < br >
17+ < button onclick ="window.calculate() "> Calculate</ button >
18+ < br >
19+ < br >
20+ < br >
21+ < h2 id ="age "> Age: ??</ h2 >
22+ </ body >
23+ < script src ="index.js "> </ script >
24+ </ html >
Original file line number Diff line number Diff line change 1+ const secondsInYear = 31536000
2+ const millisecondsToSeconds = 0.001
3+
4+ const dateInput = document . getElementById ( "date" )
5+ const age = document . getElementById ( "age" )
6+
7+ let interval = false
8+
9+ window . calculate = ( ) => {
10+ const date = new Date ( dateInput . value )
11+ age . innerHTML = "Age: " + ( ( Date . now ( ) * millisecondsToSeconds ) - ( date . getTime ( ) * millisecondsToSeconds ) ) / secondsInYear
12+
13+ if ( ! interval ) {
14+ interval = true
15+ setInterval ( window . calculate , 100 )
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ body {
2+ text-align : center;
3+ }
You can’t perform that action at this time.
0 commit comments