Merge branch 'espruino:master' into master

master
jeonlab 2024-06-17 11:05:24 -04:00 committed by GitHub
commit c40c4d4241
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 32 additions and 11 deletions

View File

@ -405,7 +405,7 @@ in an iframe.
<link rel="stylesheet" href="../../css/spectre.min.css"> <link rel="stylesheet" href="../../css/spectre.min.css">
</head> </head>
<body> <body>
<script src="../../lib/interface.js"></script> <script src="../../core/lib/interface.js"></script>
<div id="t">Loading...</div> <div id="t">Loading...</div>
<script> <script>
function onInit() { function onInit() {

View File

@ -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

View File

@ -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

View File

@ -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"],

View File

@ -17,12 +17,12 @@
}; };
var colours = (_a = {}, var colours = (_a = {},
_a[1] = { _a[1] = {
false: "#fff", false: "#000",
true: "#fff", true: "#fff",
}, },
_a[2] = { _a[2] = {
false: "#0ff", false: "#00f",
true: "#00f", true: "#0ff",
}, },
_a); _a);
WIDGETS["bluetooth"] = { WIDGETS["bluetooth"] = {

View File

@ -30,12 +30,12 @@
} }
} = { } = {
[State.Active]: { [State.Active]: {
false: "#fff", false: "#000",
true: "#fff", true: "#fff",
}, },
[State.Connected]: { [State.Connected]: {
false: "#0ff", false: "#00f",
true: "#00f", true: "#0ff",
}, },
}; };