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) { 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) { if (e != null) {
e.preventDefault(); e.preventDefault();
} }
@ -2366,9 +2366,18 @@
QR.abort(); QR.abort();
reply = QR.replies[0]; reply = QR.replies[0];
threadID = g.THREAD_ID || $('select', QR.el).value; threadID = g.THREAD_ID || $('select', QR.el).value;
if (!(threadID === 'new' && reply.file || threadID !== 'new' && (reply.com || reply.file))) { if (threadID === 'new') {
err = 'No file selected.'; if (((_ref = g.BOARD) === 'vg' || _ref === 'q') && !reply.sub) {
} else if (QR.captchaIsEnabled) { 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', []); captchas = $.get('captchas', []);
while ((captcha = captchas[0]) && captcha.time < Date.now()) { while ((captcha = captchas[0]) && captcha.time < Date.now()) {
captchas.shift(); captchas.shift();

View File

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