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

raeburn lon-capa-cvs@mail.lon-capa.org
Wed, 14 Sep 2005 21:25:54 -0000


raeburn		Wed Sep 14 17:25:55 2005 EDT

  Modified files:              
    /loncom/interface	lonpopulate.pm loncommon.pm 
  Log:
  Javascript to check/uncheck a set of checkboxes is used in more than 1 place. 
  
  
Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.24 loncom/interface/lonpopulate.pm:1.25
--- loncom/interface/lonpopulate.pm:1.24	Thu Apr  7 03:34:52 2005
+++ loncom/interface/lonpopulate.pm	Wed Sep 14 17:25:52 2005
@@ -1,5 +1,5 @@
 # automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.24 2005/04/07 07:34:52 albertel Exp $
+# $Id: lonpopulate.pm,v 1.25 2005/09/14 21:25:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -151,27 +151,8 @@
 }
 |;
     if ($action eq 'viewclass') {
+        $scripttag .= &Apache::loncommon::check_uncheck_jscript();
         $scripttag .= qq|
-function checkAll(field) {
-    if (field.length > 0) {
-        for (i = 0; i < field.length; i++) {
-            field[i].checked = true ;
-        }
-    } else {
-        field.checked = true
-    }
-}
-
-function uncheckAll(field) {
-    if (field.length > 0) {
-        for (i = 0; i < field.length; i++) {
-            field[i].checked = false ;
-        }
-    } else {
-        field.checked = false ;
-    }
-}
-
 function countChecked(field) {
     var count = 0;
     if (field.length > 0) {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.272 loncom/interface/loncommon.pm:1.273
--- loncom/interface/loncommon.pm:1.272	Wed Sep 14 16:42:36 2005
+++ loncom/interface/loncommon.pm	Wed Sep 14 17:25:52 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.272 2005/09/14 20:42:36 raeburn Exp $
+# $Id: loncommon.pm,v 1.273 2005/09/14 21:25:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -419,6 +419,31 @@
         '","'.$udomele.'","'.$desc.'","'.$extra_element.'");'."'>".&mt('Select Course')."</a>";
 }
 
+sub check_uncheck_jscript {
+    my $jscript = <<"ENDSCRT";
+function checkAll(field) {
+    if (field.length > 0) {
+        for (i = 0; i < field.length; i++) {
+            field[i].checked = true ;
+        }
+    } else {
+        field.checked = true
+    }
+}
+ 
+function uncheckAll(field) {
+    if (field.length > 0) {
+        for (i = 0; i < field.length; i++) {
+            field[i].checked = false ;
+        }     } else {
+        field.checked = false ;
+    }
+}
+ENDSCRT
+    return $jscript;
+}
+
+
 =pod
 
 =item * linked_select_forms(...)