--- loncom/interface/lonhtmlcommon.pm 2004/02/16 22:32:19 1.50
+++ loncom/interface/lonhtmlcommon.pm 2004/11/11 18:19:41 1.95
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.50 2004/02/16 22:32:19 albertel Exp $
+# $Id: lonhtmlcommon.pm,v 1.95 2004/11/11 18:19:41 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,7 +60,6 @@ use Time::HiRes;
use Apache::lonlocal;
use strict;
-
##############################################
##############################################
@@ -118,6 +117,12 @@ sub store_recent {
time.'&'.&Apache::lonnet::escape($value) });
}
+sub remove_recent {
+ my ($area,$names)=@_;
+ my $file=&recent_filename($area);
+ return &Apache::lonnet::del($file,$names);
+}
+
sub select_recent {
my ($area,$fieldname,$event)=@_;
my %recent=&Apache::lonnet::dump(&recent_filename($area));
@@ -126,7 +131,8 @@ sub select_recent {
">\n";
foreach (sort keys %recent) {
unless ($_=~/^error\:/) {
- $return.="\n';
}
@@ -164,9 +170,15 @@ sub textbox {
##############################################
##############################################
sub checkbox {
- my ($name,$value) = @_;
- my $Str = '';
+ my ($name,$checked,$value) = @_;
+ my $Str = '
ENDJS
- $result .= " \n";
+ my $minuteselector = qq{};
+ my $secondselector= qq{};
+ my $cal_link = qq{};
+ #
+ if ($no_hh_mm_ss) {
+ $result .= &mt('[_1] [_2] [_3] [_4]Select Date[_5]',
+ $monthselector,$dayselector,$yearselector,
+ $cal_link,'');
+ } else {
+ $result .= &mt('[_1] [_2] [_3] [_4] [_5]m [_6]s [_7]Select Date[_8]',
+ $monthselector,$dayselector,$yearselector,
+ $hourselector,$minuteselector,$secondselector,
+ $cal_link,'');
+ }
+ $result .= "\n\n";
return $result;
}
@@ -360,18 +416,26 @@ sub get_date_from_form {
if (($tmpsec =~ /^\d+$/) && ($tmpsec >= 0) && ($tmpsec < 60)) {
$sec = $tmpsec;
}
+ if (!defined($tmpsec) || $tmpsec eq '') { $sec = 0; }
+ } else {
+ $sec = 0;
}
if (defined($ENV{'form.'.$dname.'_minute'})) {
my $tmpmin = $ENV{'form.'.$dname.'_minute'};
if (($tmpmin =~ /^\d+$/) && ($tmpmin >= 0) && ($tmpmin < 60)) {
$min = $tmpmin;
}
+ if (!defined($tmpmin) || $tmpmin eq '') { $min = 0; }
+ } else {
+ $min = 0;
}
if (defined($ENV{'form.'.$dname.'_hour'})) {
my $tmphour = $ENV{'form.'.$dname.'_hour'};
if (($tmphour =~ /^\d+$/) && ($tmphour >= 0) && ($tmphour < 24)) {
$hour = $tmphour;
}
+ } else {
+ $hour = 0;
}
if (defined($ENV{'form.'.$dname.'_day'})) {
my $tmpday = $ENV{'form.'.$dname.'_day'};
@@ -460,6 +524,27 @@ sub javascript_nothing {
return $nothing;
}
+##############################################
+##############################################
+sub javascript_docopen {
+ # safari does not understand document.open() and loads "text/html"
+ my $nothing = "''";
+ my $user_browser;
+ my $user_os;
+ $user_browser = $ENV{'browser.type'} if (exists($ENV{'browser.type'}));
+ $user_os = $ENV{'browser.os'} if (exists($ENV{'browser.os'}));
+ if (! defined($user_browser) || ! defined($user_os)) {
+ (undef,$user_browser,undef,undef,undef,$user_os) =
+ &Apache::loncommon::decode_user_agent();
+ }
+ if ($user_browser eq 'safari' && $user_os =~ 'mac') {
+ $nothing = "document.clear()";
+ } else {
+ $nothing = "document.open('text/html','replace')";
+ }
+ return $nothing;
+}
+
##############################################
##############################################
@@ -560,6 +645,8 @@ Inputs
=item $type Either 'popup' or 'inline' (popup is assumed if nothing is
specified)
+=item $width Specify the width in charaters of the input field.
+
=item $formname Only useful in the inline case, if a form already exists, this needs to be used and specfiy the name of the form, otherwise the Progress line will be created in a new form of it's own
=item $inputname Only useful in the inline case, if a form and an input of type text exists, use this to specify the name of the input field
@@ -632,10 +719,18 @@ Returns: none
########################################################
########################################################
+my $uniq=0;
+sub get_uniq_name {
+ $uniq++;
+ return 'uniquename'.$uniq;
+}
+
# Create progress
sub Create_PrgWin {
- my ($r, $title, $heading, $number_to_do,$type,$formname,$inputname)=@_;
+ my ($r, $title, $heading, $number_to_do,$type,$width,$formname,
+ $inputname)=@_;
if (!defined($type)) { $type='popup'; }
+ if (!defined($width)) { $width=55; }
my %prog_state;
$prog_state{'type'}=$type;
if ($type eq 'popup') {
@@ -650,7 +745,7 @@ sub Create_PrgWin {
"
".
"$heading
".
"'.
"