Prevent upload if the subject is required. Close #660.

This commit is contained in:
Nicolas Stepien 2012-08-20 00:18:39 +02:00
parent 26c18d1526
commit 8a965fe9fc
2 changed files with 24 additions and 8 deletions

View File

@ -2354,7 +2354,7 @@
}));
},
submit: function(e) {
var callbacks, captcha, captchas, challenge, err, m, opts, post, reply, response, threadID;
var callbacks, captcha, captchas, challenge, err, m, opts, post, reply, response, threadID, _ref;
if (e != null) {
e.preventDefault();
}
@ -2366,9 +2366,18 @@
QR.abort();
reply = QR.replies[0];
threadID = g.THREAD_ID || $('select', QR.el).value;
if (!(threadID === 'new' && reply.file || threadID !== 'new' && (reply.com || reply.file))) {
err = 'No file selected.';
} else if (QR.captchaIsEnabled) {
if (threadID === 'new') {
if (((_ref = g.BOARD) === 'vg' || _ref === 'q') && !reply.sub) {
err = 'New threads require a subject.';
} else if (!reply.file) {
err = 'No file selected.';
}
} else {
if (!(reply.com || reply.file)) {
err = 'No file selected.';
}
}
if (QR.captchaIsEnabled && !err) {
captchas = $.get('captchas', []);
while ((captcha = captchas[0]) && captcha.time < Date.now()) {
captchas.shift();

View File

@ -1824,14 +1824,21 @@ QR =
QR.status()
return
QR.abort()
reply = QR.replies[0]
reply = QR.replies[0]
threadID = g.THREAD_ID or $('select', QR.el).value
# prevent errors
unless threadID is 'new' and reply.file or threadID isnt 'new' and (reply.com or reply.file)
err = 'No file selected.'
else if QR.captchaIsEnabled
if threadID is 'new'
if g.BOARD in ['vg', 'q'] and !reply.sub
err = 'New threads require a subject.'
else unless reply.file
err = 'No file selected.'
else
unless reply.com or reply.file
err = 'No file selected.'
if QR.captchaIsEnabled and !err
# get oldest valid captcha
captchas = $.get 'captchas', []
# remove old captchas