2022-05-28 06:50:12 +00:00
|
|
|
(() => {
|
2022-05-29 09:22:00 +00:00
|
|
|
const strength = Object.assign({
|
|
|
|
strength: 1,
|
|
|
|
}, require('Storage').readJSON("widshipbell.json", true) || {}).strength;
|
|
|
|
|
|
|
|
function replaceAll(target, search, replacement) {
|
|
|
|
return target.split(search).join(replacement);
|
|
|
|
}
|
2022-05-28 06:50:12 +00:00
|
|
|
|
|
|
|
function check() {
|
|
|
|
const now = new Date();
|
|
|
|
const currentMinute = now.getMinutes();
|
|
|
|
const currentSecond = now.getSeconds();
|
|
|
|
const etaMinute = 30-(currentMinute % 30);
|
|
|
|
|
|
|
|
if (etaMinute === 30 && currentSecond === 0) {
|
|
|
|
const strikeHour = now.getHours() % 4;
|
|
|
|
// buzz now
|
|
|
|
let pattern='';
|
|
|
|
if (strikeHour === 0 && currentMinute == 0) {
|
2022-05-29 09:22:00 +00:00
|
|
|
pattern = '.. .. .. ..';
|
2022-05-29 12:30:38 +00:00
|
|
|
} else if (strikeHour === 0 && currentMinute === 30) {
|
2022-05-28 06:50:12 +00:00
|
|
|
pattern = '.';
|
2022-05-29 12:30:38 +00:00
|
|
|
} else if (strikeHour === 1 && currentMinute === 0) {
|
2022-05-28 06:50:12 +00:00
|
|
|
pattern = '..';
|
2022-05-29 12:30:38 +00:00
|
|
|
} else if (strikeHour === 1 && currentMinute === 30) {
|
2022-05-29 09:22:00 +00:00
|
|
|
pattern = '.. .';
|
2022-05-29 12:30:38 +00:00
|
|
|
} else if (strikeHour === 2 && currentMinute === 0) {
|
2022-05-29 09:22:00 +00:00
|
|
|
pattern = '.. ..';
|
2022-05-29 12:30:38 +00:00
|
|
|
} else if (strikeHour === 2 && currentMinute === 30) {
|
2022-05-29 09:22:00 +00:00
|
|
|
pattern = '.. .. .';
|
2022-05-29 12:30:38 +00:00
|
|
|
} else if (strikeHour === 3 && currentMinute === 0) {
|
2022-05-29 09:22:00 +00:00
|
|
|
pattern = '.. .. ..';
|
2022-05-29 12:30:38 +00:00
|
|
|
} else if (strikeHour === 3 && currentMinute === 30) {
|
2022-05-29 09:22:00 +00:00
|
|
|
pattern = '.. .. .. .';
|
|
|
|
}
|
2022-05-29 12:30:38 +00:00
|
|
|
pattern = replaceAll(pattern, ' ', ' '); // 4x pause
|
|
|
|
pattern = replaceAll(pattern, '.', '. '); // pause between bells
|
2022-05-29 09:22:00 +00:00
|
|
|
if (strength === 2) { // strong selected
|
|
|
|
pattern = replaceAll(pattern, '.', ':');
|
2022-05-28 06:50:12 +00:00
|
|
|
}
|
|
|
|
require("buzz").pattern(pattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
const etaSecond = etaMinute*60-currentSecond;
|
|
|
|
setTimeout(check, etaSecond*1000);
|
|
|
|
}
|
|
|
|
|
2022-05-29 09:22:00 +00:00
|
|
|
if (strength !== 0) {
|
2022-05-28 06:50:12 +00:00
|
|
|
check();
|
|
|
|
}
|
|
|
|
})();
|