X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=includes%2Fajax.js;h=6e94941e5c56337ce2936c6419157d973210148f;hb=51373285852bc0849f42a7610b1fac4937f699f9;hp=afc73e8dd4cb890df9d22ec3382a50978c2e467b;hpb=becd62fb957da0c16c4432c40cd818ea36e71828;p=dylansserver.git diff --git a/includes/ajax.js b/includes/ajax.js index afc73e8..6e94941 100644 --- a/includes/ajax.js +++ b/includes/ajax.js @@ -1,5 +1,10 @@ $(document).ready(function() { + $('#recaptcha_widget').show(); $('.submit').click(function() { + $('#not_human').hide(); + $('#blank_comment').hide(); + $('#comment_text').css('border', '1px solid grey') + $('#recaptcha_response_field').css('border', '1px solid grey') if ($('#comment_text').val() != '') { var challenge = Recaptcha.get_challenge(); var response = Recaptcha.get_response(); @@ -12,11 +17,10 @@ $(document).ready(function() { success: function(data) { if (data.split('\n')[0] == 'true') { var name = $("#comment_name").val(); - var email = $("#comment_email").val(); var text = $("#comment_text").val(); + if (name == '') { name = "anon" } var comment_data = { "captcha" : "passed", "name" : name, - "email" : email, "text" : text}; $.ajax({ type: "POST", @@ -25,27 +29,27 @@ $(document).ready(function() { url: "verify", data: comment_data, success: function() { - var new_post = "

" + name + "

" - + text + "

"; + var new_post = "

" + name + "

" + + text + "

"; $('#comments').prepend(new_post); $('#comment').hide(); - console.log('posted new comment'); } }); } else { - console.log('reCAPTCHA said you\'re not human.'); + $('#not_human').show(); + $('#recaptcha_response_field').css('border', '2px solid red') } }, error: function() { console.log('error'); }, complete: function() { - Recaptcha.destroy(); + Recaptcha.reload(); } }); } else { - console.log('but you didn\'t write anything!'); + $('#blank_comment').show(); + $('#comment_text').css('border', '2px solid red') } return false; });