From: Dylan Lloyd Date: Sat, 26 Mar 2011 19:49:03 +0000 (-0400) Subject: Concatenated comment js files X-Git-Url: https://disinclined.org/git/?a=commitdiff_plain;h=69fc1a7b8b5406160484cb657881ab9623ec0630;p=dylansserver.git Concatenated comment js files --- diff --git a/includes/ajax.js b/includes/ajax.js deleted file mode 100644 index 6e94941..0000000 --- a/includes/ajax.js +++ /dev/null @@ -1,56 +0,0 @@ -$(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(); - var captcha_data = { "challenge" : challenge, - "response" : response}; - $.ajax({ - type: "GET", - url: "/captcha", - data: captcha_data, - success: function(data) { - if (data.split('\n')[0] == 'true') { - var name = $("#comment_name").val(); - var text = $("#comment_text").val(); - if (name == '') { name = "anon" } - var comment_data = { "captcha" : "passed", - "name" : name, - "text" : text}; - $.ajax({ - type: "POST", - // the url may need to be adjusted for - // trailing slashes - url: "verify", - data: comment_data, - success: function() { - var new_post = "

" + name + "

" - + text + "

"; - $('#comments').prepend(new_post); - $('#comment').hide(); - } - }); - } else { - $('#not_human').show(); - $('#recaptcha_response_field').css('border', '2px solid red') - } - }, - error: function() { - console.log('error'); - }, - complete: function() { - Recaptcha.reload(); - } - }); - } else { - $('#blank_comment').show(); - $('#comment_text').css('border', '2px solid red') - } - return false; - }); -}); diff --git a/includes/comment_validation.js b/includes/comment_validation.js new file mode 100644 index 0000000..6e94941 --- /dev/null +++ b/includes/comment_validation.js @@ -0,0 +1,56 @@ +$(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(); + var captcha_data = { "challenge" : challenge, + "response" : response}; + $.ajax({ + type: "GET", + url: "/captcha", + data: captcha_data, + success: function(data) { + if (data.split('\n')[0] == 'true') { + var name = $("#comment_name").val(); + var text = $("#comment_text").val(); + if (name == '') { name = "anon" } + var comment_data = { "captcha" : "passed", + "name" : name, + "text" : text}; + $.ajax({ + type: "POST", + // the url may need to be adjusted for + // trailing slashes + url: "verify", + data: comment_data, + success: function() { + var new_post = "

" + name + "

" + + text + "

"; + $('#comments').prepend(new_post); + $('#comment').hide(); + } + }); + } else { + $('#not_human').show(); + $('#recaptcha_response_field').css('border', '2px solid red') + } + }, + error: function() { + console.log('error'); + }, + complete: function() { + Recaptcha.reload(); + } + }); + } else { + $('#blank_comment').show(); + $('#comment_text').css('border', '2px solid red') + } + return false; + }); +}); diff --git a/index.php b/index.php index a2c85ea..54b5bf2 100644 --- a/index.php +++ b/index.php @@ -76,11 +76,10 @@ abstract class cms { if (cms::determine_type() == "index") { $scripts = ""; $home_link = "http://validator.w3.org/unicorn/check?ucn_uri=dylansserver.com&ucn_task=conformance#"; - } else if ($this->determine_type() == 'note') { + } else if ($this->determine_type() == 'note' + && isset($_GET['comments'])) { $scripts = ""; - $scripts .= ""; - $scripts .= ""; - $scripts .= ""; + $scripts .= ""; } echo <<