1function phnNumberOld(oldPhn, oldCode){ 2 var customPhnNum = ''; 3 if(oldPhn != '' && oldCode != ''){ 4 customPhnNum = oldPhn.replace("+"+oldCode, ""); 5 } 6 return customPhnNum; 7} 8$(document).ready(function() { 9 var findPathName = location.pathname.split('/')[1]; 10 const allSites = { 11 'au' : 'australia', 12 'in' : 'india', 13 'pk' : 'pakistan', 14 'lk' : 'srilanka', 15 'ph' : 'philippines', 16 'ke' : 'kenya', 17 'kh' : 'cambodia', 18 'id' : 'indonesia', 19 }; 20 const isValuePresent = Object.keys(allSites).some(key => allSites[key] === findPathName); 21 const ccode = Object.keys(allSites).find(key => allSites[key] === findPathName); 22 23 $.validator.addMethod("alphanumericWithSpace", function(value, element) { 24 // Regular expression pattern for alphanumeric characters and spaces 25 // Explanation: 26 // ^ - Start of string 27 // [a-zA-Z0-9 ]+ - Match one or more alphanumeric characters or spaces 28 // $ - End of string 29 return this.optional(element) || /^[a-zA-Z0-9 ]+$/.test(value); 30 }, "Please enter only letters, numbers, or spaces."); 31 32 33 $(".error").css('color', 'red'); 34 $.get("https://ipinfo.io/", function() {}, "jsonp").always(function(resp) { 35 var countryCode = (resp && resp.country) ? resp.country : ""; 36 var city = (resp && resp.city) ? resp.city : ""; 37 var region = (resp && resp.region) ? resp.region : ""; 38 var postal = (resp && resp.postal) ? resp.postal : ""; 39 var ip = (resp && resp.ip) ? resp.ip : ""; 40 $('input[name="location"]').val(city); 41 $('input[name="region"]').val(region); 42 $('input[name="postal"]').val(postal); 43 $('input[name="ip"]').val(ip); 44 }); 45 46 47 $.validator.addMethod("checkAlphabet", function(value, element) { 48 return this.optional( element ) || /^[a-zA-Z\s]+$/.test( value ); 49 }, 'Please use only letters.'); 50 $.validator.addMethod("checkEmail", function(value, element){ 51 return this.optional( element ) || /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test( value ); 52 }, 'Please enter valid email address.'); 53 54 if($("#dynamicFrom").length > 0){ 55 $("#dynamicFrom #mobile").on("input", function() { 56 if (/^0/.test(this.value)) { 57 this.value = this.value.replace(/^0/, "") 58 } 59 }); 60 $("#dynamicFrom").validate({ 61 rules: { 62 name: { 63 required: true, 64 checkAlphabet: true, 65 maxlength: 30, 66 alphanumericWithSpace: true, 67 }, 68 email: { 69 required: true, 70 checkEmail: true 71 }, 72 phone:{ 73 required: true, 74 }, 75 mobile:{ 76 required: true, 77 digits: true, 78 minlength: 8, 79 maxlength: 12 80 }, 81 nationality:{ 82 required: true, 83 }, 84 message:{ 85 alphanumericWithSpace: true, 86 }, 87 }, 88 errorPlacement: function(error, element) { 89 if(element.is('select')){ 90 element.next('button').addClass('error'); 91 } 92 93 if(element.is('textarea')){ 94 element.next('button').addClass('error'); 95 } 96 } 97 }); 98 $('#dynamicFrom select').change(function(){ 99 $(this).next('button').removeClass('error'); 100 }); 101 102 $('#submit_page_enq').click(function(){
103 var validOrNot = $('#dynamicFrom').valid(); 104 if(validOrNot){ 105 $(this).attr('disabled', true); 106 $('#dynamicFrom').submit(); 107 } 108 }); 109 } 110 111 if($('.dob_datepicker').length > 0){ 112 $('.dob_datepicker').attr('readonly', true); 113 $('.dob_datepicker').datepicker({ 114 changeMonth: true, 115 changeYear: true, 116 dateFormat: "dd-M-yy", 117 yearRange: "-90:+00", 118 maxDate: 0 119 }); 120 } 121 122 if($('#dynamicSideForm').length > 0){ 123 $("#dynamicSideForm #mobile").on("input", function() { 124 if (/^0/.test(this.value)) { 125 this.value = this.value.replace(/^0/, "") 126 } 127 }); 128 $("#dynamicSideForm").validate({ 129 rules: { 130 name: { 131 required: true, 132 checkAlphabet: true, 133 maxlength: 30, 134 alphanumericWithSpace: true, 135 }, 136 email: { 137 required: true, 138 checkEmail: true 139 }, 140 phone:{ 141 required: true, 142 }, 143 mobile:{ 144 required: true, 145 digits: true, 146 minlength: 8, 147 maxlength: 12 148 }, 149 message:{ 150 alphanumericWithSpace: true, 151 }, 152 153 nationality:{ 154 required: true, 155 156 }, 157 }, 158 errorPlacement: function(error, element) { 159 if(element.is('select')){ 160 element.next('button').addClass('error'); 161 } 162 if(element.is('textarea')){ 163 element.next('button').addClass('error'); 164 } 165 } 166 }); 167 168 $('#dynamicSideForm select').change(function(){ 169 $(this).next('button').removeClass('error'); 170 }); 171 172 $('#submit_sideBar_enq').click(function(){ 173 var validOrNot = $('#dynamicSideForm').valid(); 174 if(validOrNot){ 175 $(this).attr('disabled', true); 176 $('#dynamicSideForm').submit(); 177 } 178 }); 179 180 if($("form#dynamicSideForm").offset().top > 500 && $('#load_limit').length > 0){ 181 $('html, body').animate({ 182 scrollTop: $("form#dynamicSideForm").offset().top - 300 183 }, 2000); 184 } 185 } 186 187 $("#phone_code").val('61'); 188 if($("#mobile").length > 0){ 189 var mobile_flag = $("#mobile").attr('mobile_flag'); 190 var input = document.querySelector("#mobile"); 191 192 if(mobile_flag != 'undefined' && mobile_flag != ''){ 193 var input = document.querySelector("#mobile"); 194 const selectIntInput = window.intlTelInput(input, { 195 formatAsYouType: false, 196 formatOnDisplay: false, 197 onlyCountries: [mobile_flag], 198 utilsScript: window.location.origin+"/wp-content/plugins/apg-enquiry/public/flag/build/js/utils.js", 199 countrySearch: false 200 }); 201 var selectedDialCode = selectIntInput.getSelectedCountryData().dialCode; 202 $("#phone_code").val(selectedDialCode); 203 }else{ 204 if(isValuePresent){ 205 var initCountry = ccode; 206 }else{ 207 var initCountry = 'au'; 208 } 209 const selectIntInput = window.intlTelInput(input, { 210 formatAsYouType: false, 211 formatOnDisplay: false, 212 initialCountry: initCountry, 213 utilsScript: window.location.origin+"/wp-content/plugins/apg-enquiry/public/flag/build/js/utils.js" 214 }); 215 var selectedDialCode = selectIntInput.getSelectedCountryData().dialCode; 216 $("#phone_code").val(selectedDialCode); 217 } 218 if($('#mobile').length > 0 && $('#phone_code')){ 219 var oldPhn = $('#mobile').val(); 220 var oldCode = $('#phone_code').val(); 221 var genratePhn = phnNumberOld(oldPhn, oldCode); 222 if(genratePhn != ''){ 223 $('#mobile').val(genratePhn);
224 } 225 } 226 } 227 228 $("#phone_code").attr("autocomplete", "off"); 229 230 if($("#dynamicSidePopUpForm").length > 0){ 231 $("#dynamicSidePopUpForm #mobile").on("input", function() { 232 if (/^0/.test(this.value)) { 233 this.value = this.value.replace(/^0/, "") 234 } 235 }); 236 $("#dynamicSidePopUpForm").validate({ 237 rules: { 238 name: { 239 required: true, 240 checkAlphabet: true, 241 maxlength: 30, 242 alphanumericWithSpace: true, 243 }, 244 email: { 245 required: true, 246 checkEmail: true 247 }, 248 mobile:{ 249 required: true, 250 digits: true, 251 minlength: 8, 252 maxlength: 12 253 }, 254 nationality:{ 255 required: true, 256 }, 257 }, 258 errorPlacement: function(error, element) { 259 if(element.is('select')){ 260 element.next('button').addClass('error'); 261 } 262 263 if(element.is('textarea')){ 264 element.next('button').addClass('error'); 265 } 266 } 267 }); 268 $('#dynamicSidePopUpForm select').change(function(){ 269 $(this).next('button').removeClass('error'); 270 }); 271 272 $('#submit_sideBar_enqPopUp').click(function(){ 273 var validOrNot = $('#dynamicSidePopUpForm').valid(); 274 if(validOrNot){ 275 $(this).attr('disabled', true); 276 $('#dynamicSidePopUpForm').submit(); 277 } 278 }); 279 280 if($("#dynamicSidePopUpForm #mobile").length > 0){ 281 var mobile_flag = $("#dynamicSidePopUpForm #mobile").attr('mobile_flag'); 282 var mob_input = document.querySelector("#dynamicSidePopUpForm #mobile"); 283 284 if(mobile_flag != 'undefined' && mobile_flag != ''){ 285 const selectIntInput = window.intlTelInput(mob_input, { 286 formatAsYouType: false, 287 formatOnDisplay: false, 288 onlyCountries: [mobile_flag], 289 utilsScript: window.location.origin+"/wp-content/plugins/apg-enquiry/public/flag/build/js/utils.js", 290 countrySearch: false 291 }); 292 var selectedDialCode = selectIntInput.getSelectedCountryData().dialCode; 293 $("#dynamicSidePopUpForm #phone_code").val(selectedDialCode); 294 }else{ 295 if(isValuePresent){ 296 var initCountry = ccode; 297 }else{ 298 var initCountry = 'au'; 299 } 300 const selectIntInput = window.intlTelInput(mob_input, { 301 formatAsYouType: false, 302 formatOnDisplay: false, 303 initialCountry: initCountry, 304 utilsScript: window.location.origin+"/wp-content/plugins/apg-enquiry/public/flag/build/js/utils.js" 305 }); 306 var selectedDialCode = selectIntInput.getSelectedCountryData().dialCode; 307 $("#dynamicSidePopUpForm #phone_code").val(selectedDialCode); 308 } 309 310 if($('#dynamicSidePopUpForm #mobile').length > 0 && $('#dynamicSidePopUpForm #phone_code')){ 311 var oldPhn = $('#dynamicSidePopUpForm #mobile').val(); 312 var oldCode = $('#dynamicSidePopUpForm #phone_code').val(); 313 var genratePhn = phnNumberOld(oldPhn, oldCode); 314 if(genratePhn != ''){ 315 $('#dynamicSidePopUpForm #mobile').val(genratePhn); 316 } 317 } 318 } 319 $("#dynamicSidePopUpForm #phone_code").attr("autocomplete", "off"); 320 } 321});
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.