version 1.405, 2022/06/30 21:04:14
|
version 1.409, 2023/09/10 18:12:54
|
Line 1813 clientTime = (new Date()).getTime();
|
Line 1813 clientTime = (new Date()).getTime();
|
END |
END |
} |
} |
|
|
|
## |
|
# Client-side javascript to convert any dashes in text pasted |
|
# into textbox(es) for numericalresponse item(s) to a standard |
|
# minus, i.e., - . Calls to dash_to_minus_js() in end_problem() |
|
# and in loncommon::endbodytag() for a .page (arg: dashjs => 1) |
|
# |
|
# Will apply to any input tag with class: LC_numresponse_text. |
|
# Currently set in start_textline for numericalresponse items. |
|
# |
|
|
|
sub dash_to_minus_js { |
|
return <<'ENDJS'; |
|
|
|
<script type="text/javascript"> |
|
//<![CDATA[ |
|
//<!-- BEGIN LON-CAPA Internal |
|
document.addEventListener("DOMContentLoaded", (event) => { |
|
const numresp = document.querySelectorAll("input.LC_numresponse_text"); |
|
if (numresp.length > 0) { |
|
numresp.forEach((el) => { |
|
el.addEventListener("paste", (e) => { |
|
e.preventDefault(); |
|
e.stopPropagation(); |
|
let p = (e.clipboardData || window.clipboardData).getData("text"); |
|
p.toString(); |
|
p = p.replace(/\p{Dash}/gu, '-'); |
|
putInText(p); |
|
}); |
|
}); |
|
} |
|
const putInText = (newText, el = document.activeElement) => { |
|
const [start, end] = [el.selectionStart, el.selectionEnd]; |
|
el.setRangeText(newText, start, end, 'end'); |
|
} |
|
}); |
|
// END LON-CAPA Internal --> |
|
//]]> |
|
</script> |
|
|
|
ENDJS |
|
} |
|
|
############################################################ |
############################################################ |
############################################################ |
############################################################ |
|
|
Line 2263 sub docs_breadcrumbs {
|
Line 2305 sub docs_breadcrumbs {
|
# each of randompick number, hidden, encrypted, random order, is_page |
# each of randompick number, hidden, encrypted, random order, is_page |
# are appended with ":"s to the foldername |
# are appended with ":"s to the foldername |
$name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)\:?(\d*)$//; |
$name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)\:?(\d*)$//; |
unless ($supplementalflag) { |
if ($contenteditor) { |
if ($contenteditor) { |
if ($supplementalflag) { |
|
if ($2) { $ishidden=1; } |
|
} else { |
if ($1 ne '') { |
if ($1 ne '') { |
$randompick=$1; |
$randompick=$1; |
} else { |
} else { |
Line 3535 THIRD
|
Line 3579 THIRD
|
sub javascript_jumpto_resource { |
sub javascript_jumpto_resource { |
my $confirm_switch = &mt("Editing requires switching to the resource's home server.")."\n". |
my $confirm_switch = &mt("Editing requires switching to the resource's home server.")."\n". |
&mt('Switch server?'); |
&mt('Switch server?'); |
|
my $confirm_new_tab = &mt("Editing requires using the resource's home server.")."\n". |
|
&mt('Open a new browser tab?'); |
&js_escape(\$confirm_switch); |
&js_escape(\$confirm_switch); |
|
&js_escape(\$confirm_new_tab); |
return (<<ENDUTILITY) |
return (<<ENDUTILITY) |
|
|
function go(url) { |
function go(url) { |
Line 3556 function go(url) {
|
Line 3603 function go(url) {
|
} |
} |
} |
} |
|
|
function need_switchserver(url) { |
function need_switchserver(url,target) { |
if (url!='' && url!= null) { |
if (url!='' && url!= null) { |
if (confirm("$confirm_switch")) { |
if (target == '_blank') { |
|
if (confirm("$confirm_new_tab")) { |
|
window.open(url,target); |
|
} |
|
} else if (confirm("$confirm_switch")) { |
go(url); |
go(url); |
} |
} |
} |
} |
Line 3570 ENDUTILITY
|
Line 3621 ENDUTILITY
|
} |
} |
|
|
sub jump_to_editres { |
sub jump_to_editres { |
my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath, |
my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$shownsymb, |
$title,$hostname,$idx,$suppurl,$todocs,$suppanchor) = @_; |
$folderpath,$title,$hostname,$idx,$suppurl,$todocs,$suppanchor) = @_; |
my ($jscall,$anchor,$usehttp,$usehttps,$is_ext); |
my ($jscall,$anchor,$usehttp,$usehttps,$is_ext,$target); |
if ($switchserver) { |
if ($switchserver) { |
if ($home) { |
if ($home) { |
|
my $resedit; |
|
if ($cfile =~ m{^/priv/($match_domain)/($match_username)/}) { |
|
my ($audom,$auname) = ($1,$2); |
|
unless (&Apache::lonnet::is_course($audom,$auname)) { |
|
unless ((&Apache::lonnet::will_trust('othcoau',$env{'user.domain'},$audom)) && |
|
(&Apache::lonnet::will_trust('coaurem',$audom,$env{'user.domain'}))) { |
|
return; |
|
} |
|
if (($symb ne '') && ($env{'request.course.id'}) && |
|
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { |
|
unless (&Apache::lonnet::can_switchserver($env{'user.domain'},$home)) { |
|
$target = '_blank'; |
|
$resedit = 1; |
|
} |
|
} |
|
} |
|
} |
$cfile = '/adm/switchserver?otherserver='.$home.'&role='. |
$cfile = '/adm/switchserver?otherserver='.$home.'&role='. |
&HTML::Entities::encode($env{'request.role'},'"<>&'); |
&HTML::Entities::encode($env{'request.role'},'"<>&'); |
if ($symb) { |
if ($shownsymb) { |
$cfile .= '&symb='.&HTML::Entities::encode($symb,'"<>&'); |
$cfile .= '&symb='.&HTML::Entities::encode($shownsymb,'"<>&'); |
|
if ($resedit) { |
|
$cfile .= '&edit=1'; |
|
} |
} elsif ($folderpath) { |
} elsif ($folderpath) { |
$cfile .= '&folderpath='.&HTML::Entities::encode($folderpath,'"<>&'); |
$cfile .= '&folderpath='.&HTML::Entities::encode($folderpath,'"<>&'); |
} |
} |
Line 3588 sub jump_to_editres {
|
Line 3659 sub jump_to_editres {
|
if ($forcereg) { |
if ($forcereg) { |
$cfile .= '&register=1'; |
$cfile .= '&register=1'; |
} |
} |
$jscall = "need_switchserver('".&Apache::loncommon::escape_single($cfile)."');"; |
$jscall = "need_switchserver('".&Apache::loncommon::escape_single($cfile)."','$target')"; |
} |
} |
} else { |
} else { |
unless ($cfile =~ m{^/priv/}) { |
unless ($cfile =~ m{^/priv/}) { |