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 aolForm = event.target; 120 121 submitButton.forEach( (button, index, array) => { 122 //button.setAttribute('disabled', 'disabled'); 123 button.disabled = true; 124 } ); 125 statusBar.classList.remove('alert-danger'); //May be trying again after errors. 126 statusBar.classList.add('alert'); 127 statusBar.classList.add('alert-warning'); 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.classList.remove('alert-warning'); 146 statusBar.classList.add('alert-info'); 147 statusBar.innerHTML = message; 148 if(data['hide_form'] == true){ 149 aolForm.classList.toggle('hideout'); 150 } //Show a sliding effecnt. 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.remove('alert-warning'); 159 statusBar.classList.add('alert-danger'); 160 statusBar.innerHTML = message; 161 } 162 submitButton.forEach( (button, index, array) => { 163 //button.removeAttribute('disabled', 'disabled'); 164 button.disabled = false; 165 }); 166} 167 168function stripslashes (str) { 169 return (str + '').replace(/\\(.?)/g, function (s, n1) { 170 switch (n1) { 171 case '\\': 172 return '\\'; 173 case '0': 174 return '\u0000'; 175 case '': 176 return ''; 177 default: 178 return n1; 179 } 180 }); 181 } 182 183function limitText(limitField, limitNum) { 184 if (limitField.value.length > limitNum) { 185 limitField.value = limitField.value.substring(0, limitNum); 186 } 187} 188 189function aolEmpty(e) { 190 switch (e) { 191 case "": 192 case 0: 193 case "0": 194 case null: 195 case false: 196 case undefined: 197 return true; 198 default: 199 return false; 200 } 201}
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.