-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenderer.js.bak
166 lines (109 loc) · 4.11 KB
/
renderer.js.bak
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
const ipc = require('electron').ipcRenderer;
ipc.send('pathGet');
ipc.on('pathGot', function (event, sp) {
document.getElementById("REEnter").setAttribute('src', sp.replace(/\\/g, "/") + "/audio/REEnter.wav");
document.getElementById("REEnterAudio").load();
document.getElementById("hellorrwp").setAttribute('src', sp.replace(/\\/g, "/") + "/audio/hellorrwp.wav");
document.getElementById("hellorrwpAudio").load();
document.getElementById("leave").setAttribute('src', sp.replace(/\\/g, "/") + "/audio/leave.wav");
document.getElementById("leaveAudio").load();
});
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// No Node.js APIs are available in this process because
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering
// process.
var toggleBtn = document.getElementById("toggleAnnouncements");
var allContainer = document.getElementById("allContainer");
var aCC = document.getElementById("allContainerCover");
var whetherOoO = document.getElementById("whetherOoO");
var announcements = true;
toggleBtn.onclick = function() {
if (announcements === true) {
announcements = false;
toggleBtn.innerHTML = "turn on";
aCC.classList.remove("aCCon");
aCC.classList.add("aCCoff");
whetherOoO.innerHTML = "off";
} else {
announcements = true;
toggleBtn.innerHTML = "turn off";
aCC.classList.remove("aCCoff");
aCC.classList.add("aCCon");
whetherOoO.innerHTML = "on";
}
};
toggleBtn.click();
function playStart(time){
document.getElementById("hellorrwpAudio").play();
setTimeout(function(){
var msg = new SpeechSynthesisUtterance();
msg.text = time;
window.speechSynthesis.speak(msg);
setTimeout(function(){
document.getElementById("leaveAudio").play();
},1500);
}, 2800);
}
function playEnd(){
document.getElementById("REEnterAudio").play();
}
function startTimer(numomins, nomosecs){
var min = document.getElementById("min");
var sec = document.getElementById("sec");
var minVal = numomins;
var secVal = nomosecs;
const timerInterval = setInterval(function() {
var d = Math.random();
if (d > 0.94) {
clearInterval(timerInterval);
let d2 = new Date();
startTimer( ((d2.getMinutes() < 45) ? 44 - d2.getMinutes() : 59 - d2.getMinutes() ), 60 - d2.getSeconds() );
}
if (secVal == 1 && minVal == 0) {
clearInterval(timerInterval);
let d2 = new Date();
startTimer( ((d2.getMinutes() < 45) ? 44 - d2.getMinutes() : 59 - d2.getMinutes() ), 60 - d2.getSeconds() );
if (announcements) {
if (d2.getMinutes() == 44 || d2.getMinutes() == 45) {
playStart( ((d2.getHours() + 24) % 12 || 12) + ":45" );
}
if (d2.getMinutes() == 59 || d2.getMinutes() == 0) {
playEnd();
}
}
}
if (secVal > 0) {
secVal--;
} else {
secVal = 59;
minVal--;
}
min.innerHTML = ((minVal < 10) ? "0" + minVal : minVal);
sec.innerHTML = ((secVal < 10) ? "0" + secVal : secVal);
}, 1000);
}
let d2 = new Date();
startTimer( ((d2.getMinutes() < 45) ? 44 - d2.getMinutes() : 59 - d2.getMinutes() ), 60 - d2.getSeconds() );
// MANUAL ANNOUNCEMENT STUFF
var modal = document.getElementById("manualModal");
// Get the button that opens the modal
var btn = document.getElementById("manualBtn");
// Get the <span> element that closes the modal
var closeModal = document.getElementById("closeModal");
// When the user clicks on the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
document.getElementById("manualTime").value = ( (new Date().getMinutes() < 50) ? ( ((new Date().getHours() + 24) % 12 || 12) + ":45" ) : ( ((new Date().getHours() + 25) % 12 || 12) + ":45" ) );
}
// When the user clicks on <span> (x), close the modal
closeModal.onclick = function() {
modal.style.display = "none";
}
document.getElementById("manualStartBtn").onclick = function(){
playStart(document.getElementById("manualTime").value);
};
document.getElementById("manualEndBtn").onclick = function(){
playEnd();
};