Merge branch 'master' into ui

This commit is contained in:
Danny Coates 2017-06-21 14:04:12 -07:00 committed by GitHub
commit be3df22757
9 changed files with 55 additions and 6 deletions

View file

@ -1,4 +1,5 @@
const FileReceiver = require('./fileReceiver');
const { notify } = require('./utils');
const $ = require('jquery');
$(document).ready(function() {
@ -27,6 +28,7 @@ $(document).ready(function() {
$('.send-new').show();
$btn.text('Download complete!');
$btn.attr('disabled', 'true');
notify('Your download has finished.');
}
});

View file

@ -1,5 +1,5 @@
const EventEmitter = require('events');
const { ivToStr } = require('./utils');
const { ivToStr, notify } = require('./utils');
class FileSender extends EventEmitter {
constructor(file) {
@ -23,7 +23,7 @@ class FileSender extends EventEmitter {
}
if (xhr.status === 200) {
console.log('The file was successfully deleted.');
console.log('The file was successfully deleted.')
} else {
console.log('The file has expired, or has already been deleted.');
}

View file

@ -1,4 +1,5 @@
const FileSender = require('./fileSender');
const { notify } = require('./utils')
const $ = require('jquery');
$(document).ready(function() {
@ -94,6 +95,9 @@ $(document).ready(function() {
.querySelector('#progress-bar')
.style.setProperty('--progress', percentComplete + '%');
$('#progress-text').html(`${percentComplete}%`);
if (percentComplete === 100) {
notify('Your upload has finished.');
}
});
fileSender.upload().then(info => {
const url = info.url.trim() + `#${info.secretKey}`.trim();

View file

@ -20,7 +20,21 @@ function strToIv(str) {
return iv;
}
function notify(str) {
if (!("Notification" in window)) {
return;
} else if (Notification.permission === 'granted') {
new Notification(str)
} else if (Notification.permission !== 'denied') {
Notification.requestPermission(function(permission) {
if (permission === 'granted')
new Notification(str);
})
}
}
module.exports = {
ivToStr,
strToIv
strToIv,
notify
};