X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=includes%2Fajax.js;h=6946a073afc2bf910839740f6fc3c491d11394a3;hb=63c697020762553a9b124a1a22478d31089f84b7;hp=2bc9ccef6f116653aa8093672e6a9353f61d4574;hpb=6800ac4d1b7c2090630a149d1b9789679d338911;p=dylansserver.git diff --git a/includes/ajax.js b/includes/ajax.js index 2bc9cce..6946a07 100644 --- a/includes/ajax.js +++ b/includes/ajax.js @@ -15,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, @@ -26,16 +27,22 @@ $(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() { @@ -46,7 +53,8 @@ $(document).ready(function() { } }); } else { - console.log('but you didn\'t write anything!'); + var error = "but you didn't write anything!
"; + $('#submit').before(error); } return false; });