Merge pull request #3451 from paul-arg/elapsed_t
elapsed_t: add option to set clock as default and handle DST in day/month/year modemaster
commit
20810b4403
|
|
@ -1,2 +1,3 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
0.02: Handle AM/PM time in the "set target" menu. Add yesterday/today/tomorrow when showing target date to improve readability.
|
0.02: Handle AM/PM time in the "set target" menu. Add yesterday/today/tomorrow when showing target date to improve readability.
|
||||||
|
0.03: Add option to set clock as default, handle DST in day/month/year mode
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ function writeSettings() {
|
||||||
let inMenu = false;
|
let inMenu = false;
|
||||||
|
|
||||||
Bangle.on('touch', function (zone, e) {
|
Bangle.on('touch', function (zone, e) {
|
||||||
if (!inMenu) {
|
if (!inMenu && e.y > 24) {
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
E.showMenu(menu);
|
E.showMenu(menu);
|
||||||
inMenu = true;
|
inMenu = true;
|
||||||
|
|
@ -206,9 +206,25 @@ var menu = {
|
||||||
setTarget(false);
|
setTarget(false);
|
||||||
updateQueueMillis(settings.displaySeconds);
|
updateQueueMillis(settings.displaySeconds);
|
||||||
draw();
|
draw();
|
||||||
|
},
|
||||||
|
'Set clock as default': function () {
|
||||||
|
setClockAsDefault();
|
||||||
|
E.showAlert("Elapsed Time was set as default").then(function() {
|
||||||
|
E.showMenu();
|
||||||
|
inMenu = false;
|
||||||
|
Bangle.setUI("clock");
|
||||||
|
draw();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function setClockAsDefault(){
|
||||||
|
let storage = require('Storage');
|
||||||
|
let settings = storage.readJSON('setting.json',true)||{clock:null};
|
||||||
|
settings.clock = "elapsed_t.app.js";
|
||||||
|
storage.writeJSON('setting.json', settings);
|
||||||
|
}
|
||||||
|
|
||||||
function setTarget(set) {
|
function setTarget(set) {
|
||||||
if (set) {
|
if (set) {
|
||||||
target = new Date(
|
target = new Date(
|
||||||
|
|
@ -276,6 +292,10 @@ function updateQueueMillis(displaySeconds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Bangle.on('lock', function (on, reason) {
|
Bangle.on('lock', function (on, reason) {
|
||||||
|
if (inMenu) { // if already in a menu, nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (on) { // screen is locked
|
if (on) { // screen is locked
|
||||||
temp_displaySeconds = false;
|
temp_displaySeconds = false;
|
||||||
updateQueueMillis(false);
|
updateQueueMillis(false);
|
||||||
|
|
@ -326,7 +346,7 @@ function diffToTarget() {
|
||||||
diff.M = end.getMonth() - start.getMonth();
|
diff.M = end.getMonth() - start.getMonth();
|
||||||
diff.D = end.getDate() - start.getDate();
|
diff.D = end.getDate() - start.getDate();
|
||||||
diff.hh = end.getHours() - start.getHours();
|
diff.hh = end.getHours() - start.getHours();
|
||||||
diff.mm = end.getMinutes() - start.getMinutes();
|
diff.mm = end.getMinutes() - start.getMinutes() + end.getTimezoneOffset() - start.getTimezoneOffset();
|
||||||
diff.ss = end.getSeconds() - start.getSeconds();
|
diff.ss = end.getSeconds() - start.getSeconds();
|
||||||
|
|
||||||
// Adjust negative differences
|
// Adjust negative differences
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"name": "Elapsed Time Clock",
|
"name": "Elapsed Time Clock",
|
||||||
"shortName": "Elapsed Time",
|
"shortName": "Elapsed Time",
|
||||||
"type": "clock",
|
"type": "clock",
|
||||||
"version":"0.02",
|
"version":"0.03",
|
||||||
"description": "A clock that calculates the time difference between now and any given target date.",
|
"description": "A clock that calculates the time difference between now and any given target date.",
|
||||||
"tags": "clock,tool",
|
"tags": "clock,tool",
|
||||||
"supports": ["BANGLEJS2"],
|
"supports": ["BANGLEJS2"],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue