trying to resolve the issue for quiet time

pull/715/head
Weiming 2021-03-28 23:28:45 -04:00
parent 794b85834c
commit 4574726f5d
1 changed files with 23 additions and 15 deletions

View File

@ -1,21 +1,29 @@
(function() { (function() {
var setting = require('Storage').readJSON('hourstrike.json',1)||[]; var setting = require('Storage').readJSON('hourstrike.json',1)||[];
var notify_on = [];
if (setting.on_hour || setting.on_harlf_hour) { if (setting.on_hour || setting.on_harlf_hour) {
var cur = new Date(); var cur = new Date();
var cur_hour = cur.getHours(); var cur_hour = cur.getHours(), cur_sec = cur.getMinutes()*60+cur.getSeconds();
if (setting.start_hour<=cur_hour&&cur_hour<=setting.end_hour) { var notify_on = [1800, 3600];
var cur_sec = cur.getMinutes()*60+cur.getSeconds(); var notify_func = function() {
var notify_on = [1800, 3600]; Bangle.buzz(200, 0.5)
var t=cur_sec<notify_on[0]?notify_on[0]-cur_sec:notify_on[1]-cur_sec; .then(() => new Promise(resolve => setTimeout(resolve,200)))
var notify_func = function() { .then(() => Bangle.buzz(200, 0.5));
Bangle.buzz(100, 0.5) };
.then(() => new Promise(resolve => setTimeout(resolve,200))) var wait_sec = -1, notify_hour = cur_hour;
.then(() => Bangle.buzz(100, 0.5)); if (cur_sec<notify_on[0]) {
}; wait_sec = notify_on[0]-cur_sec;
if (t>0) { } else if (cur_sec<notify_on[1]) {
setTimeout(notify_func, t*1000); wait_sec = notify_on[1]-cur_sec;
setTimeout(load, t*1000 + 600); notify_hour += 1;
}
} }
if (wait_sec>0) {
if (setting.start_hour<=notify_hour&&notify_hour<=setting.end_hour) {
setTimeout(notify_func, wait_sec*1000);
setTimeout(load, wait_sec*1000 + 800);
} else {
setTimeout(load, t*1000 + 800);
}
} }
})(); })();