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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 11 Oct 2005 21:16:37 -0000


albertel		Tue Oct 11 17:16:37 2005 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm 
  Log:
  - anytime deslects if they interact with the time elements
  
  
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.118 loncom/interface/lonhelper.pm:1.119
--- loncom/interface/lonhelper.pm:1.118	Tue Oct 11 16:57:54 2005
+++ loncom/interface/lonhelper.pm	Tue Oct 11 17:16:37 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.118 2005/10/11 20:57:54 albertel Exp $
+# $Id: lonhelper.pm,v 1.119 2005/10/11 21:16:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1557,7 +1557,7 @@
     my $date;
 
     my $time=time;
-    my $anytime;
+    my ($anytime,$onclick);
 
     if (defined($self->{DEFAULT_VALUE})) {
         my $valueFunc = eval($self->{DEFAULT_VALUE});
@@ -1566,6 +1566,9 @@
         $time = &$valueFunc($helper, $self);
 	if (lc($time) eq 'anytime') { $time=time; $anytime=1; }
     }
+    if ($anytime) {
+	$onclick = "onclick=\"javascript:updateCheck(this.form,'${var}anytime',false)\"";
+    }
     # Default date: The current hour.
     $date = localtime($time);
     $date->min(0);
@@ -1576,7 +1579,7 @@
 
     # Month
     my $i;
-    $result .= "<select name='${var}month'>\n";
+    $result .= "<select $onclick name='${var}month'>\n";
     for ($i = 0; $i < 12; $i++) {
         if ($i == $date->mon) {
             $result .= "<option value='$i' selected='selected'>";
@@ -1588,7 +1591,7 @@
     $result .= "</select>\n";
 
     # Day
-    $result .= "<select name='${var}day'>\n";
+    $result .= "<select $onclick name='${var}day'>\n";
     for ($i = 1; $i < 32; $i++) {
         if ($i == $date->mday) {
             $result .= '<option selected="selected">';
@@ -1600,7 +1603,7 @@
     $result .= "</select>,\n";
 
     # Year
-    $result .= "<select name='${var}year'>\n";
+    $result .= "<select $onclick name='${var}year'>\n";
     for ($i = 2000; $i < 2030; $i++) { # update this after 64-bit dates
         if ($date->year + 1900 == $i) {
             $result .= "<option selected='selected'>";
@@ -1617,7 +1620,7 @@
 	my $am = &mt('a.m.');
 	my $pm = &mt('p.m.');
         # Build hour
-        $result .= "<select name='${var}hour'>\n";
+        $result .= "<select $onclick name='${var}hour'>\n";
         $result .= "<option " . ($date->hour == 0 ? 'selected="selected" ':'') .
             " value='0'>" . &mt('midnight') . "</option>\n";
         for ($i = 1; $i < 12; $i++) {
@@ -1640,7 +1643,7 @@
 
         $result .= "</select> :\n";
 
-        $result .= "<select name='${var}minute'>\n";
+        $result .= "<select $onclick name='${var}minute'>\n";
         for my $i ((0,15,30,45,59,undef,1..59)) {
             my $printedMinute = $i;
             if (defined($i) && $i < 10) {
@@ -1656,6 +1659,17 @@
         $result .= "</select>\n";
     }
     if ($self->{'anytime'}) {
+	    $result.=(<<CHECK);
+<script type="text/javascript">
+// <!--
+    function updateCheck(form,name,value) {
+	var checkbox=form[name];
+	checkbox.checked = value;
+    }
+// -->
+</script>
+CHECK
+
 	$result.="&nbsp;or&nbsp;<label><input type='checkbox' ";
 	if ($anytime) {
 	    $result.=' checked="checked" '