Skip to content

Commit c30830d

Browse files
add option to display imperial units
1 parent 15fb965 commit c30830d

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

cache.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# version 18
2+
# version 24
33

44
# gogole maps files
55
http://maps.google.com/maps/api/js?v=3.10&sensor=false&key=AIzaSyCOqkcNey4CCyG4X0X5qxHAhCgD8g5DwXg

index.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ <h2>Settings</h2>
6363
<input type="checkbox" id="opt_daylight">
6464
</div>
6565
</div>
66+
<div class="row option">
67+
<span><b>Imperial units</b></span>
68+
<div class="switch off" id="sw_imperial">
69+
<span class="thumb"></span>
70+
<input type="checkbox" id="opt_imperial">
71+
</div>
72+
</div>
6673
<div class="row option">
6774
<span><b>Availability offline</b></span>
6875
<div class="switch off" id="sw_offline">
@@ -79,7 +86,7 @@ <h2>Settings</h2>
7986
</div>
8087
<div class="row info">
8188
<span>
82-
In Chase Car mode, a station will appear together with the chase car on the map.
89+
Chase car equipped with radio reciever
8390
</span>
8491
</div>
8592
<div class="row option">
@@ -91,7 +98,6 @@ <h2>Settings</h2>
9198
</div>
9299
<div class="row info">
93100
<span>
94-
Make sure you have a stable internet connection.
95101
The size of cache files is around 600 KB.
96102
</span>
97103
</div>

js/app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ $(window).ready(function() {
312312
if(offline.get('opt_daylight')) $('#sw_daylight').removeClass('off').addClass('on');
313313

314314
// offline and mobile
315-
$('#sw_offline, #sw_station').click(function() {
315+
$('#sw_offline, #sw_station, #sw_imperial').click(function() {
316316
var e = $(this);
317317
var name = e.attr('id').replace('sw', 'opt');
318318
var on;
@@ -326,10 +326,12 @@ $(window).ready(function() {
326326
}
327327

328328
offline.set(name, on);
329+
if(name == "opt_imperial") refreshUI();
329330
});
330331

331332
if(offline.get('opt_offline')) $('#sw_offline').removeClass('off').addClass('on');
332333
if(offline.get('opt_station')) $('#sw_station').removeClass('off').addClass('on');
334+
if(offline.get('opt_imperial')) $('#sw_imperial').removeClass('off').addClass('on');
333335

334336
// force re-cache
335337
$('#sw_cache').click(function() {

js/mobile.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/tracker.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ function updateVehicleInfo(index, position) {
342342

343343
}
344344

345-
var ascent_text = position.gps_alt != 0 ? vehicles[index].ascent_rate.toFixed(1) + ' m/s' : '';
345+
var imp = offline.get('opt_imperial');
346+
var ascent_text = imp ? (vehicles[index].ascent_rate * 196.850394).toFixed(1) + ' ft/min' : vehicles[index].ascent_rate.toFixed(1) + ' m/s';
346347

347348
var coords_text;
348349
var ua = navigator.userAgent.toLowerCase();
@@ -358,6 +359,8 @@ function updateVehicleInfo(index, position) {
358359
} else {
359360
coords_text = roundNumber(position.gps_lat, 6) + ', ' + roundNumber(position.gps_lon, 6);
360361
}
362+
363+
361364
// start
362365
var a = '<div class="header"><span>' + vehicle_names[index] + '</span><i class="arrow"></i></div>'
363366
+ '<div class="data">'
@@ -382,13 +385,13 @@ function updateVehicleInfo(index, position) {
382385
+ '</div>' // left
383386
+ '<div class="right">'
384387
+ '<dl>'
385-
+ '<dt>'+ascent_text+'</dt><dd>rate</dd>'
386-
+ '<dt>'+position.gps_alt+' m</dt><dd>altitude</dd>'
387-
+ '<dt>'+vehicles[index].max_alt+' m</dt><dd>max alt</dd>'
388+
+ (position.gps_alt != 0 ? '<dt>'+ascent_text+'</dt><dd>rate</dd>' : '')
389+
+ '<dt>'+((imp) ? parseInt(3.2808399 * position.gps_alt) + ' ft': position.gps_alt + ' m')+'</dt><dd>altitude</dd>'
390+
+ '<dt>'+((imp) ? parseInt(3.2808399 * vehicles[index].max_alt) + ' ft': vehicles[index].max_alt + ' m')+'</dt><dd>max alt</dd>'
388391
+ '';
389392
// mid for landscape
390-
var l = '<dt>'+ascent_text+'</dt><dd>rate</dd>'
391-
+ '<dt>'+position.gps_alt+'m ('+vehicles[index].max_alt+'m)</dt><dd>altitude (max)</dd>'
393+
var l = (position.gps_alt != 0 ? '<dt>'+ascent_text+'</dt><dd>rate</dd>' : '')
394+
+ '<dt>'+((imp) ? parseInt(3.2808399 * position.gps_alt) + 'ft': position.gps_alt + 'm')+' ('+((imp) ? parseInt(3.2808399 * vehicles[index].max_alt) + 'ft' : vehicles[index].max_alt + 'm')+')</dt><dd>altitude (max)</dd>'
392395
+ '<dt>'+position.gps_time+'</dt><dd>datetime</dd>'
393396
+ '<dt>'+coords_text+'</dt><dd>coordinates</dd>'
394397
+ habitat_data(position.data)
@@ -906,6 +909,12 @@ function updatePredictions(r) {
906909
}
907910
}
908911

912+
function refreshUI() {
913+
for (var i = 0, ii = vehicle_names.length; i < ii; i++) {
914+
updateVehicleInfo(i, vehicles[i].curr_position);
915+
}
916+
}
917+
909918
var status = "";
910919

911920
function update(response) {
@@ -941,7 +950,7 @@ function update(response) {
941950
lastPPointer.push(vehicles[vehicle_index].curr_position);
942951
}
943952

944-
// store the in localStorage
953+
// store in localStorage
945954
offline.set('positions', lastPositions);
946955

947956
if(follow_vehicle != -1) {

0 commit comments

Comments
 (0)