From 6d80885a5dff9f86724b792485204b587901f3f3 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 12:43:27 -0700 Subject: [PATCH] merge QR.autoPost into QR.submit --- 4chan_x.user.js | 14 +++++++------- script.coffee | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 451c587d4..b9f667587 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1291,12 +1291,6 @@ } return $.replace(oldFile, file); }, - autoPost: function() { - if (!QR.hasContent()) { - return; - } - return QR.submit(); - }, captchaNode: function(e) { var c; c = e.target.value; @@ -1359,7 +1353,7 @@ disabled: false }); if ($('#auto', QR.qr).checked) { - return QR.autoPost(); + return QR.submit(); } } }, @@ -1455,6 +1449,12 @@ }, submit: function(e) { var captcha, challenge, el, qr, response; + if (!QR.hasContent()) { + if (e) { + alert('Error: No text entered.'); + } + return; + } qr = QR.qr; $('.error', qr).textContent = ''; if ((el = $('#recaptcha_response_field', qr)).value) { diff --git a/script.coffee b/script.coffee index 14987e149..cccc4f6dd 100644 --- a/script.coffee +++ b/script.coffee @@ -1008,9 +1008,6 @@ QR = name: 'upfile' accept: QR.accept $.replace oldFile, file - autoPost: -> - return unless QR.hasContent() - QR.submit() captchaNode: (e) -> c = e.target.value $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" @@ -1056,7 +1053,7 @@ QR = $.extend b, textContent: 'Submit' disabled: false - QR.autoPost() if $('#auto', QR.qr).checked + QR.submit() if $('#auto', QR.qr).checked dialog: (text='') -> QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " X @@ -1136,7 +1133,10 @@ QR = $('textarea', QR.qr).value = '' QR.attachNext() submit: (e) -> - #XXX e is undefined if we're called from QR.autoPost + #XXX e is undefined if method is called explicitly, eg, from auto posting + unless QR.hasContent() + alert 'Error: No text entered.' if e + return {qr} = QR $('.error', qr).textContent = '' if (el = $('#recaptcha_response_field', qr)).value