### Eclipse Workspace Patch 1.0
#P drupal-cvs
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.542
diff -u -r1.542 comment.module
--- modules/comment/comment.module	14 May 2007 13:43:35 -0000	1.542
+++ modules/comment/comment.module	16 May 2007 21:07:15 -0000
@@ -1458,6 +1458,10 @@
 
   $op = isset($_POST['op']) ? $_POST['op'] : '';
 
+  if (!$user->uid && variable_get('comment_anonymous', COMMENT_ANONYMOUS_MAYNOT_CONTACT) != COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
+    drupal_add_js(drupal_get_path('module', 'comment') . '/comment.js');
+  }
+
   if ($user->uid) {
     if (!empty($edit['cid']) && user_access('administer comments')) {
       if (!empty($edit['author'])) {
@@ -1685,6 +1689,9 @@
 }
 
 function _comment_form_submit($form_values) {
+  $cookie_value = 'name=' . rawurlencode($form_values['name']) . '&homepage=' . rawurlencode($form_values['homepage']) . '&mail=' . rawurlencode($form_values['mail']);
+  //set cookie for 365 days
+  setrawcookie('comment_info', $cookie_value, time() + 31536000);
   if (!isset($form_values['date'])) {
     $form_values['date'] = 'now';
   }
Index: modules/comment/comment.js
===================================================================
RCS file: modules/comment/comment.js
diff -N modules/comment/comment.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/comment/comment.js	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,44 @@
+// $Id: $
+if (Drupal.jsEnabled) {
+  $(document).ready(function() {
+    var comment_info = Drupal.comment.getCookie('comment_info');
+    $("#comment-form input[@name=name]").val(comment_info[0]);
+    $("#comment-form input[@name=homepage]").val(comment_info[1]);
+    $("#comment-form input[@name=mail]").val(comment_info[2]);
+  });
+};
+
+Drupal.comment = {};
+
+Drupal.comment.getCookie = function(name) {
+  var search = name + '=';
+  var vals = new Array();
+  
+  if (document.cookie.length > 0) {
+    offset = document.cookie.indexOf(search);
+    if (offset != -1) {
+      offset += search.length;
+      var end = document.cookie.indexOf(';', offset);
+      if (end == -1) {
+        end = document.cookie.length;
+      }
+      commentCookie = document.cookie.substring(offset, end);
+      if (commentCookie.length > 0) {
+        var parts = new Array("name", "homepage", "mail");
+        for (i=0;i<3;i++) {
+          search = parts[i] + '=';
+          offset = commentCookie.indexOf(search);
+          if (offset != -1) {
+            offset += search.length;
+            end = commentCookie.indexOf('&', offset);
+            if (end == -1) {
+              end = commentCookie.length;
+            }
+            vals[i] = unescape(commentCookie.substring(offset, end))
+          }
+        }
+      }
+    }
+  }
+  return vals;
+}
