Merge pull request #820 from ihavenoface/pull-request

Add support for post with QR and tags on /f/. Close #566
This commit is contained in:
Mayhem 2012-11-16 16:15:57 -08:00
commit 39f02cd3f4
3 changed files with 41 additions and 16 deletions

View File

@ -1738,7 +1738,7 @@
$.on(link.firstChild, 'click', function() {
QR.open();
if (!g.REPLY) {
QR.threadSelector.value = 'new';
QR.threadSelector.value = g.BOARD === 'f' ? '9999' : 'new';
}
return $('textarea', QR.el).focus();
});
@ -2418,7 +2418,7 @@
id = thread.id.slice(1);
threads += "<option value=" + id + ">Thread " + id + "</option>";
}
QR.threadSelector = $.el('select', {
QR.threadSelector = g.BOARD === 'f' ? $('select[name=filetag]').cloneNode(true) : $.el('select', {
innerHTML: threads,
title: 'Create a new thread / Reply to a thread'
});
@ -2472,7 +2472,7 @@
}));
},
submit: function(e) {
var callbacks, captcha, captchas, challenge, err, m, opts, post, reply, response, textOnly, threadID, _ref;
var callbacks, captcha, captchas, challenge, err, filetag, m, opts, post, reply, response, textOnly, threadID, _ref;
if (e != null) {
e.preventDefault();
}
@ -2483,17 +2483,23 @@
}
QR.abort();
reply = QR.replies[0];
threadID = g.THREAD_ID || QR.threadSelector.value;
if (g.BOARD === 'f' && !g.REPLY) {
filetag = QR.threadSelector.value;
threadID = 'new';
} else {
threadID = g.THREAD_ID || QR.threadSelector.value;
}
if (threadID === 'new') {
threadID = null;
if (((_ref = g.BOARD) === 'vg' || _ref === 'q') && !reply.sub) {
err = 'New threads require a subject.';
} else if (!(reply.file || (textOnly = !!$('input[name=textonly]', $.id('postForm'))))) {
err = 'No file selected.';
} else if (g.BOARD === 'f' && filetag === '9999') {
err = 'Invalid tag specified.';
}
} else {
if (!(reply.com || reply.file)) {
err = 'No file selected.';
}
} else if (!(reply.com || reply.file)) {
err = 'No file selected.';
}
if (QR.captchaIsEnabled && !err) {
captchas = $.get('captchas', []);
@ -2544,6 +2550,7 @@
sub: reply.sub,
com: reply.com,
upfile: reply.file,
filetag: filetag,
spoiler: reply.spoiler,
textonly: textOnly,
mode: 'regist',

View File

@ -1,4 +1,6 @@
master
- noface
Added tags support on /f/.
2.36.1
- noface

View File

@ -1342,7 +1342,12 @@ QR =
link = $.el 'h1', innerHTML: "<a href=javascript:;>#{if g.REPLY then 'Reply to Thread' else 'Start a Thread'}</a>"
$.on link.firstChild, 'click', ->
QR.open()
QR.threadSelector.value = 'new' unless g.REPLY
unless g.REPLY
QR.threadSelector.value =
if g.BOARD is 'f'
'9999'
else
'new'
$('textarea', QR.el).focus()
$.before $.id('postForm'), link
@ -1885,9 +1890,13 @@ QR =
for thread in $$ '.thread'
id = thread.id[1..]
threads += "<option value=#{id}>Thread #{id}</option>"
QR.threadSelector = $.el 'select'
innerHTML: threads
title: 'Create a new thread / Reply to a thread'
QR.threadSelector =
if g.BOARD is 'f'
$('select[name=filetag]').cloneNode true
else
$.el 'select'
innerHTML: threads
title: 'Create a new thread / Reply to a thread'
$.prepend $('.move > span', QR.el), QR.threadSelector
$.on QR.threadSelector, 'mousedown', (e) -> e.stopPropagation()
$.on $('#autohide', QR.el), 'change', QR.toggleHide
@ -1933,16 +1942,22 @@ QR =
QR.abort()
reply = QR.replies[0]
threadID = g.THREAD_ID or QR.threadSelector.value
if g.BOARD is 'f' and not g.REPLY
filetag = QR.threadSelector.value
threadID = 'new'
else
threadID = g.THREAD_ID or QR.threadSelector.value
# prevent errors
if threadID is 'new'
threadID = null
if g.BOARD in ['vg', 'q'] and !reply.sub
err = 'New threads require a subject.'
else unless reply.file or textOnly = !!$ 'input[name=textonly]', $.id 'postForm'
err = 'No file selected.'
else
unless reply.com or reply.file
err = 'No file selected.'
else if g.BOARD is 'f' and filetag is '9999'
err = 'Invalid tag specified.'
else unless reply.com or reply.file
err = 'No file selected.'
if QR.captchaIsEnabled and !err
@ -1994,6 +2009,7 @@ QR =
sub: reply.sub
com: reply.com
upfile: reply.file
filetag: filetag
spoiler: reply.spoiler
textonly: textOnly
mode: 'regist'