1(function( $ ) { 2 'use strict'; 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note that this assume you're going to use jQuery, so it prepares 9 * the $ function reference to be used within the scope of this 10 * function. 11 * 12 * From here, you're able to define handlers for when the DOM is 13 * ready: 14 * 15 * $(function() { 16 * 17 * }); 18 * 19 * Or when the window is loaded: 20 * 21 * $( window ).load(function() { 22 * 23 * }); 24 * 25 * ...and so on. 26 * 27 * Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler 28 * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may 29 * be doing this, we should try to minimize doing that in our own work. 30 */ 31 32 $(document).ready(function(){ 33 /*Avada Theme work around, when it shows multiple forms on single ads.*/ 34 $('.fusion-tb-header .aol-single, .fusion-tb-footer .aol-single').children().not('div').remove(); 35 36 $('.datepicker').datepicker({ 37 yearRange: "-99:+50", 38 //dateFormat : aol_public.date_format, 39 changeMonth: true, 40 changeYear: true, 41 }); 42 43 /*Setting Textarea Charchter Counter*/ 44 $('textarea, input[type=text]').keyup(function() { 45 46 var characterCount = $(this).val().length, 47 current = $(this).parent().find('.current'), 48 maximum = $(this).parent().find('.maximum'), 49 theCount = $(this).parent().find('.the-count'); 50 51 current.text(characterCount); 52 53 }); 54 /*Ends Textarea Charchter Counter*/ 55 56 /*Submit Application Form*/ 57 $( ".aol_app_form" ).submit(function(){ 58 aolSubmitForm(event); 59 }); 60 61 //Separator Code 62 $('.aol_multistep').click(function(){ 63 $('fieldset').hide(); 64 var load = $(this).data('load'); 65 if( load == 'next' ) $(this).parent("fieldset").next("fieldset").show(); 66 else if( load == 'back' ) $(this).parent("fieldset").prev("fieldset").show(); else $(this).parent("fieldset").previous("fieldset").show(); 67 68 return false; 69 }); 70 71 /* Progress Bar*/ 72 /*End Progress Bar*/ 73 }) 74 75})( jQuery ); 76 77document.addEventListener('DOMContentLoaded', function () { 78 79 const form = document.querySelector('form.aol_app_form'); 80 81 // Only run if the form exists 82 if (!form) return; 83 84 const requiredFields = form.querySelectorAll('[required]'); 85 const progressBar = form.querySelector('#progress-bar'); 86 const progressText = form.querySelector('#progress-text'); 87 88 function aolupdateProgress() { 89 let filled = 0; 90 91 requiredFields.forEach(field => { 92 if (field.checkValidity()) filled++; 93 }); 94 95 const percent = Math.round((filled / requiredFields.length) * 100); 96 //alert(percent); 97 98 if (progressBar) progressBar.style.width = percent + '%'; 99 if (progressText) progressText.textContent = percent + '%'; 100 } 101 102 form.addEventListener('input', aolupdateProgress); 103 form.addEventListener('change', aolupdateProgress); 104 105 aolupdateProgress(); 106}); 107 108//End Progress Bar 109 110async function aolSubmitForm( event ) { 111 if(!aolEmpty(aol_public.consent_text)){ 112 if ( window.confirm(aol_public.consent_text) == false ) return; 113 } 114 event.preventDefault(); 115 116 //const submitButton = document.getElementById('aol_app_submit_button'); 117 const submitButton = document.querySelectorAll('.aol-form-button'); 118 const statusBar = document.getElementById('aol_form_status'); 119 const successAlert = document.getElementById('aol_success_alert'); 120 const aolForm = event.target; 121 122 submitButton.forEach( (button, index, array) => { 123 //button.setAttribute('disabled', 'disabled'); 124 button.disabled = true; 125 } ); 126 statusBar.classList.remove('alert', 'alert-danger'); //May be trying again after errors. 127 statusBar.classList.add('alert'); 128 statusBar.innerHTML = '<img src="'+aol_public.url+'/images/loading.gif" />'; 129 130 const formData = new FormData(document.getElementById("aol_app_form")); 131 //formData.append('note', 'hello_world'); 132 133 const response = await fetch(aol_public.rest_url+'/form', { 134 method: 'POST', 135 body: formData, 136 headers: { 137 'Accept': 'application/json', 138 'X-WP-Nonce': aol_public.nonce 139 } 140 }); 141 const data = await response.json(); 142 let message = !aolEmpty(data['message']) ? data['message'] : 'Something went wrong. Please try again or c
142ontact support.'; 143 144 if( response.status == 200 ){ 145 statusBar.innerHTML = ''; 146 successAlert.classList.add('alert', 'alert-info'); 147 successAlert.innerHTML = message; 148 if(data['hide_form'] == true){ 149 aolForm.classList.toggle('hideout'); 150 } //Show a sliding effect. 151 152 //Divert to thank you page. 153 if(data.divert == true){ 154 var page = response.divert; 155 window.location.href = stripslashes(page); 156 } 157 } else { 158 statusBar.classList.add('alert', 'alert-danger'); 159 statusBar.innerHTML = message; 160 } 161 submitButton.forEach( (button, index, array) => { 162 //button.removeAttribute('disabled', 'disabled'); 163 button.disabled = false; 164 }); 165} 166 167function stripslashes (str) { 168 return (str + '').replace(/\\(.?)/g, function (s, n1) { 169 switch (n1) { 170 case '\\': 171 return '\\'; 172 case '0': 173 return '\u0000'; 174 case '': 175 return ''; 176 default: 177 return n1; 178 } 179 }); 180 } 181 182function limitText(limitField, limitNum) { 183 if (limitField.value.length > limitNum) { 184 limitField.value = limitField.value.substring(0, limitNum); 185 } 186} 187 188function aolEmpty(e) { 189 switch (e) { 190 case "": 191 case 0: 192 case "0": 193 case null: 194 case false: 195 case undefined: 196 return true; 197 default: 198 return false; 199 } 200}
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.