From 9adfa5f866e87c589225b3515d92d745bea46acb Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 6 Aug 2011 10:07:17 -0700 Subject: [PATCH] move auto auto post into qr --- 4chan_x.user.js | 19 +++++++++++-------- script.coffee | 11 +++++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ad0b64992..e059fec5d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1280,6 +1280,15 @@ $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value; return $('#recaptcha_challenge_field', qr.el).value = target.value; }, + captchaKeydown: function(e) { + if (e.keyCode === 13 && cooldown.duration) { + $('#auto', qr.el).checked = true; + if (conf['Auto Hide QR']) { + qr.autohide.set(); + } + return qr.push.call(this); + } + }, cb: { autohide: function(e) { if (this.checked) { @@ -1320,6 +1329,7 @@ $.bind($('a[name=attach]', qr.el), 'click', qr.attach); $.bind($('img', qr.el), 'click', Recaptcha.reload); $.bind($('#recaptcha_response_field', qr.el), 'keydown', Recaptcha.listener); + $.bind($('#recaptcha_response_field', qr.el), 'keydown', qr.captchaKeydown); return $.append(d.body, qr.el); }, message: function(e) { @@ -2485,14 +2495,7 @@ }, listener: function(e) { if (e.keyCode === 8 && this.value === '') { - Recaptcha.reload(); - } - if (e.keyCode === 13 && cooldown.duration) { - $('#auto', qr.el).checked = true; - if (conf['Auto Hide QR']) { - qr.autohide.set(); - } - return qr.push.call(this); + return Recaptcha.reload(); } }, reload: function() { diff --git a/script.coffee b/script.coffee index d87a49509..97198d0eb 100644 --- a/script.coffee +++ b/script.coffee @@ -1009,6 +1009,12 @@ qr = $('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value $('#recaptcha_challenge_field', qr.el).value = target.value + captchaKeydown: (e) -> + if e.keyCode is 13 and cooldown.duration # press enter to enable auto-post if cooldown is still running + $('#auto', qr.el).checked = true + qr.autohide.set() if conf['Auto Hide QR'] + qr.push.call this + cb: autohide: (e) -> if @checked @@ -1064,6 +1070,7 @@ qr = $.bind $('a[name=attach]', qr.el), 'click', qr.attach $.bind $('img', qr.el), 'click', Recaptcha.reload $.bind $('#recaptcha_response_field', qr.el), 'keydown', Recaptcha.listener + $.bind $('#recaptcha_response_field', qr.el), 'keydown', qr.captchaKeydown $.append d.body, qr.el @@ -1894,10 +1901,6 @@ Recaptcha = listener: (e) -> if e.keyCode is 8 and @value is '' # backspace to reload Recaptcha.reload() - if e.keyCode is 13 and cooldown.duration # press enter to enable auto-post if cooldown is still running - $('#auto', qr.el).checked = true - qr.autohide.set() if conf['Auto Hide QR'] - qr.push.call this reload: -> window.location = 'javascript:Recaptcha.reload()'