forked from leehadassin/progress-bar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
year.html
57 lines (51 loc) · 1.65 KB
/
year.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes">
<script>
var UPDATES_PER_SECOND = 30;
document.addEventListener('DOMContentLoaded', function () {
"use strict";
var $title = $('#title');
var $bar = $('#progress-bar');
var $percentage = $('#progress-percentage');
setInterval(function () {
"use strict";
var _getYearProgress = getYearProgress(),
year = _getYearProgress.year,
percentage = _getYearProgress.percentage;
$title.innerText = year;
document.title = year;
$bar.style.setProperty('width', "".concat(percentage, "%"));
$percentage.innerText = percentage.toFixed(10);
}, 1000 / UPDATES_PER_SECOND);
});
// Helpers
var $ = function $(selector) {
"use strict";
return document.querySelector(selector);
};
function getYearProgress() {
"use strict";
var year = new Date().getFullYear();
var start = new Date(year, 0, 1, 0, 0, 0, 0);
var end = new Date(year + 1, 0, 1, 0, 0, 0, 0);
var percentage = 100 * ((Date.now() - start) / (end - start));
return {
year: year,
percentage: percentage
};
};
</script>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<h1 id="title"></h1>
<div class="progress-bar-container">
<div id="progress-bar"></div>
</div>
<h2><span id="progress-percentage"></span>%</h2>
</body>
</html>