[LON-CAPA-cvs] cvs: loncom /interface lonhtmlcommon.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 16 Feb 2004 22:28:55 -0000
albertel Mon Feb 16 17:28:55 2004 EDT
Modified files:
/loncom/interface lonhtmlcommon.pm
Log:
- support inline style progress windows
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.48 loncom/interface/lonhtmlcommon.pm:1.49
--- loncom/interface/lonhtmlcommon.pm:1.48 Mon Feb 16 16:49:16 2004
+++ loncom/interface/lonhtmlcommon.pm Mon Feb 16 17:28:55 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.48 2004/02/16 21:49:16 albertel Exp $
+# $Id: lonhtmlcommon.pm,v 1.49 2004/02/16 22:28:55 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -627,36 +627,62 @@
# Create progress
sub Create_PrgWin {
- 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($r,'<script>'.
- "var popwin;
- function openpopwin () {
- popwin=open(\'\',\'popwin\',\'width=400,height=100\');".
- "popwin.document.writeln(\'<html><head><title>$title</title></head>".
+ my ($r, $title, $heading, $number_to_do,$type,$formname,$inputname)=@_;
+ if (!defined($type)) { $type='popup'; }
+ my %prog_state;
+ $prog_state{'type'}=$type;
+ if ($type eq 'popup') {
+ $prog_state{'window'}='popwin';
+ #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($r,'<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>");
+ "popwin.document.close();}".
+ "\nwindow.setTimeout(openpopwin,0)</script>");
+ $prog_state{'formname'}='popremain';
+ $prog_state{'inputname'}="remaining";
+ } elsif ($type eq 'inline') {
+ $prog_state{'window'}='window';
+ if (!$formname) {
+ &r_print($r,'<form name="progresswindow">');
+ $prog_state{'formname'}='progresswindow';
+ } else {
+ $prog_state{'formname'}=$formname;
+ }
+ if (!$inputname) {
+ &r_print($r,'<input type="text" name="progressline" />');
+ $prog_state{'inputname'}="progressline";
+ } else {
+ $prog_state{'inputname'}=$inputname;
+
+ }
+ if (!$formname) { &r_print($r,'</form>'); }
+ &Update_PrgWin($r,\%prog_state,&mt('Starting'));
+ }
- 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;
-
+
return %prog_state;
}
# update progress
sub Update_PrgWin {
my ($r,$prog_state,$displayString)=@_;
- &r_print($r,'<script>popwin.document.popremain.remaining.value="'.
+ &r_print($r,'<script>'.$$prog_state{'window'}.'.document.'.
+ $$prog_state{'formname'}.'.'.
+ $$prog_state{'inputname'}.'.value="'.
$displayString.'";</script>');
$$prog_state{'laststart'}=&Time::HiRes::time();
}
@@ -706,7 +732,9 @@
if ($user_browser eq 'explorer' && $user_os =~ 'mac') {
$lasttime = '';
}
- &r_print($r,'<script>popwin.document.popremain.remaining.value="'.
+ &r_print($r,'<script>'.$$prog_state{'window'}.'.document.'.
+ $$prog_state{'formname'}.'.'.
+ $$prog_state{'inputname'}.'.value="'.
$$prog_state{'done'}.'/'.$$prog_state{'max'}.
': '.$time_est.' '.&mt('remaining').' '.$lasttime.'";'.'</script>');
$$prog_state{'laststart'}=&Time::HiRes::time();
@@ -715,7 +743,11 @@
# close Progress Line
sub Close_PrgWin {
my ($r,$prog_state)=@_;
- &r_print($r,'<script>popwin.close()</script>'."\n");
+ if ($$prog_state{'type'} eq 'popup') {
+ &r_print($r,'<script>popwin.close()</script>'."\n");
+ } elsif ($$prog_state{'type'} eq 'inline') {
+ &Update_PrgWin($r,$prog_state,&mt('Done'));
+ }
undef(%$prog_state);
}