Added client-side warning about too large files
This commit is contained in:
parent
13e622f9e7
commit
2856b67018
3 changed files with 11 additions and 0 deletions
|
@ -135,6 +135,7 @@ module.exports = function(grunt) {
|
|||
serviceName: config.basic.serviceName,
|
||||
templates: readTemplates(grunt),
|
||||
timestamp: grunt.template.today('isoDateTime'),
|
||||
maxPostSize: config.database.maxPostSize,
|
||||
tagCategories: config.tags.categories,
|
||||
}
|
||||
},
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
<head
|
||||
data-version="dev"
|
||||
data-build-time=""
|
||||
data-max-post-size="10485760"
|
||||
data-tag-categories='["meta","character","artist","copyright"]'>
|
||||
<!-- /build -->
|
||||
<!-- build:template
|
||||
<head
|
||||
data-version="<%= version %>"
|
||||
data-build-time="<%= timestamp %>"
|
||||
data-max-post-size="<%= maxPostSize %>"
|
||||
data-tag-categories='<%= JSON.stringify(tagCategories).replace(/'/g, ''') %>'>
|
||||
/build -->
|
||||
<meta charset="utf-8"/>
|
||||
|
|
|
@ -25,10 +25,12 @@ App.Presenters.PostUploadPresenter = function(
|
|||
var interactionEnabled = true;
|
||||
var currentUploadId = null;
|
||||
var currentUploadXhr = null;
|
||||
var maxPostSize = 0;
|
||||
|
||||
function init(params, loaded) {
|
||||
topNavigationPresenter.select('upload');
|
||||
topNavigationPresenter.changeTitle('Upload');
|
||||
maxPostSize = parseInt(jQuery('head').attr('data-max-post-size'));
|
||||
|
||||
promise.wait(util.promiseTemplate('post-upload'))
|
||||
.then(function(template) {
|
||||
|
@ -117,6 +119,12 @@ App.Presenters.PostUploadPresenter = function(
|
|||
if (files.length > 0) {
|
||||
var posts = [];
|
||||
for (var i = 0; i < files.length; i ++) {
|
||||
if (files[i].size > maxPostSize) {
|
||||
window.alert('File "' + files[i].name + '" is too big - ignoring.' +
|
||||
String.fromCharCode(10) +
|
||||
'(max allowed file size = ' + maxPostSize + ' bytes)');
|
||||
continue;
|
||||
}
|
||||
var post = addPostFromFile(files[i]);
|
||||
posts.push(post);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue