-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenderer.js
61 lines (51 loc) · 1.89 KB
/
renderer.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const { ipcRenderer } = require('electron');
const startBtn = document.getElementById('startBtn');
const stopBtn = document.getElementById('stopBtn');
const resetBtn = document.getElementById('resetBtn');
const timerMinutes = document.getElementById('timerMinutes');
const timerSeconds = document.getElementById('timerSeconds');
const modal = document.getElementById('myModal');
const dontShowAgainCheckbox = document.getElementById('dontShowAgain');
startBtn.addEventListener('click', () => {
ipcRenderer.send('startApp');
startBtn.style.display = 'none'; // Hide the Start button
stopBtn.style.display = 'inline-block'; // Display the Stop button
});
stopBtn.addEventListener('click', () => {
ipcRenderer.send('stopApp');
stopBtn.style.display = 'none'; // Hide the Stop button
startBtn.style.display = 'inline-block'; // Display the Start button
});
resetBtn.addEventListener('click', () => {
ipcRenderer.send('stopApp');
ipcRenderer.send('startApp');
})
ipcRenderer.on('updateTimer', (event, minutes, seconds) => {
timerMinutes.textContent = minutes < 10 ? '0' + minutes : minutes;
timerSeconds.textContent = seconds < 10 ? '0' + seconds : seconds;
});
const showModal = () => {
modal.style.display = 'block';
};
const closeModal = () => {
modal.style.display = 'none';
};
window.onload = () => {
localStorage.removeItem('hideModal');
const shouldShowModal = !localStorage.getItem('hideModal');
if (shouldShowModal) {
showModal();
}
};
// Close the modal when the user clicks on the close button
modal.querySelector('.close').addEventListener('click', () => {
closeModal();
});
// Save user preference when the checkbox is clicked
dontShowAgainCheckbox.addEventListener('change', () => {
if (dontShowAgainCheckbox.checked) {
localStorage.setItem('hideModal', 'true');
} else {
localStorage.removeItem('hideModal');
}
});