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,
|
serviceName: config.basic.serviceName,
|
||||||
templates: readTemplates(grunt),
|
templates: readTemplates(grunt),
|
||||||
timestamp: grunt.template.today('isoDateTime'),
|
timestamp: grunt.template.today('isoDateTime'),
|
||||||
|
maxPostSize: config.database.maxPostSize,
|
||||||
tagCategories: config.tags.categories,
|
tagCategories: config.tags.categories,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,12 +4,14 @@
|
||||||
<head
|
<head
|
||||||
data-version="dev"
|
data-version="dev"
|
||||||
data-build-time=""
|
data-build-time=""
|
||||||
|
data-max-post-size="10485760"
|
||||||
data-tag-categories='["meta","character","artist","copyright"]'>
|
data-tag-categories='["meta","character","artist","copyright"]'>
|
||||||
<!-- /build -->
|
<!-- /build -->
|
||||||
<!-- build:template
|
<!-- build:template
|
||||||
<head
|
<head
|
||||||
data-version="<%= version %>"
|
data-version="<%= version %>"
|
||||||
data-build-time="<%= timestamp %>"
|
data-build-time="<%= timestamp %>"
|
||||||
|
data-max-post-size="<%= maxPostSize %>"
|
||||||
data-tag-categories='<%= JSON.stringify(tagCategories).replace(/'/g, ''') %>'>
|
data-tag-categories='<%= JSON.stringify(tagCategories).replace(/'/g, ''') %>'>
|
||||||
/build -->
|
/build -->
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
|
|
|
@ -25,10 +25,12 @@ App.Presenters.PostUploadPresenter = function(
|
||||||
var interactionEnabled = true;
|
var interactionEnabled = true;
|
||||||
var currentUploadId = null;
|
var currentUploadId = null;
|
||||||
var currentUploadXhr = null;
|
var currentUploadXhr = null;
|
||||||
|
var maxPostSize = 0;
|
||||||
|
|
||||||
function init(params, loaded) {
|
function init(params, loaded) {
|
||||||
topNavigationPresenter.select('upload');
|
topNavigationPresenter.select('upload');
|
||||||
topNavigationPresenter.changeTitle('Upload');
|
topNavigationPresenter.changeTitle('Upload');
|
||||||
|
maxPostSize = parseInt(jQuery('head').attr('data-max-post-size'));
|
||||||
|
|
||||||
promise.wait(util.promiseTemplate('post-upload'))
|
promise.wait(util.promiseTemplate('post-upload'))
|
||||||
.then(function(template) {
|
.then(function(template) {
|
||||||
|
@ -117,6 +119,12 @@ App.Presenters.PostUploadPresenter = function(
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
var posts = [];
|
var posts = [];
|
||||||
for (var i = 0; i < files.length; i ++) {
|
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]);
|
var post = addPostFromFile(files[i]);
|
||||||
posts.push(post);
|
posts.push(post);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue