Lines 726-731
$(document).ready(function(){
Link Here
|
726 |
} |
726 |
} |
727 |
} |
727 |
} |
728 |
|
728 |
|
|
|
729 |
function containsInvalidXMLChars(input) { |
730 |
let pattern = /[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD\u10000-\u10FFFF]+/; |
731 |
return pattern . test(input); |
732 |
} |
733 |
|
734 |
function checkForXML(){ |
735 |
let alert_text = ""; |
736 |
let subfields = new Array(); |
737 |
const regex = /([A-Za-z0-9]+)_subfield_([A-Za-z0-9]+)_/; |
738 |
$("input[type='text'].input_marceditor, textarea.input_marceditor").each(function(){ |
739 |
if ( containsInvalidXMLChars(this.value) ){ |
740 |
let html_id = this.id; |
741 |
let subfield = { "id": html_id }; |
742 |
//FIXME: Turns out tabindex isn't the real tab index... |
743 |
subfield['tab'] = parseInt(this.getAttribute('tabindex')) + 1; |
744 |
let match = html_id.match(regex); |
745 |
if (match){ |
746 |
subfield['tag'] = match[1]; |
747 |
subfield['subfield_code'] = match[2]; |
748 |
} |
749 |
subfields.push(subfield); |
750 |
} |
751 |
}); |
752 |
if (subfields.length > 0){ |
753 |
alert_text += "<div class='dialog alert list'>"; |
754 |
alert_text += "<h4>" + _("The following subfields contain characters invalid in XML:") + "</h4>"; |
755 |
for (let i = 0; i < subfields.length; i++){ |
756 |
let subfield = subfields[i]; |
757 |
let tag = subfield.tag; |
758 |
let subfield_code = subfield.subfield_code; |
759 |
let tab = subfield.tab; |
760 |
let id = subfield.id; |
761 |
alert_text += "<li>"+_("Tag %s subfield %s in tab %s").format(tag, subfield_code, tab) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + tab + '" data-field="' + id + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> ' + _("Go to field") + '</a></li>'; |
762 |
} |
763 |
alert_text += "</div>"; |
764 |
} |
765 |
return alert_text; |
766 |
} |
767 |
|
729 |
/** |
768 |
/** |
730 |
* Run checks for mandatory and important fields |
769 |
* Run checks for mandatory and important fields |
731 |
* Output errors if necessary, or submit the form |
770 |
* Output errors if necessary, or submit the form |
Lines 733-738
$(document).ready(function(){
Link Here
|
733 |
function Check(){ |
772 |
function Check(){ |
734 |
var StrAlert = AreFieldsNotOk(); |
773 |
var StrAlert = AreFieldsNotOk(); |
735 |
var StrWarning = AreFieldsNotOk( false ); |
774 |
var StrWarning = AreFieldsNotOk( false ); |
|
|
775 |
|
776 |
[% IF ! advancedMARCEditor %] |
777 |
let AlertXML = checkForXML(); |
778 |
if (AlertXML) { |
779 |
if ( StrAlert === false ) { |
780 |
StrAlert = ''; |
781 |
} |
782 |
StrAlert += AlertXML; |
783 |
} |
784 |
[% END %] |
785 |
|
736 |
if( !StrAlert && StrWarning ){ |
786 |
if( !StrAlert && StrWarning ){ |
737 |
// Check important fields |
787 |
// Check important fields |
738 |
$("#check_errors").html( StrWarning ); |
788 |
$("#check_errors").html( StrWarning ); |
739 |
- |
|
|