implemented notifications

This commit is contained in:
tigerbot 2017-04-20 12:58:11 -06:00
parent 7c877e66ff
commit 56fca5acf5
2 changed files with 25 additions and 0 deletions

View File

@ -9,5 +9,7 @@
We are using node <script>document.write(process.versions.node)</script>,
Chrome <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
<script>require('./notifications.js')</script>
</body>
</html>

23
notifications.js Normal file
View File

@ -0,0 +1,23 @@
;(function () {
// 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 () {
setTimeout(notifyUser, 5000);
};
}
setTimeout(notifyUser, 1000);
}());