fix widchime: make it actually chime the hour instead of crashing
Actually only needs two semicolons to fix, but just add them everywheremaster
parent
bcc1f8cff2
commit
3fbf14cb23
|
|
@ -585,7 +585,7 @@
|
||||||
{ "id": "widchime",
|
{ "id": "widchime",
|
||||||
"name": "Hour Chime",
|
"name": "Hour Chime",
|
||||||
"icon": "widget.png",
|
"icon": "widget.png",
|
||||||
"version":"0.01",
|
"version":"0.02",
|
||||||
"description": "Buzz or beep on every whole hour.",
|
"description": "Buzz or beep on every whole hour.",
|
||||||
"tags": "widget",
|
"tags": "widget",
|
||||||
"type": "widget",
|
"type": "widget",
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
0.01: First version
|
0.01: First version
|
||||||
|
0.02: Bugfix: now it actually chimes the hour instead of crashing
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
(function() {
|
(function() {
|
||||||
// 0: off, 1: buzz, 2: beep, 3: both
|
// 0: off, 1: buzz, 2: beep, 3: both
|
||||||
const type = (require("Storage").readJSON("widchime.json", 1) || {type: 1}).type
|
const type = (require("Storage").readJSON("widchime.json", 1) || {type: 1}).type;
|
||||||
if (!type) return
|
if (!type) return;
|
||||||
|
|
||||||
function chime() {
|
function chime() {
|
||||||
if ((require("Storage").readJSON("setting.json", 1) || {}).quiet) return
|
if ((require("Storage").readJSON("setting.json", 1) || {}).quiet) return;
|
||||||
if (type&1) Bangle.buzz(100)
|
if (type&1) Bangle.buzz(100);
|
||||||
if (type&2) Bangle.beep()
|
if (type&2) Bangle.beep();
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastHour = (new Date()).getHours() // don't chime when (re)loaded at a whole hour
|
let lastHour = (new Date()).getHours(); // don't chime when (re)loaded at a whole hour
|
||||||
function check() {
|
function check() {
|
||||||
const now = new Date(),
|
const now = new Date(),
|
||||||
h = now.getHours(), m = now.getMinutes(),
|
h = now.getHours(), m = now.getMinutes(),
|
||||||
s = now.getSeconds(), ms = now.getMilliseconds()
|
s = now.getSeconds(), ms = now.getMilliseconds();
|
||||||
if (h!==lastHour && m===0) chime()
|
if (h!==lastHour && m===0) chime();
|
||||||
lastHour = h
|
lastHour = h;
|
||||||
// check again when this hour is over
|
// check again when this hour is over
|
||||||
const mLeft = 60-m, sLeft = (mLeft*60)-s, msLeft = (sLeft*1000)-ms
|
const mLeft = 60-m, sLeft = (mLeft*60)-s, msLeft = (sLeft*1000)-ms;
|
||||||
setTimeout(check, msLeft)
|
setTimeout(check, msLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
check()
|
check();
|
||||||
})
|
})
|
||||||
()
|
();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue