[LON-CAPA-cvs] cvs: loncom /interface lonindexer.pm

banghart lon-capa-cvs-allow@mail.lon-capa.org
Wed, 27 Jun 2007 23:27:25 -0000


banghart		Wed Jun 27 19:27:25 2007 EDT

  Modified files:              
    /loncom/interface	lonindexer.pm 
  Log:
  	Bug 4773. Add 'Check All' and 'Uncheck All' buttons.
  
  
Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.162 loncom/interface/lonindexer.pm:1.163
--- loncom/interface/lonindexer.pm:1.162	Wed Jun 27 18:39:48 2007
+++ loncom/interface/lonindexer.pm	Wed Jun 27 19:27:23 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Directory Indexer
 #
-# $Id: lonindexer.pm,v 1.162 2007/06/27 22:39:48 albertel Exp $
+# $Id: lonindexer.pm,v 1.163 2007/06/27 23:27:23 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -350,21 +350,26 @@
 	my $js = <<"ENDHEADER";
 <script type="text/javascript">
 $catalogmodefunctions
-function checkAll(dir) {
+function checkAll() {
     var numForms = document.forms.length;
-    var dirLength = dir.length;
-    var dirCheckbox = document.getElementById(dir);
     for (i=0;i<numForms;i++) {
         var numElements = document.forms[i].elements.length;
         for (j=0;j<numElements;j++){
-            var fieldVal = document.forms[i].elements[j].value;
-            var comp = fieldVal.substr(0,dirLength);
-            if ((comp == dir) && (dirLength < fieldVal.length)) {
-                if (dirCheckbox.checked == true) {
-                    document.forms[i].elements[j].checked = true;
-                } else {
-                    document.forms[i].elements[j].checked = false;
-                }
+            var fieldName = document.forms[i].elements[j].name;
+            if (fieldName == 'filelink') {
+                document.forms[i].elements[j].checked = true;
+            }
+        }
+    }
+}
+function uncheckAll() {
+    var numForms = document.forms.length;
+    for (i=0;i<numForms;i++) {
+        var numElements = document.forms[i].elements.length;
+        for (j=0;j<numElements;j++){
+            var fieldName = document.forms[i].elements[j].name;
+            if (fieldName == 'filelink') {
+                document.forms[i].elements[j].checked = false;
             }
         }
     }
@@ -518,6 +523,9 @@
 # ------------------------------------------------------ Remember where we were
 	&Apache::loncommon::storeresurl($storeuri);
 	&Apache::lonhtmlcommon::store_recent('residx',$storeuri,$storeuri);
+# -------------------------------------------------- Check All and Uncheck all
+	$r->print('<br /><input type="button" value="'.&mt("Check All").'" id="checkallbutton" onClick="javascript:checkAll()" />');
+	$r->print('<input type="button" value="'.&mt("Uncheck All").'" id="uncheckallbutton" onClick="javascript:uncheckAll()" />');
 # ----------------- output starting row to the indexed file/directory hierarchy
         my $titleclr="#ddffff";
         #$r->print(&initdebug());
@@ -889,10 +897,7 @@
 	my $curdir = $startdir.$filecom[0].'/';
 	my $anchor = $curdir;
 	$anchor =~ s/\W//g;
-	$r->print("<tr valign=$valign bgcolor=\"$fileclr\">");
-	$r->print("<td>\n");
-	$r->print("<input type=\"checkbox\" name=\"$curdir\" id=\"$curdir\" value=\"$curdir\" onClick=\"javascript:checkAll('$curdir')\" /></td>\n");
-	$r->print("<td nowrap>\n");
+	$r->print("<tr bgcolor=\"$fileclr\">$extrafield<td valign=$valign>");
 	&begin_form ($r,$curdir);
 	$r->print ('<a name="'.$anchor.'"></a><img alt="" src="'.$iconpath.
 		   'whitespace1.gif" class="LC_icon" />'."\n");