From 3a331f154756b6b07c3a45eac2d5ec4f0208ee21 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 25 Aug 2010 10:31:24 -0700 Subject: [PATCH] captcha reminder --- 4chan_x.coffee | 17 ++++++++++++++--- 4chan_x.js | 22 ++++++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/4chan_x.coffee b/4chan_x.coffee index b5c965926..2ce3066a4 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -425,10 +425,21 @@ iframeLoad = -> remove(qr) -submit = -> - this.style.visibility = 'collapse' - if span = this.nextSibling +submit = (e) -> + if span = @nextSibling remove(span) + recaptcha = $('#recaptcha_response_field', this) + if not recaptcha.value + e.preventDefault() + span = make 'span', { + className: 'error' + textContent: 'You forgot to type in the verification.' + } + @parentNode.appendChild span + alert 'You forgot to type in the verification.' + recaptcha.focus() + else + @style.visibility = 'collapse' minimize = -> diff --git a/4chan_x.js b/4chan_x.js index ab7050c31..de6c8eacb 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -462,10 +462,24 @@ return remove(qr); } }; - submit = function() { - var span; - this.style.visibility = 'collapse'; - return (span = this.nextSibling) ? remove(span) : null; + submit = function(e) { + var recaptcha, span; + if (span = this.nextSibling) { + remove(span); + } + recaptcha = $('#recaptcha_response_field', this); + if (!recaptcha.value) { + e.preventDefault(); + span = make('span', { + className: 'error', + textContent: 'You forgot to type in the verification.' + }); + this.parentNode.appendChild(span); + alert('You forgot to type in the verification.'); + return recaptcha.focus(); + } else { + return (this.style.visibility = 'collapse'); + } }; minimize = function() { var form;