-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
184 lines (157 loc) · 7.32 KB
/
index.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/solar/bootstrap.min.css" crossorigin="anonymous">
<style type="text/css">
.marker {
width: 1px;
height: 20px;
display: block;
position: absolute;
border: 1px rgba(0,0,0,0) solid;
border-right-color: rgba(255,255,255,0.3);
border-left-color: rgba(0,0,0,0.3);
}
.markers {
width: 100%;
}
</style>
</head>
<body>
<div class="bs-component">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<div class="navbar-brand" id="div-time">00:00:00</div>
</div>
<div class="navbar-collapse collapse" id="bs-example-navbar-collapse-2" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav navbar-right">
<li><a href="https://github.com/prehensile/progress-clock" target="_blank">Source</a></li>
</ul>
</div>
</div>
</nav>
</div>
<div class="container">
<div class="row">
<div class="col-lg-12">
<h3>Minute</h3>
<div class="bs-component">
<div class="progress progress-striped active">
<div id="progress-minute" class="progress-bar progress-bar-info" style="width: 45%"></div>
</div>
</div>
<h3>Hour</h3>
<div class="bs-component">
<div class="progress progress-striped active">
<div id="progress-hour" class="progress-bar progress-bar-success" style="width: 45%"></div>
</div>
</div>
<h3>Day</h3>
<div class="bs-component">
<div class="progress progress-striped active">
<div id="progress-day" class="progress-bar progress-bar-warning" style="width: 45%"></div>
<div class=markers>
<div class="marker" style="left:37.5%"></div>
<div class="marker" style="left:70.8%"></div>
</div>
</div>
</div>
<h3>Month</h3>
<div class="bs-component">
<div class="progress progress-striped active">
<div id="progress-month" class="progress-bar progress-bar" style="width: 45%"></div>
</div>
</div>
<h3>Year</h3>
<div class="bs-component">
<div class="progress progress-striped active">
<div id="progress-year" class="progress-bar progress-bar-danger" style="width: 45%"></div>
<!-- <div class=markers>
<div class="marker" style="left:8.3%"></div>
<div class="marker" style="left:16.6%"></div>
<div class="marker" style="left:24.9%"></div>
<div class="marker" style="left:33.2%"></div>
<div class="marker" style="left:41.5%"></div>
<div class="marker" style="left:49.8%"></div>
<div class="marker" style="left:58.1%"></div>
<div class="marker" style="left:66.4%"></div>
<div class="marker" style="left:74.7%"></div>
<div class="marker" style="left:83%"></div>
<div class="marker" style="left:91.3%"></div>
<div class="marker" style="left:99.6%"></div>
</div> -->
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<script type="text/javascript">
function updateProgressBar( elementId, normalisedProgress ){
var bar = document.getElementById( elementId );
bar.style.width = (normalisedProgress * 100) + "%";
}
function padNumber( n ){
if( ("" + n).length < 2) return "0" + n;
return n;
}
function updateTime( now ){
var clock = document.getElementById( "div-time" );
var display =
padNumber(now.getHours()) + ":" +
padNumber( now.getMinutes()) + ":" +
padNumber(now.getSeconds());
clock.innerHTML = display;
}
function getDaysInCurrentMonth(){
// cribbed from https://stackoverflow.com/questions/1184334/get-number-days-in-a-specified-month-using-javascript
var d = new Date();
d = new Date( d.getFullYear(), d.getMonth()+1, 0);
return d.getDate();
}
var MS_IN_AN_HOUR = (1000*60*60);
var MS_IN_A_DAY = MS_IN_AN_HOUR * 24;
function updateMinute( now ){
var minuteProgress = now.getSeconds() / 60.0;
updateProgressBar( "progress-minute", minuteProgress );
return minuteProgress;
}
function updateHour( now, dtDayStart ){
// use ms in an hour to calculate percentage through current hour
var tsHourStart = dtDayStart.getTime() + (now.getHours() * MS_IN_AN_HOUR);
var hourProgress = (now.getTime() - tsHourStart) / MS_IN_AN_HOUR;
updateProgressBar( "progress-hour", hourProgress );
return hourProgress;
}
function updateDay( now, dtDayStart ){
// use ms in an day to calculate percentage through current day
var dayProgress = (now.getTime() - dtDayStart.getTime()) / MS_IN_A_DAY;
updateProgressBar( "progress-day", dayProgress );
return dayProgress;
}
function updateClock(){
var now = new Date();
var dtDayStart = new Date( now.getFullYear(), now.getMonth(), now.getDate() );
var daysInCurrentMonth = getDaysInCurrentMonth();
var msThisMonth = daysInCurrentMonth * MS_IN_A_DAY;
var minuteProgress = updateMinute( now );
var hourProgress = updateHour( now, dtDayStart );
var dayProgress = updateDay( now, dtDayStart );
var monthProgress = (now.getDate()+dayProgress) / daysInCurrentMonth;
var yearProgress = (now.getMonth()+monthProgress) / 12.0;
updateProgressBar( "progress-month", monthProgress );
updateProgressBar( "progress-year", yearProgress );
updateTime( now );
};
setInterval( updateClock, 1000.0 / 10.0 );
</script>
</body>
</html>