mirror of https://github.com/espruino/BangleApps
Merge pull request #3362 from jt-nti/thunder-units
thunder: Use the locale module to display distancepull/3184/head
commit
f975f653e1
|
@ -1 +1,2 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
|
0.02: Use locale module to display distance
|
||||||
|
|
|
@ -7,6 +7,8 @@ Bangle.setLCDTimeout(undefined);
|
||||||
let renderIntervalId;
|
let renderIntervalId;
|
||||||
let startTime;
|
let startTime;
|
||||||
|
|
||||||
|
const locale = require("locale");
|
||||||
|
|
||||||
const DEFAULTS = {
|
const DEFAULTS = {
|
||||||
units: 0,
|
units: 0,
|
||||||
};
|
};
|
||||||
|
@ -29,6 +31,9 @@ var layout = new Layout( {
|
||||||
back: load,
|
back: load,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO The code in this function appears in various apps so it might be
|
||||||
|
// nice to add something to the time_utils module. (There is already a
|
||||||
|
// formatDuration function but that doesn't quite work the same way.)
|
||||||
const getTime = function(milliseconds) {
|
const getTime = function(milliseconds) {
|
||||||
let hrs = Math.floor(milliseconds/3600000);
|
let hrs = Math.floor(milliseconds/3600000);
|
||||||
let mins = Math.floor(milliseconds/60000)%60;
|
let mins = Math.floor(milliseconds/60000)%60;
|
||||||
|
@ -52,12 +57,15 @@ const getDistance = function(milliseconds) {
|
||||||
let secs = milliseconds/1000;
|
let secs = milliseconds/1000;
|
||||||
let distance;
|
let distance;
|
||||||
|
|
||||||
if (settings.units === 0) {
|
if (settings.units === 1) {
|
||||||
let kms = Math.round((secs / 2.91) * 10) / 10;
|
let kms = Math.round((secs / 2.91) * 10) / 10;
|
||||||
distance = kms.toFixed(1) + "km";
|
distance = kms.toFixed(1) + "km";
|
||||||
} else {
|
} else if (settings.units === 2) {
|
||||||
let miles = Math.round((secs / 4.69) * 10) / 10;
|
let miles = Math.round((secs / 4.69) * 10) / 10;
|
||||||
distance = miles.toFixed(1) + "mi";
|
distance = miles.toFixed(1) + "mi";
|
||||||
|
} else {
|
||||||
|
let meters = (secs / 2.91) * 1000;
|
||||||
|
distance = locale.distance(meters);
|
||||||
}
|
}
|
||||||
|
|
||||||
return distance;
|
return distance;
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ "id": "thunder",
|
{ "id": "thunder",
|
||||||
"name": "Come on Thunder",
|
"name": "Come on Thunder",
|
||||||
"shortName":"Thunder",
|
"shortName":"Thunder",
|
||||||
"version":"0.01",
|
"version":"0.02",
|
||||||
"description": "Simple timer to calculate how far away lightning is",
|
"description": "Simple timer to calculate how far away lightning is",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "tool,weather",
|
"tags": "tool,weather",
|
||||||
"supports" : ["BANGLEJS2"],
|
"supports" : ["BANGLEJS2"],
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
|
"screenshots": [{ "url": "screenshot.png" }],
|
||||||
"allow_emulator": true,
|
"allow_emulator": true,
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"thunder.app.js","url":"app.js"},
|
{"name":"thunder.app.js","url":"app.js"},
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const showMenu = function() {
|
const showMenu = function() {
|
||||||
const unitOptions = ['kms','miles'];
|
const unitOptions = [/*LANG*/'Auto','kms','miles'];
|
||||||
|
|
||||||
const menu = {
|
const menu = {
|
||||||
'': {'title': 'Thunder'},
|
'': {'title': 'Thunder'},
|
||||||
|
|
Loading…
Reference in New Issue