[LON-CAPA-cvs] cvs: loncom /interface lonhtmlcommon.pm
sakharuk
lon-capa-cvs@mail.lon-capa.org
Fri, 13 Feb 2004 21:12:12 -0000
sakharuk Fri Feb 13 16:12:12 2004 EDT
Modified files:
/loncom/interface lonhtmlcommon.pm
Log:
Changes to use Status Window in printout.pl just for the printing (without request object).
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.46 loncom/interface/lonhtmlcommon.pm:1.47
--- loncom/interface/lonhtmlcommon.pm:1.46 Thu Feb 12 17:23:30 2004
+++ loncom/interface/lonhtmlcommon.pm Fri Feb 13 16:12:12 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.46 2004/02/12 22:23:30 matthew Exp $
+# $Id: lonhtmlcommon.pm,v 1.47 2004/02/13 21:12:12 sakharuk Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -56,6 +56,7 @@
package Apache::lonhtmlcommon;
use Time::Local;
+use Time::HiRes;
use Apache::lonlocal;
use strict;
@@ -629,19 +630,35 @@
my ($r, $title, $heading, $number_to_do)=@_;
#the whole function called through timeout is due to issues
#in mozilla Read BUG #2665 if you want to know the whole story
- $r->print('<script>'.
- "var popwin;
- function openpopwin () {
- popwin=open(\'\',\'popwin\',\'width=400,height=100\');".
- "popwin.document.writeln(\'<html><head><title>$title</title></head>".
- "<body bgcolor=\"#88DDFF\">".
- "<h4>$heading</h4>".
- "<form name=popremain>".
- '<input type="text" size="55" name="remaining" value="'.
- &mt('Starting').'"></form>'.
- "</body></html>\');".
- "popwin.document.close();}".
- "\nwindow.setTimeout(openpopwin,0)</script>");
+ if ($r ne '') {
+ $r->print('<script>'.
+ "var popwin;
+ function openpopwin () {
+ popwin=open(\'\',\'popwin\',\'width=400,height=100\');".
+ "popwin.document.writeln(\'<html><head><title>$title</title></head>".
+ "<body bgcolor=\"#88DDFF\">".
+ "<h4>$heading</h4>".
+ "<form name=popremain>".
+ '<input type="text" size="55" name="remaining" value="'.
+ &mt('Starting').'"></form>'.
+ "</body></html>\');".
+ "popwin.document.close();}".
+ "\nwindow.setTimeout(openpopwin,0)</script>");
+ } else {
+ print('<script>'.
+ "var popwin;
+ function openpopwin () {
+ popwin=open(\'\',\'popwin\',\'width=400,height=100\');".
+ "popwin.document.writeln(\'<html><head><title>$title</title></head>".
+ "<body bgcolor=\"#88DDFF\">".
+ "<h4>$heading</h4>".
+ "<form name=popremain>".
+ '<input type="text" size="55" name="remaining" value="'.
+ &mt('Starting').'"></form>'.
+ "</body></html>\');".
+ "popwin.document.close();}".
+ "\nwindow.setTimeout(openpopwin,0)</script>");
+ }
my %prog_state;
$prog_state{'done'}=0;
@@ -649,17 +666,22 @@
$prog_state{'laststart'}=&Time::HiRes::time();
$prog_state{'max'}=$number_to_do;
- $r->rflush();
+ if ($r ne '') {$r->rflush();}
return %prog_state;
}
# update progress
sub Update_PrgWin {
my ($r,$prog_state,$displayString)=@_;
- $r->print('<script>popwin.document.popremain.remaining.value="'.
+ if ($r ne '') {
+ $r->print('<script>popwin.document.popremain.remaining.value="'.
+ $displayString.'";</script>');
+ } else {
+ print('<script>popwin.document.popremain.remaining.value="'.
$displayString.'";</script>');
+ }
$$prog_state{'laststart'}=&Time::HiRes::time();
- $r->rflush();
+ if ($r ne '') {$r->rflush();}
}
# increment progress state
@@ -707,19 +729,29 @@
if ($user_browser eq 'explorer' && $user_os =~ 'mac') {
$lasttime = '';
}
- $r->print('<script>popwin.document.popremain.remaining.value="'.
+ if ($r ne '') {
+ $r->print('<script>popwin.document.popremain.remaining.value="'.
+ $$prog_state{'done'}.'/'.$$prog_state{'max'}.
+ ': '.$time_est.' '.&mt('remaining').' '.$lasttime.'";'.'</script>');
+ } else {
+ print('<script>popwin.document.popremain.remaining.value="'.
$$prog_state{'done'}.'/'.$$prog_state{'max'}.
': '.$time_est.' '.&mt('remaining').' '.$lasttime.'";'.'</script>');
+ }
$$prog_state{'laststart'}=&Time::HiRes::time();
- $r->rflush();
+ if ($r ne '') {$r->rflush();}
}
# close Progress Line
sub Close_PrgWin {
my ($r,$prog_state)=@_;
- $r->print('<script>popwin.close()</script>'."\n");
+ if ($r ne '') {
+ $r->print('<script>popwin.close()</script>'."\n");
+ } else {
+ print('<script>popwin.close()</script>'."\n");
+ }
undef(%$prog_state);
- $r->rflush();
+ if ($r ne '') {$r->rflush();}
}