1jQuery(document).ready(function($){ 2$('.formlayer-form').on('submit', function(e){ 3e.preventDefault(); 4let $form=$(this); 5$submit_Btn=$form.find('.formlayer-submit-btn'), 6$status=$form.find('.formlayer-form-status'), 7formId=$form.data('form-id'); 8$submit_Btn.prop('disabled', true).addClass('loading'); 9$status.html('').removeClass('formlayer-success-message formlayer-error-message'); 10var formData=new FormData(this); 11var errors=[]; 12$form.find('.formlayer-email-confirm').each(function(){ 13var matchName=$(this).data('match'); 14var originalVal=$form.find('input[name="' + matchName + '"]').val(); 15if($(this).val()!==originalVal){ 16errors.push('Emails do not match.'); 17}}); 18$form.find('input[type="number"][maxlength]').each(function(){ 19var limit=parseInt($(this).attr('maxlength')); 20if($(this).val().length > limit){ 21errors.push('Value exceeds maximum digit limit of ' + limit); 22}}); 23$form.find('input[data-validate-url="1"]').each(function(){ 24var val=$(this).val(); 25if(val&&!val.match(/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/)){ 26errors.push('Please enter a valid URL.'); 27}}); 28$form.find('input[data-https-only="1"]').each(function(){ 29var val=$(this).val(); 30if(val&&!val.startsWith('https://')){ 31errors.push('Only HTTPS URLs are allowed.'); 32}}); 33if(errors.length > 0){ 34$status.addClass('formlayer-error-message').html(errors.join('<br>')); 35$submit_Btn.prop('disabled', false).removeClass('loading'); 36return; 37} 38formData.append('action', 'formlayer_submit_form'); 39formData.append('nonce', formlayer_data.nonce); 40formData.append('form_id', formId); 41$.ajax({ 42url: formlayer_data.ajax_url, 43method: 'POST', 44data: formData, 45processData: false, 46contentType: false, 47success: function(response){ 48$submit_Btn.prop('disabled', false).removeClass('loading'); 49if(response.success){ 50var confirmation=response.data.settings||{ type: 'message', message: 'Thank you! Your form has been submitted successfully.', hide_form: true }; 51if(confirmation.type==='redirect'&&confirmation.redirect_url){ 52$status.addClass('formlayer-success-message').html('Redirecting...'); 53window.location.href=confirmation.redirect_url; 54}else{ 55if(confirmation.hide_form!==false){ 56$form.find('.formlayer-form-fields-wrapper').hide(); 57} 58$form[0].reset(); 59$status.addClass('formlayer-success-message').html(confirmation.message||'Thank you! Your form has been submitted successfully.'); 60}}else{ 61$status.addClass('formlayer-error-message').html(response.data.message||'An error occurred.'); 62}}, 63error: function(jqXHR, textStatus, errorThrown){ 64$submit_Btn.prop('disabled', false).removeClass('loading'); 65console.error('Submission error:', textStatus, errorThrown, jqXHR.responseText); 66var msg='An unexpected error occurred. Please try again.'; 67if(textStatus==='timeout') msg='Request timed out. Please check your connection.'; 68$status.addClass('formlayer-error-message').html(msg); 69}}); 70}); 71$('.formlayer-rating .dashicons').on('click', function(){ 72var value=$(this).data('value'); 73var $container=$(this).closest('.formlayer-rating'); 74$container.find('input').val(value); 75$container.find('.dashicons').removeClass('active'); 76$(this).addClass('active').prevAll().addClass('active'); 77}); 78$('.formlayer-rating .dashicons').on('mouseenter', function(){ 79$(this).addClass('hover').prevAll().addClass('hover'); 80$(this).nextAll().removeClass('hover'); 81}).on('mouseleave', '.formlayer-rating .dashicons', function(){ 82$('.formlayer-rating .dashicons').removeClass('hover'); 83}); 84$('.formlayer-file-real').on('change', function(e){ 85let input=this, 86$wrap=$(input).closest('.formlayer-field-wrap'), 87$chosenName=$wrap.find('.formlayer-file-chosen-name'); 88$wrap.find('.formlayer-file-preview-container').remove(); 89if(input.files&&input.files[0]){ 90let file=input.files[0]; 91$chosenName.text(file.name); 92let $previewContainer=$(` 93<div class="formlayer-file-preview-container" style="margin-top:10px; display:flex; align-items:center; gap:12px; padding:10px; border:1px dashed #ccc; border-radius:6px; background:#f9f9f9; max-width: 100%;"> 94<img class="formlayer-file-preview-img" src="" style="width:60px; height:60px; border-radius:4px; display:none; object-fit:cover; border:1px solid #ddd; background:#fff;"> 95<span class="formlayer-file-preview-icon dashicons dashicons-document" style="font-size:36px; width:36px; height:36px; display:none; color:#5525d6; line-height:36px;"></span> 96<div style="display:flex; flex-direction:column; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:left; margin-right: auto;"> 97<span class="formlayer-file-preview-name" style="font-size:13px; font-weight:600; color:#333; overflow:hidden; text-overflow:ellipsis; max-width: 200px;"></span> 98<span class="formlayer-file-preview-size" style="font-size:11px;
98 color:#777; margin-top: 2px;"></span> 99</div> 100<span class="formlayer-file-preview-remove dashicons dashicons-no-alt" style="cursor:pointer; color:#999; font-size:20px; width:20px; height:20px; line-height:20px; text-align:center; transition:color 0.2s;" onmouseover="this.style.color='#d9534f'" onmouseout="this.style.color='#999'"></span> 101</div> 102`); 103$previewContainer.find('.formlayer-file-preview-name').text(file.name); 104let sizeStr=(file.size / 1024).toFixed(1) + ' KB'; 105if(file.size > 1024 * 1024){ 106sizeStr=(file.size / (1024 * 1024)).toFixed(1) + ' MB'; 107} 108$previewContainer.find('.formlayer-file-preview-size').text(sizeStr); 109if(file.type.match('image.*')){ 110let reader=new FileReader(); 111reader.onload=function(e){ 112$previewContainer.find('.formlayer-file-preview-img').attr('src', e.target.result).show(); 113} 114reader.readAsDataURL(file); 115}else{ 116$previewContainer.find('.formlayer-file-preview-icon').show(); 117} 118$previewContainer.find('.formlayer-file-preview-remove').on('click', function(){ 119$(input).val(''); 120$chosenName.text('No file chosen'); 121$previewContainer.remove(); 122}); 123$wrap.append($previewContainer); 124}else{ 125$chosenName.text('No file chosen'); 126}}); 127});
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.