X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=includes%2Fajax.js;h=014e1f594013cf39d0c8018697449fb1744eaa3b;hb=e140ee0a41979644a6db6c3ba444d76afc2a4125;hp=afc73e8dd4cb890df9d22ec3382a50978c2e467b;hpb=becd62fb957da0c16c4432c40cd818ea36e71828;p=dylansserver.git diff --git a/includes/ajax.js b/includes/ajax.js index afc73e8..014e1f5 100644 --- a/includes/ajax.js +++ b/includes/ajax.js @@ -1,4 +1,5 @@ $(document).ready(function() { + $('#recaptcha_widget').show(); $('.submit').click(function() { if ($('#comment_text').val() != '') { var challenge = Recaptcha.get_challenge(); @@ -14,6 +15,7 @@ $(document).ready(function() { 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, @@ -25,27 +27,34 @@ $(document).ready(function() { url: "verify", data: comment_data, success: function() { - var new_post = "

" + name + "

" - + text + "

"; + if (email != '') { + var new_post = "

" + name + "

" + + text + "

"; + } else { + 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.'); + var error = "reCAPTCHA said you're not human"; + $('#comment').append(error); } }, error: function() { console.log('error'); }, complete: function() { - Recaptcha.destroy(); + Recaptcha.reload(); } }); } else { - console.log('but you didn\'t write anything!'); + var error = "but you didn't write anything!
"; + $('#submit').before(error); } return false; });