1+(function ($) { 2 "use strict"; 3 4 $(document).ready(function () { 5 $("body").on("SMBLeadsFormReady", function () { 6 var $formSection = $('[data-control="form"]'); 7 if ($formSection.length) { 8 $formSection.each(function () { 9 if ($(this).data('mhorgid') != '') { 10 $('<input>').attr({ 11 type: 'hidden', 12 name: 'mh_orgId', 13 value: $(this).data('mhorgid') 14 }).appendTo($('form', $(this))); 15 $('<input>').attr({ 16 type: 'hidden', 17 name: 'mh_template_id', 18 value: $(this).data('templateId') 19 }).appendTo($('form', $(this))); 20 } 21 }); 22 23 var $form = $formSection.find('form'); 24 var $submitBtn = $form.find('input[type=submit]'); 25 26 $submitBtn.on('click', function(e){ 27 var formData = $form.serializeArray(); 28 var formDataObject = {}; 29 30 $.each(formData, function(index, field){ 31 formDataObject[field.name] = field.value; 32 }); 33 34 const errorDialog = document.getElementById('error-form-dialog'); 35 const errorMessage = document.getElementById('p-error-message'); 36 const closeDialogButton = document.getElementById('close-dialog'); 37 38 closeDialogButton.addEventListener('click', () => { 39 errorDialog.close(); 40 document.body.style.overflow = 'auto'; 41 }); 42 var hasExternalUrls = checkUrlsInComments(formDataObject); 43 if (hasExternalUrls) { 44 var message = 45 'Error: Your message could not be delivered because it contains a link to an external website. Please review your message and try again.'; 46 errorMessage.innerHTML = message; 47 errorDialog.showModal(); 48 document.body.style.overflow = 'hidden'; 49 errorDialog.style.display = 'block'; 50 51 e.preventDefault(); 52 } 53 }); 54 } 55 56 $('.leadForm .hasDatepicker').each(function() { 57 $(this).attr({ 58 type:"text", 59 readonly:"readonly", 60 }); 61 }); 62 }); 63 64 // add section-form class if there is form inside pagecontent section 65 var $formIsPle = $('.form.isPleForm'); 66 if ($formIsPle.length) { 67 $formIsPle.each(function () { 68 var $parentSection = $(this).closest('.section'); 69 if(!$parentSection.hasClass('section-form')) { 70 $parentSection.addClass('section-form'); 71 }; 72 }); 73 }; 74 75 // target section form without these section class and if it's only ple 76 var $formSectionClean = $('.section-form:not(.newsletter-2-fields):not(.newsletter-3-fields):not(.contact-us-im):not(.appointment-request):not(.exclusive-offer):not(.pet-memorial):not(.form-default)'); 77 78 if ($formSectionClean.length && $formIsPle.length) { 79 80 $formSectionClean.each(function () { 81 82 $(this).find($formIsPle).addClass('form-themeExtras'); 83 $("body").on("SMBLeadsFormReady", function () { 84 var $form2colSection = $('.forms--2col-textarea:not(.newsletter-2-fields):not(.newsletter-3-fields):not(.contact-us-im):not(.appointment-request):not(.exclusive-offer):not(.pet-memorial):not(.form-default)'), 85 $formLabelOptionB = $('.forms-option--b .leadForm .form__group:not(.checkbox__group):not(.radio__group)'); 86 87 $form2colSection.find($formIsPle).each(function () { 88 var formGroup = $(this).find(".form__group").not(".form-input-comments"); 89 formGroup.wrapAll("<div class='groupWrap' />"); 90 }); 91 92 $formLabelOptionB.each(function () { 93 if ($(this).hasClass('hasLabel')) { 94 $(this).addClass('optionB-enabled'); 95 } 96 }); 97 }); 98 99 }); 100 } 101 102 function checkUrlsInComments(postData) { 103 if (!('comments' in postData)) { 104 return false;
105 } 106 function getUrlRegex() { 107 var regex = "((https?|ftp):\\/\\/)?"; 108 regex += "([a-z0-9+!*(),;?&=$_.-]+(:[a-z0-9+!*(),;?&=$_.-]+)?@)?"; 109 regex += "([a-z0-9-.]*)\\.([a-z]{2,3})"; 110 regex += "(:[0-9]{2,5})?"; 111 regex += "(\\/([a-z0-9+$_-]\\.?)+)*\\/?"; 112 regex += "(\\?[a-z+&$_.-][a-z0-9;:@&%=+\\/$_.-]*)?"; 113 regex += "(#[a-z_.-][a-z0-9+$_.-]*)?"; 114 return new RegExp(regex, 'i'); 115 } 116 117 var urlRegex = getUrlRegex(); 118 119 var comments = postData['comments']; 120 return !! comments.match(urlRegex); 121 } 122 }); 123 124})(window.jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.