Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

add file size limit message #256

Merged
merged 1 commit into from
Jul 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions frontend/src/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ require('jquery-circle-progress');

const Raven = window.Raven;
$(document).ready(function() {
$('#download-progress').hide();
//link back to homepage
$('.send-new').attr('href', window.location.origin);

Expand All @@ -23,8 +22,8 @@ $(document).ready(function() {
const fileReceiver = new FileReceiver();

fileReceiver.on('progress', progress => {
$('#download-page-one').hide();
$('#download-progress').show();
$('#download-page-one').attr('hidden', true);
$('#download-progress').removeAttr('hidden');
const percent = progress[0] / progress[1];
// update progress bar
$('#dl-progress').circleProgress('value', percent);
Expand All @@ -50,7 +49,7 @@ $(document).ready(function() {
.then(translated => {
notify(translated[0]);
$('.title').html(translated[1]);
})
});
}
});

Expand Down Expand Up @@ -78,9 +77,9 @@ $(document).ready(function() {
document.l10n.formatValue('expiredPageHeader')
.then(translated => {
$('.title').text(translated);
})
$('#download-btn').hide();
$('#expired-img').show();
});
$('#download-btn').attr('hidden', true);
$('#expired-img').removeAttr('hidden');
console.log('The file has expired, or has already been deleted.');
return;
})
Expand Down
53 changes: 24 additions & 29 deletions frontend/src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const Raven = window.Raven;

$(document).ready(function() {
gcmCompliant().catch(err => {
$('#page-one').hide();
$('#unsupported-browser').show();
$('#page-one').attr('hidden', true);
$('#unsupported-browser').removeAttr('hidden');
});

$('#file-upload').change(onUpload);
Expand All @@ -19,12 +19,6 @@ $(document).ready(function() {
$('#link').attr('disabled', false);
$copyBtn.attr('data-l10n-id', 'copyUrlFormButton');

$('#upload-progress').hide();
$('#share-link').hide();
$('#upload-error').hide();
$('#unsupported-browser').hide();
$('#compliance-error').hide();
$('#page-one').show();

if (localStorage.length === 0) {
toggleHeader();
Expand Down Expand Up @@ -75,6 +69,12 @@ $(document).ready(function() {
// on file upload by browse or drag & drop
function onUpload(event) {
event.preventDefault();
$('#page-one').attr('hidden', true);
$('#upload-error').attr('hidden', true);
$('#upload-progress').removeAttr('hidden');
//don't allow drag and drop when not on page-one
$('body').off('drop', onUpload);

let file = '';
if (event.type === 'drop') {
file = event.originalEvent.dataTransfer.files[0];
Expand All @@ -89,17 +89,11 @@ $(document).ready(function() {
location.reload();
document.l10n.formatValue('uploadCancelNotification')
.then(str => {
console.log('here')
notify(str);
})
});
});

fileSender.on('progress', progress => {
$('#page-one').hide();
$('#upload-error').hide();
$('#upload-progress').show();
//don't allow drag and drop when not on page-one
$('body').off('drop', onUpload);
const percent = progress[0] / progress[1];
// update progress bar
$('#ul-progress').circleProgress('value', percent);
Expand Down Expand Up @@ -163,23 +157,24 @@ $(document).ready(function() {
localStorage.setItem(info.fileId, JSON.stringify(fileData));
$('#upload-filename').attr('data-l10n-id', 'uploadSuccessConfirmHeader');
t = window.setTimeout(() => {
$('#page-one').hide();
$('#upload-progress').hide();
$('#upload-error').hide();
$('#share-link').show();
$('#page-one').attr('hidden', true);
$('#upload-progress').attr('hidden', true);
$('#upload-error').attr('hidden', true);
$('#share-link').removeAttr('hidden');
}, 2000);

populateFileList(JSON.stringify(fileData));
document.l10n.formatValue('notifyUploadDone').then(str => {
notify(str);
});
document.l10n.formatValue('notifyUploadDone')
.then(str => {
notify(str);
});
})
.catch(err => {
Raven.captureException(err);
console.log(err);
$('#page-one').hide();
$('#upload-progress').hide();
$('#upload-error').show();
$('#page-one').attr('hidden', true);
$('#upload-progress').attr('hidden', true);
$('#upload-error').removeAttr('hidden');
window.clearTimeout(t);
});
}
Expand Down Expand Up @@ -263,8 +258,8 @@ $(document).ready(function() {
document.body.removeChild(aux);
document.l10n.formatValue('copiedUrl')
.then(translated => {
link.innerHTML = translated;
})
link.innerHTML = translated;
});
window.setTimeout(() => {
const linkImg = document.createElement('img');
$(linkImg).addClass('icon-copy');
Expand Down Expand Up @@ -381,9 +376,9 @@ $(document).ready(function() {
function toggleHeader() {
//hide table header if empty list
if (document.querySelector('tbody').childNodes.length === 1) {
$('#file-list').hide();
$('#file-list').attr('hidden', true);
} else {
$('#file-list').show();
$('#file-list').removeAttr('hidden');
}
}
});
Loading