--- loncom/interface/lonhtmlcommon.pm 2003/02/19 20:13:45 1.12
+++ loncom/interface/lonhtmlcommon.pm 2003/03/10 20:25:00 1.18
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.12 2003/02/19 20:13:45 matthew Exp $
+# $Id: lonhtmlcommon.pm,v 1.18 2003/03/10 20:25:00 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -249,6 +249,40 @@ sub get_date_from_form {
##############################################
##############################################
+=pod
+
+=item &javascript_nothing()
+
+Return an appropriate null for the users browser. This is used
+as the first arguement for window.open calls when you want a blank
+window that you can then write to.
+
+=cut
+
+##############################################
+##############################################
+sub javascript_nothing {
+ # mozilla and other browsers work with "''", but IE on mac does not.
+ 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 'explorer' && $user_os =~ 'mac') {
+ $nothing = "'javascript:void(0);'";
+ }
+ return $nothing;
+}
+
+##############################################
+##############################################
+
+
+
sub AscendOrderOptions {
my ($order, $page, $formName)=@_;
@@ -524,7 +558,7 @@ sub Title {
=pod
-=item &CreateTableHeadings()
+=item &CreateHeadings()
This function generates the column headings for the chart.
@@ -640,33 +674,70 @@ sub FormatStudentInformation {
# Create progress
sub Create_PrgWin {
- my ($r, $title, $heading)=@_;
+ my ($r, $title, $heading, $number_to_do)=@_;
$r->print('");
+ my %prog_state;
+ $prog_state{'done'}=0;
+ $prog_state{'firststart'}=time;
+ $prog_state{'laststart'}=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;
+ $r->rflush();
+}
+
+# increment progress state
+sub Increment_PrgWin {
+ my ($r,$prog_state,$extraInfo)=@_;
+ $$prog_state{'done'}++;
+ my $time_est= (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.' minutes';
+ if ($sec > 1) {
+ $time_est.= ', '.$sec.' seconds';
+ } elsif ($sec > 0) {
+ $time_est.= ', '.$sec.' second';
+ }
+ } else {
+ $time_est .= ' seconds';
+ }
+
+ $r->print('');
+ $$prog_state{'laststart'}=time;
$r->rflush();
}
# close Progress Line
sub Close_PrgWin {
- my ($r)=@_;
+ my ($r,$prog_state)=@_;
$r->print(''."\n");
+ undef(%$prog_state);
$r->rflush();
}