added browser notifications

This commit is contained in:
Nicolas Constant 2020-03-21 15:23:57 -04:00 committed by Luc Didry
parent 680dc5f0d0
commit 538bf77cbe
No known key found for this signature in database
GPG Key ID: EA868E12D0257E3C
5 changed files with 29 additions and 0 deletions

View File

@ -95,6 +95,7 @@ function spawnWebsocket(pa) {
if (data.part + 1 === data.total) {
var blob = new Blob(a, {type: data.type});
notify('File downloaded', data.name);
$('#please-wait').remove();
$('#loading').remove();

View File

@ -0,0 +1,24 @@
function notify(title, body) {
if (!Notification) {
return;
}
if (Notification.permission !== "granted") {
Notification.requestPermission();
} else {
let options = {
body: body,
icon: '/img/lufi196.png'
};
let n = new Notification(title, options);
}
}
document.addEventListener('DOMContentLoaded', function () {
if (!Notification) {
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
});

View File

@ -477,6 +477,8 @@ function updateProgressBar(data) {
console.log('Error on WebSocket connection but file has been fully send, so we don\'t care.');
}
notify('File uploaded', data.name);
$('#parts-'+window.fc).remove();
var n = $('#name-'+window.fc);
var s = $('#size-'+window.fc);

View File

@ -165,5 +165,6 @@
%= javascript '/js/moment-with-locales.min.js'
%= javascript '/js/filesize.min.js'
%= javascript '/js/jszip.min.js'
%= javascript '/js/lufi-notifications.js'
%= javascript '/js/lufi-up.js'
% }

View File

@ -45,6 +45,7 @@
%= javascript '/js/filesize.min.js'
%= javascript '/js/sjcl.js'
%= javascript '/js/jszip.min.js'
%= javascript '/js/lufi-notifications.js'
%= javascript '/js/lufi-down.js'
% }
% }