Concatenated comment js files
authorDylan Lloyd <dylan@psu.edu>
Sat, 26 Mar 2011 19:49:03 +0000 (15:49 -0400)
committerDylan Lloyd <dylan@psu.edu>
Sat, 26 Mar 2011 19:49:03 +0000 (15:49 -0400)
includes/ajax.js [deleted file]
includes/comment_validation.js [new file with mode: 0644]
index.php

diff --git a/includes/ajax.js b/includes/ajax.js
deleted file mode 100644 (file)
index 6e94941..0000000
+++ /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 = "<h3>" + name + "</h3>"
-                                                            + text + "<br><br>";
-                          $('#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 (file)
index 0000000..6e94941
--- /dev/null
@@ -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 = "<h3>" + name + "</h3>"
+                                                            + text + "<br><br>";
+                          $('#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;
+  });
+});
index a2c85ea..54b5bf2 100644 (file)
--- a/index.php
+++ b/index.php
@@ -76,11 +76,10 @@ abstract class cms {
     if (cms::determine_type() == "index") {
       $scripts = "<script type='text/javascript' src='/includes/all.js'></script>"; 
       $home_link = "http://validator.w3.org/unicorn/check?ucn_uri=dylansserver.com&amp;ucn_task=conformance#";
-    } else if ($this->determine_type() == 'note') {
+    } else if ($this->determine_type() == 'note'
+                 && isset($_GET['comments'])) {
       $scripts = "<script type='text/javascript' src='http://www.google.com/recaptcha/api/js/recaptcha_ajax.js'></script>";
-      $scripts .= "<script type='text/javascript' src='/includes/jquery-core.js'></script>";
-      $scripts .= "<script type='text/javascript' src='/includes/jquery-all-components.js'></script>";
-      $scripts .= "<script type='text/javascript' src='/includes/ajax.js'></script>";
+      $scripts .= "<script type='text/javascript' src='/includes/comment.js'></script>";
     }
     echo <<<END_OF_HEAD
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"