--- loncom/interface/lonhtmlcommon.pm 2009/08/10 12:32:34 1.229 +++ loncom/interface/lonhtmlcommon.pm 2009/09/08 20:48:34 1.235 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.229 2009/08/10 12:32:34 droeschl Exp $ +# $Id: lonhtmlcommon.pm,v 1.235 2009/09/08 20:48:34 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -82,7 +82,7 @@ sub confirm_success { .''."\n"; } else { return ''."\n" - .''.&mt('Ok').' '."\n" + .''.&mt('OK').' '."\n" .$message."\n" .''."\n"; } @@ -160,8 +160,8 @@ sub authorbombs { $url=&Apache::lonnet::declutter($url); my ($udom,$uname)=($url=~m{^($LONCAPA::domain_re)/($LONCAPA::username_re)/}); my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom); - foreach (keys %bombs) { - if ($_=~/^$udom\/$uname\//) { + foreach my $bomb (keys(%bombs)) { + if ($bomb =~ /^$udom\/$uname\//) { return ''.&mt('Bomb').''. &Apache::loncommon::help_open_topic('About_Bombs'); @@ -239,7 +239,7 @@ sub get_recent { # Begin filling return_hash with any 'always_include' option my %time_hash = (); my %return_hash = (); - foreach my $item (keys %recent) { + foreach my $item (keys(%recent)) { my ($thistime,$thisvalue)=(split(/\&/,$recent{$item})); if ($thistime eq 'always_include') { $return_hash{$item} = &unescape($thisvalue); @@ -978,8 +978,7 @@ sub Create_PrgWin { #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,''); + "\nwindow.setTimeout(openpopwin,0)" + )); $prog_state{'formname'}='popremain'; $prog_state{'inputname'}="remaining"; } elsif ($type eq 'inline') { @@ -1025,14 +1023,12 @@ sub Create_PrgWin { # update progress sub Update_PrgWin { my ($r,$prog_state,$displayString)=@_; - &r_print($r,''); + $$prog_state{'formname'}.'.'. + $$prog_state{'inputname'}.'.value="'. + $displayString.'";' + )); $$prog_state{'laststart'}=&Time::HiRes::time(); } @@ -1085,15 +1081,13 @@ sub Increment_PrgWin { if ($user_browser eq 'explorer' && $user_os =~ 'mac') { $lasttime = ''; } - &r_print($r,''); + $$prog_state{'formname'}.'.'. + $$prog_state{'inputname'}.'.value="'. + $$prog_state{'done'}.'/'.$$prog_state{'max'}. + ': '.$time_est.' '.&mt('remaining').' '.$lasttime.'";' + )); $$prog_state{'laststart'}=&Time::HiRes::time(); } @@ -1101,11 +1095,9 @@ sub Increment_PrgWin { sub Close_PrgWin { my ($r,$prog_state)=@_; if ($$prog_state{'type'} eq 'popup') { - &r_print($r,''."\n"); + &r_print($r,&Apache::lonhtmlcommon::scripttag( + 'popwin.close()' + )); } elsif ($$prog_state{'type'} eq 'inline') { &Update_PrgWin($r,$prog_state,&mt('Done')); } @@ -1272,8 +1264,8 @@ sub htmlareaselectactive { my @fields=@_; unless (&htmlareabrowser()) { return ''; } if (&htmlareablocked()) { return '
'.&enablelink(@fields); } - my $output='
'. &disablelink(@fields); return $output; @@ -1461,7 +1453,7 @@ returns: nothing } sub add_breadcrumb { - push (@Crumbs,@_); + push(@Crumbs,@_); } } # End of scope for @Crumbs @@ -1953,7 +1945,7 @@ sub set_form_elements { $values{$name}[$i] =~ s/([\r\n\f]+)/\\n/g; $values{$name}[$i] =~ s/"/\\"/g; } - if ($$elements{$name} eq 'text') { + if (($$elements{$name} eq 'text') || ($$elements{$name} eq 'hidden')) { my $numvalues = @{$values{$name}}; if ($numvalues > 1) { my $valuestring = join('","',@{$values{$name}}); @@ -1988,6 +1980,8 @@ sub set_form_elements { $output .= qq| if (courseForm.elements['$name'].value == "$value") { courseForm.elements['$name'].checked = true; + } else { + courseForm.elements['$name'].checked = false; }|; } } @@ -2029,6 +2023,7 @@ sub set_form_elements { } } $output .= " + return; }\n"; return $output; } @@ -2117,22 +2112,38 @@ sub inittags { } -# USAGE: scripttag(scriptcode, true/false); +# USAGE: scripttag(scriptcode, [start|end|both]); # # EXAMPLES: -# - scripttag("alert('Hello World!')") +# - scripttag("alert('Hello World!')", 'both') +# returns: +# # # NOTES: # - works currently only for javascripts # -# OUTPUT: Scriptcode properly enclosed in