-
Notifications
You must be signed in to change notification settings - Fork 0
/
bell.js
40 lines (30 loc) · 1015 Bytes
/
bell.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// const schedules = require("./schedules.json");
function secondLoop() {
let date = new Date().toString().split(" ");
// console.log(schedules[date[0]]);
let timeParts = date[4].split(":");
if (timeParts[0].startsWith("0"))
timeParts[0] = timeParts[0].substring(1);
let actualTime = timeParts[0] + ":" + timeParts[1];
if (schedules[date[0]].includes(actualTime) && !playing && parseInt(timeParts[2]) < 5) {
// if (voice1)
// voice1.play("bell.mp3");
// voice2.play("bell.mp3");
// voice3.play("bell.mp3");
// voice4.play("bell.mp3");
// if (testVoice)
// testVoice.play("bell.mp3");
//play(voice1, "bell.mp3");
//play(testVoice, "bell.mp3");
document.getElementById("bell-sound").play();
playing = true;
}
if (parseInt(timeParts[2]) > 5)
playing = false;
}
window.addEventListener("load", () => {
setInterval(secondLoop, 1000);
document.getElementById("test-button").addEventListener("click", () => {
document.getElementById("test-sound").play();
});
});