--- loncom/interface/lonhtmlcommon.pm 2003/01/14 22:01:56 1.11
+++ loncom/interface/lonhtmlcommon.pm 2003/10/15 18:01:10 1.32
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.11 2003/01/14 22:01:56 minaeibi Exp $
+# $Id: lonhtmlcommon.pm,v 1.32 2003/10/15 18:01:10 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -56,8 +56,48 @@ html.
package Apache::lonhtmlcommon;
use Time::Local;
+use Apache::lonlocal;
use strict;
+
+##############################################
+##############################################
+
+=pod
+
+=item textbox
+
+=cut
+
+##############################################
+##############################################
+sub textbox {
+ my ($name,$value,$size,$special) = @_;
+ $size = 40 if (! defined($size));
+ my $Str = '';
+ return $Str;
+}
+
+##############################################
+##############################################
+
+=pod
+
+=item checkbox
+
+=cut
+
+##############################################
+##############################################
+sub checkbox {
+ my ($name) = @_;
+ my $Str = '';
+ return $Str;
+}
+
+
+
##############################################
##############################################
@@ -65,6 +105,9 @@ use strict;
=item &date_setter
+&date_setter returns html and javascript for a compact date-setting form.
+To retrieve values from it, use &get_date_from_form().
+
Inputs
=over 4
@@ -82,12 +125,23 @@ The current setting for this time parame
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
+
+Additional html/javascript to be associated with each element in
+the date_setter. See lonparmset for example usage.
+
+=back
+
+Bugs
+
+The method used to restrict user input will fail in the year 2400.
+
=cut
##############################################
##############################################
sub date_setter {
- my ($formname,$dname,$currentvalue) = @_;
+ my ($formname,$dname,$currentvalue,$special) = @_;
if (! defined($currentvalue) || $currentvalue eq 'now') {
$currentvalue = time;
}
@@ -128,9 +182,19 @@ sub date_setter {
document.$formname.$dname\_day.value = 30;
}
}
+
+ function $dname\_opencalendar() {
+ var calwin=window.open(
+"/adm/announcements?pickdate=yes&formname=$formname&element=$dname&month="+
+document.$formname.$dname\_month.value+"&year="+
+document.$formname.$dname\_year.value,
+ "LONCAPAcal",
+ "height=350,width=350,scrollbars=yes,resizable=yes,menubar=no");
+
+ }
ENDJS
- $result .= " \n";
$result .= " \n";
$result .= " \n";
$result .= " ";
- $result .= " '."\n";
-
+
return $Str;
}
+########################################################
+########################################################
+
+=pod
+
+=item &Title()
+
+Inputs: $pageName a string containing the name of the page to be sent
+to &Apache::loncommon::bodytag.
+
+Returns: string containing being and complete
and
+as well as a ");
+ my %prog_state;
+ $prog_state{'done'}=0;
+ $prog_state{'firststart'}=&Time::HiRes::time();
+ $prog_state{'laststart'}=&Time::HiRes::time();
+ $prog_state{'max'}=$number_to_do;
+
$r->rflush();
+ return %prog_state;
}
# update progress
sub Update_PrgWin {
- my ($displayString,$r)=@_;
+ my ($r,$prog_state,$displayString)=@_;
$r->print('');
+ $$prog_state{'laststart'}=&Time::HiRes::time();
+ $r->rflush();
+}
+
+# increment progress state
+sub Increment_PrgWin {
+ my ($r,$prog_state,$extraInfo)=@_;
+ $$prog_state{'done'}++;
+ my $time_est= (&Time::HiRes::time() - $$prog_state{'firststart'})/
+ $$prog_state{'done'} *
+ ($$prog_state{'max'}-$$prog_state{'done'});
+ $time_est = int($time_est);
+ if (int ($time_est/60) > 0) {
+ my $min = int($time_est/60);
+ my $sec = $time_est % 60;
+ $time_est = $min.' '.&mt('minutes');
+ if ($min < 10) {
+ if ($sec > 1) {
+ $time_est.= ', '.$sec.' '.&mt('seconds');
+ } elsif ($sec > 0) {
+ $time_est.= ', '.$sec.' '.&mt('second');
+ }
+ }
+ } else {
+ $time_est .= ' '.&mt('seconds');
+ }
+ my $lasttime = &Time::HiRes::time()-$$prog_state{'laststart'};
+ if ($lasttime > 9) {
+ $lasttime = int($lasttime);
+ } elsif ($lasttime < 0.01) {
+ $lasttime = 0;
+ } else {
+ $lasttime = sprintf("%3.2f",$lasttime);
+ }
+ if ($lasttime == 1) {
+ $lasttime = '('.$lasttime.' '.&mt('second for').' '.$extraInfo.')';
+ } else {
+ $lasttime = '('.$lasttime.' '.&mt('seconds for').' '.$extraInfo.')';
+ }
+ #
+ my $user_browser = $ENV{'browser.type'} if (exists($ENV{'browser.type'}));
+ my $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 'explorer' && $user_os =~ 'mac') {
+ $lasttime = '';
+ }
+ $r->print('');
+ $$prog_state{'laststart'}=&Time::HiRes::time();
$r->rflush();
}
# close Progress Line
sub Close_PrgWin {
- my ($r)=@_;
+ my ($r,$prog_state)=@_;
$r->print(''."\n");
+ undef(%$prog_state);
$r->rflush();
}
1;
+
__END__