@@ -349,12 +349,15 @@ function updateVehicleInfo(index, position) {
349349 var image = vehicles [ index ] . image_src ;
350350
351351 var elm = $ ( '.vehicle' + index ) ;
352+
353+ // if the vehicle doesn't exist in the list
352354 if ( elm . length == 0 ) {
353355 $ ( '.portrait' ) . append ( '<div class="row vehicle' + index + '"></div>' ) ;
354356 $ ( '.landscape' ) . append ( '<div class="row vehicle' + index + '"></div>' ) ;
355357
356358 }
357359
360+ // decides how to dispaly the horizonal speed
358361 var imp = offline . get ( 'opt_imperial' ) ;
359362 var ascent_text = imp ? ( vehicles [ index ] . ascent_rate * 196.850394 ) . toFixed ( 1 ) + ' ft/min' : vehicles [ index ] . ascent_rate . toFixed ( 1 ) + ' m/s' ;
360363 if ( offline . get ( 'opt_haxis_hours' ) ) {
@@ -365,6 +368,7 @@ function updateVehicleInfo(index, position) {
365368
366369 var coords_text ;
367370 var ua = navigator . userAgent . toLowerCase ( ) ;
371+
368372 // determine how to link the vehicle coordinates to a native app, if on a mobile device
369373 if ( ua . indexOf ( 'iphone' ) > - 1 ) {
370374 coords_text = '<a id="launch_mapapp" href="maps://?q=' + position . gps_lat + ',' + position . gps_lon + '">'
@@ -378,6 +382,12 @@ function updateVehicleInfo(index, position) {
378382 coords_text = roundNumber ( position . gps_lat , 6 ) + ', ' + roundNumber ( position . gps_lon , 6 ) ;
379383 }
380384
385+ // format altitude strings
386+ var text_alt = Number ( ( imp ) ? Math . floor ( 3.2808399 * parseInt ( position . gps_alt ) ) : parseInt ( position . gps_alt ) ) . toLocaleString ( "us" ) ;
387+ text_alt += " " + ( ( imp ) ? 'ft' :'m' ) ;
388+ var text_alt_max = Number ( ( imp ) ? Math . floor ( 3.2808399 * parseInt ( vehicles [ index ] . max_alt ) ) : parseInt ( vehicles [ index ] . max_alt ) ) . toLocaleString ( "us" ) ;
389+ text_alt_max += " " + ( ( imp ) ? 'ft' :'m' ) ;
390+
381391
382392 // start
383393 var a = '<div class="header">'
@@ -407,12 +417,12 @@ function updateVehicleInfo(index, position) {
407417 + '<div class="right">'
408418 + '<dl>'
409419 + ( ( vehicles [ index ] . vehicle_type == "car" ) ? '' : '<dt>' + ascent_text + ' ' + hrate_text + '</dt><dd>rate v|h</dd>' )
410- + '<dt>' + ( ( imp ) ? parseInt ( 3.2808399 * position . gps_alt ) + ' ft' : parseInt ( position . gps_alt ) + ' m' ) + '</dt><dd>altitude</dd>'
411- + '<dt>' + ( ( imp ) ? parseInt ( 3.2808399 * vehicles [ index ] . max_alt ) + ' ft' : parseInt ( vehicles [ index ] . max_alt ) + ' m' ) + '</dt><dd>max alt</dd>'
420+ + '<dt>' + text_alt + '</dt><dd>altitude</dd>'
421+ + '<dt>' + text_alt_max + '</dt><dd>max alt</dd>'
412422 + '' ;
413423 // mid for landscape
414424 var l = ( ( vehicles [ index ] . vehicle_type == "car" ) ? '' : '<dt>' + ascent_text + ' ' + hrate_text + '</dt><dd>rate v|h</dd>' )
415- + '<dt>' + ( ( imp ) ? parseInt ( 3.2808399 * position . gps_alt ) + 'ft' : parseInt ( position . gps_alt ) + 'm' ) + ' (' + ( ( imp ) ? parseInt ( 3.2808399 * vehicles [ index ] . max_alt ) + 'ft' : parseInt ( vehicles [ index ] . max_alt ) + 'm' ) + ')</dt><dd>altitude (max)</dd>'
425+ + '<dt>' + text_alt + ' (' + text_alt_max + ')</dt><dd>altitude (max)</dd>'
416426 + '<dt>' + position . gps_time + '</dt><dd>datetime</dd>'
417427 + '<dt>' + coords_text + '</dt><dd>coordinates</dd>'
418428 + habitat_data ( position . data )
0 commit comments