--- loncom/interface/lonhtmlcommon.pm 2004/02/16 22:32:19 1.50
+++ loncom/interface/lonhtmlcommon.pm 2004/10/05 20:35:02 1.91
@@ -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.91 2004/10/05 20:35:02 albertel 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));
@@ -164,9 +169,15 @@ sub textbox {
##############################################
##############################################
sub checkbox {
- my ($name,$value) = @_;
- my $Str = '';
+ my ($name,$checked,$value) = @_;
+ my $Str = '
ENDJS
$result .= " \n";
- $result .= " \n";
- $result .= " \n";
$result .= " ";
- $result .= " \n";
- $result .= " m\n";
- $result .= " s\n";
+ if (! $no_hh_mm_ss) {
+ # Hours
+ $result .= " \n";
+ $result .= " m\n";
+ $result .= " s\n";
+ }
$result .= "".
&mt('Select Date')."\n\n";
return $result;
@@ -360,18 +417,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 +525,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 +646,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 +720,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 +746,7 @@ sub Create_PrgWin {
"
".
"$heading
".
"'.
"