-
Notifications
You must be signed in to change notification settings - Fork 3
/
timepicker.js
42 lines (35 loc) · 1.47 KB
/
timepicker.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
var getGlobal = window.Bridge.getGlobal;
var ipcRenderer = window.Bridge.ipcRenderer;
var storage = window.Bridge.storage;
var openExternalURL = getGlobal('openExternalURL');
window.addEventListener('DOMContentLoaded', function(){
updateDarkMode();
storage.getMany(['streakNotificationsOn', 'streakNotificationsTime'], function(err, data) {
if(err) { throw err }
console.log(data);
document.querySelector('input[type="checkbox"]').checked = data.streakNotificationsOn;
document.querySelector('input[type="time"]').value = data.streakNotificationsTime;
});
document.querySelector('#cancel').addEventListener('click', function(e) {
getGlobal('closeTimePicker')();
});
document.querySelector('form').addEventListener('submit', function(e) {
e.preventDefault();
var notificationsOn = document.querySelector('input[type="checkbox"]').checked;
var notificationsTime = document.querySelector('input[type="time"]').value;
storage.set('streakNotificationsOn', notificationsOn);
storage.set('streakNotificationsTime', notificationsTime);
getGlobal('reloadMainWindow')();
getGlobal('closeTimePicker')();
})
});
ipcRenderer.on('darkModeChange', (event, arg) => {
updateDarkMode();
})
function updateDarkMode() {
if(getGlobal('darkMode')) {
document.body.classList.add('dark');
} else {
document.body.classList.remove('dark');
}
}