Skip to content

Commit b3ccd74

Browse files
committed
(hopefully) fixed time + added cool stuff
1 parent 8b6d0d6 commit b3ccd74

2 files changed

Lines changed: 55 additions & 12 deletions

File tree

html/index.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,15 @@ <h3 class="header">And there is literally nothing to be seen here either</h3>
256256

257257
<br>
258258
<h2 class="header">Time you have already wasted on this page</h2>
259-
260259
<br>
261260

261+
<div id = "innerDIV">
262+
263+
</div>
264+
262265
<!-- CLOCK -->
263266

264-
<div class="clock">
267+
<div class="clock" id = "clockDIV">
265268
<div class="container-fluid">
266269
<div class="row">
267270

@@ -322,7 +325,7 @@ <h2 class="header">Time you have already wasted on this page</h2>
322325

323326
<!-- DECIMAL -->
324327

325-
<div class="dec">
328+
<div class="dec" id = "numberDIV">
326329
<div class="container-fluid">
327330
<div class="row">
328331

html/static/index/js/app.js

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
// Prevent text marking on this page
22
onselectstart = (e) => {e.preventDefault()}
33

4-
/* this JS handles the binary clock */
5-
var startTime = new Date().getTime();
4+
// Start date
5+
var d = new Date();
6+
// Covert current time to UTC
7+
var startTime = d.getTime() + d.getTimezoneOffset() * 60000;
8+
9+
// Timer
10+
var timer;
611

712
var main = function() {
813

9-
window.setInterval(function() {clock()}, 1000);
14+
// Update everys 1000 ms
15+
timer = window.setInterval(function() {clock()}, 1000);
1016

17+
// Pre-Setup to make everything nice and dark
1118
var lighting = function(n,t) {
1219
if(n == 1) {
1320
$('.'+t+'-1').addClass('on').removeClass('off');
@@ -73,27 +80,60 @@ var main = function() {
7380
};
7481

7582
var clock = function() {
76-
77-
var currentTime = new Date(new Date().getTime() - startTime)
7883

79-
var hours = currentTime.getHours()-1;
80-
var minutes = currentTime.getMinutes();
81-
var seconds = currentTime.getSeconds();
82-
84+
// Current Time
85+
var d2 = new Date();
86+
var currentTime = d2.getTime() + (d2.getTimezoneOffset() * 60000) - startTime;
87+
88+
// Convert miliseconds
89+
var seconds = currentTime / 1000;
90+
var minutes = seconds / 60;
91+
var hours = minutes / 60;
92+
93+
// Get within current limits
94+
seconds = Math.floor(seconds % 60);
95+
minutes = Math.floor(minutes % 60);
96+
hours = Math.floor(hours % 24);
97+
98+
hours = 30;
99+
100+
// No-Life protection
101+
if (hours >= 30) {
102+
document.getElementById("clockDIV").innerHTML = "";
103+
document.getElementById("numberDIV").innerHTML = "";
104+
105+
// Get some help.
106+
var timeMsg = document.createElement("h1");
107+
timeMsg.innerHTML = " > 30 GODDAMNED HOURS!";
108+
109+
var helpMsg = document.createElement("h3");
110+
helpMsg.innerHTML = "If you didn't cheat on archiving this amount of time<br> you should really go out and get some help."
111+
helpMsg.style.textAlign = "center";
112+
helpMsg.style.color = "#4f4f66"
113+
114+
document.getElementById("innerDIV").appendChild(timeMsg);
115+
document.getElementById("innerDIV").appendChild(helpMsg);
116+
117+
window.clearInterval(timer);
118+
}
119+
120+
// Calculate the binary lights
83121
var s2 = seconds % 10;
84122
var s1 = (seconds - s2) / 10 % 10;
85123
var m2 = minutes % 10;
86124
var m1 = (minutes - m2) / 10 % 10;
87125
var h2 = hours % 10;
88126
var h1 = (hours - h2) / 10 % 10;
89127

128+
// Make it bright (or dark lol)
90129
lighting(s2, 's-2');
91130
lighting(s1, 's-1');
92131
lighting(m2, 'm-2');
93132
lighting(m1, 'm-1');
94133
lighting(h2, 'h-2');
95134
lighting(h1, 'h-1');
96135

136+
// Display time number
97137
$('.dec-hour1 p').text(h1);
98138
$('.dec-hour2 p').text(h2);
99139
$('.dec-minute1 p').text(m1);

0 commit comments

Comments
 (0)