X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=includes%2Fajax.js;h=6e94941e5c56337ce2936c6419157d973210148f;hb=8531410ff5fb89df84d28fb097c236e6c5cb894c;hp=014e1f594013cf39d0c8018697449fb1744eaa3b;hpb=e140ee0a41979644a6db6c3ba444d76afc2a4125;p=dylansserver.git diff --git a/includes/ajax.js b/includes/ajax.js index 014e1f5..6e94941 100644 --- a/includes/ajax.js +++ b/includes/ajax.js @@ -1,6 +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(); @@ -13,12 +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", @@ -27,22 +29,15 @@ $(document).ready(function() { url: "verify", data: comment_data, success: function() { - if (email != '') { - var new_post = "

" + name + "

" + var new_post = "

" + name + "

" + text + "

"; - } else { - var new_post = "

" + name + "

" - + text + "

"; - } $('#comments').prepend(new_post); $('#comment').hide(); - console.log('posted new comment'); } }); } else { - var error = "reCAPTCHA said you're not human"; - $('#comment').append(error); + $('#not_human').show(); + $('#recaptcha_response_field').css('border', '2px solid red') } }, error: function() { @@ -53,8 +48,8 @@ $(document).ready(function() { } }); } else { - var error = "but you didn't write anything!
"; - $('#submit').before(error); + $('#blank_comment').show(); + $('#comment_text').css('border', '2px solid red') } return false; });