--- loncom/interface/lonrequestcourse.pm 2015/05/21 23:40:09 1.87 +++ loncom/interface/lonrequestcourse.pm 2015/06/09 21:22:57 1.89 @@ -1,7 +1,7 @@ # The LearningOnline Network # Request a course # -# $Id: lonrequestcourse.pm,v 1.87 2015/05/21 23:40:09 raeburn Exp $ +# $Id: lonrequestcourse.pm,v 1.89 2015/06/09 21:22:57 damieng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -768,7 +768,7 @@ END "; } } - my %lt = &Apache::lonlocal::texthash( + my %js_lt = &Apache::lonlocal::texthash( official => 'You are not permitted to request creation of an official course in this domain.', unofficial => 'You are not permitted to request creation of an unofficial course in this domain.', community => 'You are not permitted to request creation of a community in this domain.', @@ -776,33 +776,34 @@ END all => 'You must choose a specific course type when making a new course request.', allt => '"All types" is not allowed.', ); + &js_escape(\%js_lt); $js .= <<END; if (crschoice == 'official') { if (official != 1) { - alert("$lt{'official'}"); + alert("$js_lt{'official'}"); return false; } } else { if (crschoice == 'unofficial') { if (unofficial != 1) { - alert("$lt{'unofficial'}"); + alert("$js_lt{'unofficial'}"); return false; } } else { if (crschoice == 'community') { if (community != 1) { - alert("$lt{'community'}"); + alert("$js_lt{'community'}"); return false; } } else { if (crschoice == 'textbook') { if (textbook != 1) { - alert("$lt{'community'}"); + alert("$js_lt{'textbook'}"); return false; } } else { if (actionchoice == 'new') { - alert('$lt{'all'}'+'\\n'+'$lt{'allt'}'); + alert('$js_lt{'all'}'+'\\n'+'$js_lt{'allt'}'); return false; } } @@ -1175,6 +1176,8 @@ sub enrollment_lcsec_js { my %alerts = §ion_check_alerts(); my $secname = $alerts{'badsec'}; my $secnone = $alerts{'reserved'}; + &js_escape(\$secname); + &js_escape(\$secnone); my $output = ' function validateEnrollSections(formname,nextstate) { var badsectotal = 0; @@ -1232,8 +1235,10 @@ function validateEnrollSections(formname sub personnel_lcsec_js { my %alerts = §ion_check_alerts(); - my $secname = $alerts{'badsec'}.'\\n'.$alerts{'separate'}; + my $secname = $alerts{'badsec'}."\n".$alerts{'separate'}; my $secnone = $alerts{'reserved'}; + &js_escape(\$secname); + &js_escape(\$secnone); my $output = ' function validatePersonnelSections(formname,nextstate) { var badsectotal = 0; @@ -2416,8 +2421,9 @@ ENDJS } sub viewcancel_javascript { - my $alert = &mt('Are you sure you want to cancel this request?').'\\n'. + my $alert = &mt('Are you sure you want to cancel this request?')."\n". &mt('Your request will be removed.'); + &js_escape(\$alert); return << "ENDJS"; function nextPage(formname,nextstate) { if (confirm('$alert')) { @@ -3059,19 +3065,20 @@ sub dates_from_form { sub courseinfo_form { my ($dom,$formname,$crstype,$next,$description) = @_; - my %lt = &Apache::lonlocal::texthash( + my %js_lt = &Apache::lonlocal::texthash( official => 'You must provide a (brief) course description.', community => 'You must provide a (brief) community description.' ); - $lt{'unofficial'} = $lt{'official'}; - $lt{'textbook'} = $lt{'official'}; + &js_escape(\%js_lt); + $js_lt{'unofficial'} = $js_lt{'official'}; + $js_lt{'textbook'} = $js_lt{'official'}; my $js_validate = <<"ENDJS"; <script type="text/javascript"> // <![CDATA[' function validateForm() { if ((document.$formname.cdescr.value == "") || (document.$formname.cdescr.value == "undefined")) { - alert('$lt{$crstype}'); + alert('$js_lt{$crstype}'); return; } nextPage(document.$formname,'$next'); @@ -4881,13 +4888,14 @@ sub textbook_request_javascript { my ($numprefab,$numcurrent) = @_; return unless (ref($numprefab) eq 'HASH'); return if (!$numprefab->{'textbooks'} && !$numprefab->{'templates'} && !$numcurrent); - my %lt = &Apache::lonlocal::texthash( + my %js_lt = &Apache::lonlocal::texthash( choose => 'Please select a content option.', textbook => 'Please select a textbook, or choose a different option.', template => 'Please select a template, or choose a different option.', existing => 'Please select one of your existing courses to copy, or choose a different option.', title => 'Please enter a course title.', ); + &js_escape(\%js_lt); return <<"ENDSCRIPT"; function cloneChoice() { if (document.requestcourse.cloning) { @@ -4950,9 +4958,9 @@ function uncheckAllRadio() { if (numbook > 0) { uncheckRadio('textbook'); } - if (nutemplate > 0) { + if (numtemplate > 0) { uncheckRadio('template'); - }m + } if (numcurrent > 0) { uncheckRadio('existing'); } @@ -4965,7 +4973,7 @@ function validTextbookReq() { var radioLength = document.requestcourse.cloning.length; if (radioLength == undefined) { if (document.requestcourse.cloning.checked == false) { - alert("$lt{'choose'}"); + alert("$js_lt{'choose'}"); return false; } else { cloneChoice = document.requestcourse.cloning.value; @@ -4978,7 +4986,7 @@ function validTextbookReq() { } } if (cloneChoice == 0) { - alert("$lt{'choose'}"); + alert("$js_lt{'choose'}"); return false; } } @@ -5010,12 +5018,12 @@ function validTextbookReq() { } if (chosen == 0) { if (cloneChoice == 'textbook') { - alert("$lt{'textbook'}"); + alert("$js_lt{'textbook'}"); } else { if (cloneChoice == 'template') { - alert("$lt{'template'}"); + alert("$js_lt{'template'}"); } else { - alert("$lt{'existing'}"); + alert("$js_lt{'existing'}"); } } return false; @@ -5023,7 +5031,7 @@ function validTextbookReq() { } } if (document.requestcourse.cdescr.value == '') { - alert("$lt{'title'}"); + alert("$js_lt{'title'}"); return false; } return true;