Index: misc/checkbox.js
===================================================================
RCS file: misc/checkbox.js
diff -N misc/checkbox.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ misc/checkbox.js	17 Nov 2006 06:59:50 -0000
@@ -0,0 +1,76 @@
+// $Id: $
+
+// Global Killswitch
+if (Drupal.jsEnabled) {
+  $(document).ready(function() {
+    // Keep track of which checkbox is checked for selecting ranges.
+    var checked;
+    var selectAll = Drupal.settings.selectAll;
+    var selectNone = Drupal.settings.selectNone;
+
+    // Find all <a> with class check-all, and attach a toggle event to them
+    // so that when the link is clicked, checkboxes within the form are checked
+    // and when the link is clicked again, checkboxes are unchecked.
+    // Also highlight and unhighlight each row the checkbox lives in.
+    $('a.select-all').toggle(function() {
+      $('input:checkbox', this.form).each(function() {
+        this.checked = true;
+        $(this).parents('tr').addClass('selected');
+      });
+      $(this).html(selectNone);
+      return false;
+    }, function() {
+      $('input:checkbox', this.form).each(function() {
+        this.checked = false;
+        $(this).parents('tr').removeClass('selected');
+      });
+      $(this).html(selectAll);
+      return false;
+    });
+
+    // For each of the checkboxes within the form that this <a> exists.
+    $('form[a.select-all] input:checkbox').click(function(e) {
+      // Toggle between highlighting and unhighlighting this row.
+      $(this).parents('tr').toggleClass('selected');
+
+      // If this is a shift click, we need to highlight everything in the range.
+      if (e.shiftKey) {
+        // We use the checkbox's parent TR to do our range searching.
+        var from = $(checked).parents('tr')[0];
+        var to = $(e.target).parents('tr')[0];
+      
+        // We swap from and to around to support forward and reverse clicking.
+        if (from.rowIndex > to.rowIndex) {
+          selectRange(to, from);
+        }
+        else {
+          selectRange(from, to);
+        }
+      }
+    
+      // Keep track of the last checked checkbox.
+      checked = e.target;
+    });
+  
+    // Select all checkboxes within a range.
+    function selectRange(from, to) {
+      // Traverse through the sibling nodes.
+      for (var i = from.nextSibling; i; i = i.nextSibling) {
+        // Make sure that we're only dealing with elements.
+        if (i.nodeType != 1) continue;
+
+        if (to.nodeType) {
+        // If we are at the end of the range, stop.
+          if (i == to) break;
+        } 
+        // A faster alternative to doing $(i).filter(to).length
+        else if (jQuery.filter(to, [i]).r.length) break;
+      
+        $(i).toggleClass('selected');
+        $('input:checkbox', i).each(function() {
+          this.checked = !this.checked;
+        });
+      }
+    }
+  });
+}
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.496
diff -u -F^f -r1.496 comment.module
--- modules/comment/comment.module	12 Nov 2006 00:11:15 -0000	1.496
+++ modules/comment/comment.module	17 Nov 2006 06:59:52 -0000
@@ -1029,6 +1029,9 @@ function comment_admin($type = 'new') {
 }
 
 function comment_admin_overview($type = 'new', $arg) {
+  drupal_add_js(array('selectAll' => t('Select all'), 'selectNone' => t('Select none')), 'setting');
+  drupal_add_js('misc/checkbox.js');
+
   // build an 'Update options' form
   $form['options'] = array(
     '#type' => 'fieldset', '#title' => t('Update options'),
@@ -1044,7 +1047,7 @@ function comment_admin_overview($type = 
   // load the comments that we want to display
   $status = ($type == 'approval') ? COMMENT_NOT_PUBLISHED : COMMENT_PUBLISHED;
   $form['header'] = array('#type' => 'value', '#value' => array(
-    NULL,
+    array('data' => l(t('Select all'), NULL, array('class' => 'select-all'))),
     array('data' => t('Subject'), 'field' => 'subject'),
     array('data' => t('Author'), 'field' => 'name'),
     array('data' => t('Time'), 'field' => 'timestamp', 'sort' => 'desc'),
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.729
diff -u -F^f -r1.729 node.module
--- modules/node/node.module	16 Nov 2006 21:14:44 -0000	1.729
+++ modules/node/node.module	17 Nov 2006 06:59:54 -0000
@@ -1497,6 +1497,9 @@ function node_admin_content() {
 }
 
 function node_admin_nodes() {
+  drupal_add_js(array('selectAll' => t('Select all'), 'selectNone' => t('Select none')), 'setting');
+  drupal_add_js('misc/checkbox.js');
+
   global $form_values;
   $filter = node_build_filter_query();
 
@@ -1533,7 +1536,7 @@ function node_admin_nodes() {
  */
 function theme_node_admin_nodes($form) {
   // Overview table:
-  $header = array(NULL, t('Title'), t('Type'), t('Author'), t('Status'), t('Operations'));
+  $header = array(l(t('Select all'), NULL, array('class' => 'select-all')), t('Title'), t('Type'), t('Author'), t('Status'), t('Operations'));
 
   $output .= drupal_render($form['options']);
   if (isset($form['title']) && is_array($form['title'])) {
Index: modules/system/system.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.css,v
retrieving revision 1.14
diff -u -F^f -r1.14 system.css
--- modules/system/system.css	24 Oct 2006 19:36:52 -0000	1.14
+++ modules/system/system.css	17 Nov 2006 06:59:54 -0000
@@ -325,3 +325,19 @@
   display: block;
   padding: 1.5em 0 .5em;
 }
+
+/*
+** To be used with checkbox.js
+*/
+html.js a.select-all {
+  display: block;
+}
+
+a.select-all {
+  display: none;
+  width: 6em;
+  white-space: nowrap;
+}
+tr.selected td {
+  background: #ffc;
+}
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.711
diff -u -F^f -r1.711 user.module
--- modules/user/user.module	16 Nov 2006 09:01:55 -0000	1.711
+++ modules/user/user.module	17 Nov 2006 06:59:57 -0000
@@ -1958,6 +1958,9 @@ function theme_user_admin_new_role($form
 }
 
 function user_admin_account() {
+  drupal_add_js(array('selectAll' => t('Select all'), 'selectNone' => t('Select none')), 'setting');
+  drupal_add_js('misc/checkbox.js');
+
   $filter = user_build_filter_query();
 
   $header = array(
@@ -2029,7 +2032,7 @@ function user_admin_account() {
 function theme_user_admin_account($form) {
   // Overview table:
   $header = array(
-    array(),
+    array('data' => l(t('Select all'), NULL, array('class' => 'select-all'))),
     array('data' => t('Username'), 'field' => 'u.name'),
     array('data' => t('Status'), 'field' => 'u.status'),
     t('Roles'),
