From 574b2fe2fb93f2c521e11d188c4405ed5cc9d5c6 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 20:01:19 -0700 Subject: [PATCH] auto hide, persist --- 4chan_x.user.js | 23 ++++++++++++++--------- script.coffee | 12 ++++++------ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d4a25773d..8d1d4bdd4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1239,9 +1239,15 @@ $('#recaptcha_response_field').id = ''; holder = $('#recaptcha_challenge_field_holder'); $.bind(holder, 'DOMNodeInserted', QR.captchaNode); - return QR.captchaNode({ + QR.captchaNode({ target: holder.firstChild }); + if (conf['Persistent QR']) { + qr.dialog(); + if (conf['Auto Hide QR']) { + return $('#autohide', QR.el).checked = true; + } + } }, captchaNode: function(e) { var c; @@ -1354,7 +1360,9 @@ if (data) { return $.extend($('a.error', QR.el), JSON.parse(data)); } else { - QR.close(); + if (!conf['Persistent QR']) { + QR.close(); + } if (conf['Cooldown']) { cooldown = Date.now() + 30 * SECOND; $.set("cooldown/" + g.BOARD, cooldown); @@ -1375,7 +1383,10 @@ } challenge = captcha.challenge, response = captcha.response; $('#challenge', QR.el).value = challenge; - return $('#response', QR.el).value = response; + $('#response', QR.el).value = response; + if (conf['Auto Hide QR']) { + return $('#autohide', QR.el).checked = true; + } }, sys: function() { return $.globalEval(function() { @@ -3065,12 +3076,6 @@ if (conf['Image Preloading']) { imgPreloading.init(); } - if (conf['Quick Reply'] && conf['Persistent QR'] && canPost) { - qr.dialog(); - if (conf['Auto Hide QR']) { - $('#autohide', qr.el).checked = true; - } - } if (conf['Post in Title']) { titlePost.init(); } diff --git a/script.coffee b/script.coffee index eec34ceb5..6cf1d2cd8 100644 --- a/script.coffee +++ b/script.coffee @@ -974,6 +974,10 @@ QR = holder = $ '#recaptcha_challenge_field_holder' $.bind holder, 'DOMNodeInserted', QR.captchaNode QR.captchaNode target: holder.firstChild + if conf['Persistent QR'] + qr.dialog() + if conf['Auto Hide QR'] + $('#autohide', QR.el).checked = true captchaNode: (e) -> c = e.target.value $('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}" @@ -1066,7 +1070,7 @@ QR = if data $.extend $('a.error', QR.el), JSON.parse data else - QR.close() + QR.close() unless conf['Persistent QR'] if conf['Cooldown'] cooldown = Date.now() + 30*SECOND $.set "cooldown/#{g.BOARD}", cooldown @@ -1082,6 +1086,7 @@ QR = {challenge, response} = captcha $('#challenge', QR.el).value = challenge $('#response', QR.el).value = response + $('#autohide', QR.el).checked = true if conf['Auto Hide QR'] sys: -> $.globalEval -> if node = document.querySelector('table font b')?.firstChild @@ -2420,11 +2425,6 @@ main = if conf['Image Preloading'] imgPreloading.init() - if conf['Quick Reply'] and conf['Persistent QR'] and canPost - qr.dialog() - if conf['Auto Hide QR'] - $('#autohide', qr.el).checked = true - if conf['Post in Title'] titlePost.init()