Skip to content

Commit 01d290b

Browse files
hovering the graph will display the past time
1 parent 7f6d970 commit 01d290b

File tree

3 files changed

+40
-29
lines changed

3 files changed

+40
-29
lines changed

css/main.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ body {
6464
height: 28px;
6565
}
6666
#timebox svg path {
67-
-webkit-transition: all 0.2s ease-in-out;
68-
-moz-transition: all 0.2s ease-in-out;
69-
-ms-transition: all 0.2s ease-in-out;
70-
-o-transition: all 0.2s ease-in-out;
71-
transition: all 0.2s ease-in-out;
67+
-webkit-transition: all 0.4s ease-in-out;
68+
-moz-transition: all 0.4s ease-in-out;
69+
-ms-transition: all 0.4s ease-in-out;
70+
-o-transition: all 0.4s ease-in-out;
71+
transition: all 0.4s ease-in-out;
7272
fill: #00a3d3;
7373
}
7474
#timebox.past svg path {

js/app.js

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -258,32 +258,36 @@ var twoZeroPad = function(n) {
258258
return (n.length<2) ? '0'+n : n;
259259
}
260260

261+
// updates timebox
262+
var updateTimebox = function(date) {
263+
var elm = $("#timebox");
264+
var a,b,c,d,e,f,g,z;
265+
266+
a = date.getUTCFullYear();
267+
b = twoZeroPad(date.getUTCMonth()+1); // months 0-11
268+
c = twoZeroPad(date.getUTCDate());
269+
e = twoZeroPad(date.getUTCHours());
270+
f = twoZeroPad(date.getUTCMinutes());
271+
g = twoZeroPad(date.getUTCSeconds());
272+
273+
elm.find(".current").text("Current: "+a+'-'+b+'-'+c+' '+e+':'+f+':'+g+" UTC");
274+
275+
a = date.getFullYear();
276+
b = twoZeroPad(date.getMonth()+1); // months 0-11
277+
c = twoZeroPad(date.getDate());
278+
e = twoZeroPad(date.getHours());
279+
f = twoZeroPad(date.getMinutes());
280+
g = twoZeroPad(date.getSeconds());
281+
z = date.getTimezoneOffset() / -60;
282+
283+
elm.find(".local").text("Local: "+a+'-'+b+'-'+c+' '+e+':'+f+':'+g+" UTC"+((z<0)?"-":"+")+z);
284+
}
285+
261286
// runs every second
262287
var updateTime = function(date) {
263288
// update timebox
264289
var elm = $("#timebox.present");
265-
if(elm.length > 0) {
266-
var a,b,c,d,e,f,g,z;
267-
268-
a = date.getUTCFullYear();
269-
b = twoZeroPad(date.getUTCMonth()+1); // months 0-11
270-
c = twoZeroPad(date.getUTCDate());
271-
e = twoZeroPad(date.getUTCHours());
272-
f = twoZeroPad(date.getUTCMinutes());
273-
g = twoZeroPad(date.getUTCSeconds());
274-
275-
elm.find(".current").text("Current: "+a+'-'+b+'-'+c+' '+e+':'+f+':'+g+" UTC");
276-
277-
a = date.getFullYear();
278-
b = twoZeroPad(date.getMonth()+1); // months 0-11
279-
c = twoZeroPad(date.getDate());
280-
e = twoZeroPad(date.getHours());
281-
f = twoZeroPad(date.getMinutes());
282-
g = twoZeroPad(date.getSeconds());
283-
z = date.getTimezoneOffset() / -60;
284-
285-
elm.find(".local").text("Local: "+a+'-'+b+'-'+c+' '+e+':'+f+':'+g+" UTC"+((z<0)?"-":"+")+z);
286-
}
290+
if(elm.length > 0) updateTimebox(date);
287291

288292
// update friendly delta time fields
289293
var elm = $(".friendly-dtime");
@@ -345,10 +349,13 @@ $(window).ready(function() {
345349
// expand graph on startup, if nessary
346350
if(embed.graph_expanded) $('#telemetry_graph .graph_label').click();
347351

348-
// reset nite-overlay when mouse goes out of the graph box
352+
// reset nite-overlay and timebox when mouse goes out of the graph box
349353
$("#telemetry_graph").on('mouseout','.holder', function() {
350354
nite.setDate(null);
351355
nite.refresh();
356+
357+
$("#timebox").removeClass('past').addClass('present');
358+
updateTimebox(new Date());
352359
});
353360

354361
// hand cursor for dragging the vehicle list

js/plot_config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,12 @@ function updateLegend() {
131131
polyMarker.setPosition(vehicles[follow_vehicle].positions[j - null_count]);
132132

133133
// adjust nite overlay
134-
nite.setDate(new Date(data_ref.data[j][0]));
134+
var date = new Date(data_ref.data[j][0])
135+
nite.setDate(date);
135136
nite.refresh();
137+
// set timebox
138+
$('#timebox').removeClass('present').addClass('past');
139+
updateTimebox(date);
136140
}
137141
}
138142

0 commit comments

Comments
 (0)