2017-04-20 18:58:11 +00:00
|
|
|
;(function () {
|
2017-04-21 21:41:37 +00:00
|
|
|
var electron = require('electron');
|
|
|
|
var ipc = electron.ipcRenderer;
|
2017-04-20 18:58:11 +00:00
|
|
|
// This file runs in a render thread of the Electron app. It must be required (directly or
|
|
|
|
// indirectly) from one of the html files.
|
|
|
|
|
|
|
|
var count = 0;
|
|
|
|
function notifyUser() {
|
|
|
|
count += 1;
|
|
|
|
var notif = new window.Notification('Annoying Alert ' + count, {
|
|
|
|
body: 'See what happens when you try to click on it.',
|
|
|
|
silent: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
// Notifications are unclickable on my system currently, not sure why.
|
|
|
|
notif.onclick = function () {
|
|
|
|
console.log('notification ' + count + ' clicked');
|
|
|
|
notif.close();
|
|
|
|
};
|
|
|
|
notif.onclose = function () {
|
2017-04-21 21:41:37 +00:00
|
|
|
if (count < 10) {
|
|
|
|
setTimeout(notifyUser, 5000);
|
|
|
|
}
|
2017-04-20 18:58:11 +00:00
|
|
|
};
|
2017-04-21 21:41:37 +00:00
|
|
|
ipc.send('notification', count);
|
2017-04-20 18:58:11 +00:00
|
|
|
}
|
|
|
|
setTimeout(notifyUser, 1000);
|
|
|
|
}());
|