--- loncom/interface/lonhtmlcommon.pm 2017/02/25 19:48:33 1.382
+++ loncom/interface/lonhtmlcommon.pm 2017/11/16 13:31:29 1.390
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.382 2017/02/25 19:48:33 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.390 2017/11/16 13:31:29 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -92,7 +92,7 @@ sub raw_href_to_link {
sub entity_encode {
my ($text)=@_;
- return &HTML::Entities::encode($text, '<>&"');
+ return &HTML::Entities::encode($text, '\'<>&"');
}
sub direct_parm_link {
@@ -1025,11 +1025,15 @@ data structure used for bookkeeping.
=item $number_to_do The total number of items being processed.
+=item $preamble Optional HTML to display before the progress bar.
+
=back
=back
Returns a hash containing the progress state data structure.
+If $number_to_do is zero or null, an indeterminate progress bar will
+be used.
=item &Update_PrgWin()
@@ -1118,20 +1122,20 @@ Returns: none
# Create progress
sub Create_PrgWin {
- my ($r,$number_to_do)=@_;
+ my ($r,$number_to_do,$preamble)=@_;
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;
- &Apache::loncommon::LCprogressbar($r);
+ &Apache::loncommon::LCprogressbar($r,$prog_state{'max'},$preamble);
return %prog_state;
}
# update progress
sub Update_PrgWin {
my ($r,$prog_state,$displayString)=@_;
- &Apache::loncommon::LCprogressbarUpdate($r,undef,$displayString);
+ &Apache::loncommon::LCprogressbarUpdate($r,undef,$displayString,$$prog_state{'max'});
$$prog_state{'laststart'}=&Time::HiRes::time();
}
@@ -1181,7 +1185,7 @@ sub Increment_PrgWin {
if ($$prog_state{'max'}) {
$percent=int(100.*$current/$$prog_state{'max'});
}
- &Apache::loncommon::LCprogressbarUpdate($r,$percent,$timeinfo);
+ &Apache::loncommon::LCprogressbarUpdate($r,$percent,$timeinfo,$$prog_state{'max'});
$$prog_state{'laststart'}=&Time::HiRes::time();
}
@@ -1301,9 +1305,9 @@ sub htmlareaheaders {
ENDEDITOR
}
$s.=(<
-
-
+
+
+
@@ -1727,7 +1731,7 @@ sub show_return_link {
(($env{'request.noversionuri'}=~/^\/adm\//) &&
($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
($env{'request.noversionuri'}!~
- m{^/adm/.*/(smppg|bulletinboard|exttools?)($|\?)})
+ m{^/adm/.*/(smppg|bulletinboard|ext\.tool)($|\?)})
));
}
@@ -3477,7 +3481,8 @@ function go(url) {
if (url!='' && url!= null) {
currentURL = null;
currentSymb= null;
- window.location.href=url;
+ var lcHostname = setLCHost();
+ window.location.href=lcHostname+url;
}
}
@@ -3497,7 +3502,7 @@ ENDUTILITY
sub jump_to_editres {
my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath,
$title,$hostname,$idx,$suppurl,$todocs,$suppanchor) = @_;
- my ($jscall,$anchor,$usehttp,$usehttps);
+ my ($jscall,$anchor,$usehttp,$usehttps,$is_ext);
if ($switchserver) {
if ($home) {
$cfile = '/adm/switchserver?otherserver='.$home.'&role='.
@@ -3517,9 +3522,18 @@ sub jump_to_editres {
}
} else {
unless ($cfile =~ m{^/priv/}) {
- if ($cfile =~ m{^(/adm/wrapper/ext/[^#]+)#([^#]+)$}) {
+ if ($cfile =~ m{^(/adm/wrapper/ext/([^#]+))#([^#]+)$}) {
$cfile = $1;
- $anchor = $2;
+ my $extlink = $2;
+ $anchor = $3;
+ $is_ext = 1;
+ if (($extlink !~ /^https:/) && ($ENV{'SERVER_PORT'} == 443)) {
+ $usehttp = 1;
+ } elsif ($env{'request.use_absolute'}) {
+ if ($env{'request.use_absolute'} =~ m{^https://}) {
+ $usehttps = 1;
+ }
+ }
} elsif ($cfile =~ m{^/?public/($match_domain)/($match_courseid)/syllabus}) {
if ($ENV{'SERVER_PORT'} == 443) {
my ($cdom,$cnum) = ($1,$2);
@@ -3567,7 +3581,9 @@ sub jump_to_editres {
if ($hostname ne '') {
$cfile = 'http://'.$hostname.(($cfile =~ /^\//)? '':'/').$cfile;
}
- $cfile .= (($cfile=~/\?/)?'&':'?').'usehttp=1';
+ unless ($is_ext) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').'usehttp=1';
+ }
} elsif ($usehttps) {
$cfile = $env{'request.use_absolute'}.(($cfile =~ /^\//)? '':'/').$cfile;
}
@@ -3596,15 +3612,18 @@ sub jump_to_editres {
# javascript_valid_email
#
# Generates javascript to validate an e-mail address.
-# Returns a javascript function which accetps a form field as argumnent, and
+# Returns a javascript function which accepts a form field as argument, and
# returns false if field.value does not satisfy two regular expression matches
# for a valid e-mail address. Backwards compatible with old browsers without
# support for javascript RegExp (just checks for @ in field.value in this case).
sub javascript_valid_email {
my $scripttag .= <<'END';
-function validmail(field) {
+function validmail(field,suffix) {
var str = field.value;
+ if (suffix != '' && suffix != undefined) {
+ str += suffix;
+ }
if (window.RegExp) {
var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //"