@@ -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
262287var 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
0 commit comments