--- loncom/interface/lonhtmlcommon.pm 2009/12/11 17:25:01 1.254
+++ loncom/interface/lonhtmlcommon.pm 2009/12/22 06:02:44 1.256
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.254 2009/12/11 17:25:01 bisitz Exp $
+# $Id: lonhtmlcommon.pm,v 1.256 2009/12/22 06:02:44 faziophi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -383,8 +383,7 @@ dname_hour, dname_min, and dname_sec.
The current setting for this time parameter. A unix format time
(time in seconds since the beginning of Jan 1st, 1970, GMT.
-An undefined value is taken to indicate the value is the current time
-unless it is requested to leave it empty. See $includeempty.
+An undefined value is taken to indicate the value is the current time.
Also, to be explicit, a value of 'now' also indicates the current time.
=item $special
@@ -394,9 +393,6 @@ the date_setter. See lonparmset for exa
=item $includeempty
-If it is set (true) and no date/time value is provided,
-the date/time fields are left empty.
-
=item $state
Specifies the initial state of the form elements. Either 'disabled' or empty.
@@ -416,40 +412,42 @@ sub date_setter {
my ($formname,$dname,$currentvalue,$special,$includeempty,$state,
$no_hh_mm_ss,$defhour,$defmin,$defsec,$nolink) = @_;
my $now = time;
-
- my $tzname;
- my ($sec,$min,$hour,$mday,$month,$year) = ('','',undef,'','','');
- # other potentially useful values: wkday,yrday,is_daylight_savings
-
+ my $wasdefined=1;
if (! defined($state) || $state ne 'disabled') {
$state = '';
}
if (! defined($no_hh_mm_ss)) {
$no_hh_mm_ss = 0;
}
-
if ($currentvalue eq 'now') {
- $currentvalue = $now;
+ $currentvalue = $now;
}
-
- # Default value: Set empty date field to current time
- # unless empty inclusion is requested
- if ((!$includeempty) && (!$currentvalue)) {
- $currentvalue = $now;
+ if ((!defined($currentvalue)) || ($currentvalue eq '')) {
+ $wasdefined=0;
+ if ($includeempty) {
+ $currentvalue = 0;
+ } else {
+ $currentvalue = $now;
+ }
}
- # Do we have a date? Split it!
+ # other potentially useful values: wkday,yrday,is_daylight_savings
+ my $tzname;
+ my ($sec,$min,$hour,$mday,$month,$year)=('','',undef,'','','');
if ($currentvalue) {
- ($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($currentvalue);
-
- # No values provided for hour, min, sec? Use default 0
- if (($defhour) || ($defmin) || ($defsec)) {
- $sec = ($defsec ? $defsec : 0);
- $min = ($defmin ? $defmin : 0);
- $hour = ($defhour ? $defhour : 0);
- }
+ ($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($currentvalue);
+ }
+ unless ($wasdefined) {
+ ($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($now);
+ if (($defhour) || ($defmin) || ($defsec)) {
+ $sec=($defsec?$defsec:0);
+ $min=($defmin?$defmin:0);
+ $hour=($defhour?$defhour:0);
+ } elsif (!$includeempty) {
+ $sec=0;
+ $min=0;
+ $hour=0;
+ }
}
-
- # Create Output
my $result = "\n\n";
$result .= <
@@ -1243,11 +1241,18 @@ ENDLINK
}
sub htmlareaheaders {
- return if (&htmlareablocked());
- return if (!&htmlareabrowser());
- return (<
-ENDHEADERS
+
+ENDEDITOR
+ }
+ $s.=(<
+
+ENDJQUERY
+ return $s;
}
# ----------------------------------------------------------------- Preferences
@@ -1286,16 +1291,98 @@ sub htmlareaselectactive {
my $output='