1var __cfg_cms_url = app_settings.cms_url; 2var __tapSafeSignup = false; 3 4__cfg_cms_url = "http://cms.appinstitute.com/cms/"; 5 6var __loadingMask = new ai.ui.Mask({ text: 'Creating Account' }); 7var __loadingMaskReseller = new ai.ui.Mask({ text: 'Submitting Enquiry' }); 8 9 10$(function () { 11 12 // Capture UTM params 13 14 // Example : https://appinstitute.com/restaurant-apps/?utm_campaign=petertest&utm_source=testsource&utm_medium=testmedium&utm_content=testcontent&utm_term=testterm 15 16 var url = new URL(window.location.href); 17 var utmParamNames = ['utm_campaign','utm_source','utm_medium','utm_content','utm_term']; 18 19 for (var i = 0; i < utmParamNames.length; i++) { 20 var utmParamName = utmParamNames[i]; 21 var utmParamValue = url.searchParams.get(utmParamName); 22 if (utmParamValue) { // Only set if the param has a value. 23 localStorage.setItem(utmParamName, utmParamValue); 24 } 25 } 26 27 28 $('#countrySelectorModal div').on('click',function(e){ 29 e.preventDefault(); 30 var user_currency = jQuery(this).attr('id'); 31 setCurrencyCodeSession( user_currency ); 32 $.ajax({ 33 url: myajax.url, 34 type: 'post', 35 dataType: 'text', 36 cache: false, 37 data: { 38 'action': 'currency_ajax_submit', 39 'user_currency': user_currency 40 }, 41 success: function(data) { 42 console.log(data); 43 }, 44 error: function(err){ 45 46 } 47 }) 48 }); 49 50 51 var signup_border_default = $("#signup-form input[name=email]").css('borderColor'); 52 var signup_border_error = 'red'; 53 54 /* --- Main Sign-up form --- */ 55 $('#signup-form #form-submit').off('click').on('click', function(event) { 56 57 ai_site_legacy_form_submitted({ form: 'signupf1' }); 58 59 event.preventDefault(); // Event is always handled by JS. 60 61 var el_email = $("#signup-form input[name=email]"); 62 var el_name = $("#signup-form input[name=fname]"); 63 var el_phone = $("#signup-form input[name=phone]"); 64 65 66 // Reset boarder styles. 67 el_email.css('borderColor', signup_border_default); 68 el_name.css('borderColor', signup_border_default); 69 el_phone.css('borderColor', signup_border_default); 70 71 72 // Validate inputs. 73 console.log('checking signup details'); // debug 74 if (isEmail(el_email.val())) { 75 console.log(isEmail(el_email.val())); // debug 76 if (el_name.val()) { 77 if (el_phone.val()) { 78 79 var $self = $(this), noredirect = false; 80 event.preventDefault(); 81 try{ 82 __loadingMask.show(); 83 }catch(e){} 84 85 __tapSafeSignup = true; 86 $.ajax({
87 method: "POST", 88 url: "/ajax-scripts/thanks-ajax.php", 89 data: { 90 email : el_email.val(), 91 fname : el_name.val(), 92 phone : el_phone.val(), 93 form_location : $("#signup-form input[name=form_location]").val(), 94 template_ref: $("#signup-form input[name=template_ref]").val(), 95 signup_page: $("#signup-form input[name=signuppage]").val() 96 } 97 }) 98 .done(function( msg ) { 99 100 console.log(msg); // debug 101 102 var obj = jQuery.parseJSON( msg ); 103 if(obj.status == "success"){ 104 if( $self.parents('form').hasClass('contact-us-page') ) { 105 //Cancel the redirect and hiding form 106 noredirect = !noredirect; 107 $self.parents('form').find('input').hide(); 108 $self.parents('form').find('textarea').hide(); 109 } else { 110 $('#signup-form input').css('display', 'none'); 111 $('#signup-form textarea').css('display', 'none'); 112 } 113 $('.signup-form-notification').html('<p class="sub">Success! We will email you a temporary password and auto log you in to start building your app!</p>'); 114 115 // login to the CMS. Allow time for analytics to be sent. 116 var redirectTimeout = setTimeout(function() { 117 // Now redirect to CMS & login... 118 noredirect || post(__cfg_cms_url + 'login.php', obj); 119 }, 5000); 120 121 // Send analytics data to segment 122 analytics.alias(obj.username, function(){ 123 analytics.track('Site Signup', {Package: 'businessapp'}); 124 125 // Set signuptype attribute 126 analytics.identify( 127 user_id=obj.username, 128 traits={ 129 "signuptype": "businessapp", 130 "signuppage": $("#signup-form input[name=signuppage]").val() 131 }, 132 function() { 133 134 analytics.identify(obj.username, { 135 signuppage: $("#signup-form input[name=signuppage]").val() 136 }); 137 // Now redirect to CMS & login... 138 clearTimeout(redirectTimeout); // Cancel backup timeout 139 noredirect || post(__cfg_cms_url + 'login.php', obj); 140 } 141 ); 142 143 }); 144 145 146 } else { 147 148 var email = el_email.val(); 149 //$('#signup-form input').prop('disabled', 'false'); 150 $('#signup-form input[type=submit]').css('display', 'inline'); 151 $('.ajax-loader').css('visibility', 'hidden'); 152 $('#signup-form #form-submit').css('display','inline-block'); 153 $('.signup-form-notification').html('<p class="sub-error" style="color:red!important;">'+obj.message+'</p><div class="advice_message">Please <a href="'+__cfg_cms_url+'login.php">Login</a> or <a href="'+__cfg_cms_url+'login.php?action=forgotpassword&username='+email+'">Reset your password</a></div>'); 154 } 155 __tapSafeSignup = false; 156 157 try{ 158 __loadingMask.hide(); 159 }catch(e){} 160 }); 161 } else { 162 $('#signup-form #form-submit').css('display','inline-block'); 163 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">Please complete Your Tel No.</p>'); 164 el_phone.css('borderColor', signup_border_error); 165 } 166 } else { 167 $('#signup-form #form-submit').css('display','inline-block'); 168 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">Please complete Your Name.</p>'); 169 el_name.css('borderColor', signup_border_error); 170 } 171 } else { 172 $('#signup-form #form-submit').css('display','inline-block'); 173 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">Please enter a valid email address.</p>'); 174 el_email.css('borderColor', signup_border_error); 175 } 176 177 }); 178 179 180 181 182 183 $('#bottom-signup-form #bottom-form-submit').off('click').on('click', function(event) { 184 185 ai_site_legacy_form_submitted({ form: 'signupf2' }); 186 187 //alert('here2'); 188 var $self = $(this), noredirect = false; 189 try{ 190 __loadingMask.show(); 191 }catch(e){} 192 __tapSafeSignup = true; 193 $.ajax({ 194 method: "POST", 195 url: "/ajax-scripts/thanks-ajax.php", 196 data: { 197 email : $("#bottom-signup-form input[name=email]").val(), 198 fname : $("#bottom-signup-form input[name=fname]").val(), 199 phone : $("#bottom-signup-form input[name=phone]").val(), 200 form_location : $("#bottom-signup-form input[name=form_location]").val() 201 } 202 }) 203 .done(function( msg ) { 204//console.log(msg); 205 var obj = jQuery.parseJSON( msg ); 206 if(obj.status == "success"){ 207 if( $self.parents('form').hasClass('reseller-page') ) { 208 noredirect = !noredirect; 209 } 210 //Hide form inputs if no contact us || resellers page 211 $('#bottom-signup-form input').css('display','none'); 212 $('#bottom-signup-form textarea').css('display','none'); 213 214 215 $('.signup-form-notification').html('<p class="sub">Success! We will email you a temporary password and auto log you in to start building your app!</p>'); 216 217// login to the CMS. Allow time for analytics to be sent. 218 219 var redirectTimeout = setTimeout(function() { 220// Now redirect to CMS & login... 221 noredirect || post(__cfg_cms_url + 'login.php', obj); 222 }, 5000); 223 224 225 226// Send analytics data to segment 227 analytics.alias(obj.username, function(){ 228 analytics.track('Site Signup', {Package: 'businessapp'}); 229 230// Set signuptype attribute 231 analytics.identify( 232 user_id=obj.username, 233 traits={ 234 "signuptype": "businessapp" 235 }, 236 function() { 237// Now redirect to CMS & login... 238 clearTimeout(redirectTimeout); // Cancel backup timeout 239 noredirect || post(__cfg_cms_url + 'login.php', obj); 240 } 241 ); 242 243 });
244 245 246 } else { 247 248 var email = $("#bottom-signup-form input[name=email]").val(); 249//$('#signup-form input').prop('disabled', 'false'); 250 $('#bottom-signup-form input[type=submit]').css('display', 'inline'); 251 $('.ajax-loader').css('visibility', 'hidden'); 252 $('#bottom-signup-form #bottom-form-submit').css('display','inline-block'); 253 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">'+obj.message+'</p><div class="advice_message">Please <a href="'+__cfg_cms_url+'login.php">Login</a> or <a href="'+__cfg_cms_url+'login.php?action=forgotpassword&username='+email+'">Reset your password</a></div>'); 254 } 255 __tapSafeSignup = false; 256 257 try{ 258 __loadingMask.hide(); 259 }catch(e){} 260 }); 261 }); 262 263 $('#reseller-signup-form').submit(function () { 264 return false; 265 }); 266 267 $('#reseller-signup-form #form-submit').off('click').on('click', function(event) { 268 269 ai_site_legacy_form_submitted({ form: 'signupf3' }); 270 271 if (isEmail($("#reseller-signup-form input[name=email]").val())) { 272 if ($("#reseller-signup-form input[name=fname]").val()) { 273 if ($("#reseller-signup-form input[name=phone]").val()) { 274 var $self = $(this), noredirect = false; 275 try{ 276 __loadingMaskReseller.show(); 277 }catch(e){} 278 __tapSafeSignup = true; 279 280 var form_fname = $("#reseller-signup-form input[name=fname]").val(); 281 var form_email = $("#reseller-signup-form input[name=email]").val(); 282 283 var action_value = $("#reseller-signup-form input[name=action]").val(); 284 var action_type_value = $("#reseller-signup-form input[name=action_type]").val(); 285 var form_company = $("#reseller-signup-form input[name=company]").val(); 286 var form_signup_page = $("#reseller-signup-form input[name=signup_page]").val(); 287 var form_referrer = $("#reseller-signup-form input[name=referrer]").val(); 288 289 var form_calendly_id = $("#reseller-signup-form input[name=calendly_id]").val(); 290 291 292 var data = { 293 email : form_email, 294 fname : form_fname, 295 phone : $("#reseller-signup-form input[name=phone]").val(), 296 action : action_value, 297 form_location : $("#reseller-signup-form input[name=form_location]").val() 298 }; 299 if (action_type_value) { data.action_type = action_type_value; } 300 if (form_company) { data.company = form_company; } 301 302 $.ajax({
303 method: "POST", 304 url: "/ajax-scripts/thanks-ajax.php", 305 data: data 306 }) 307 .done(function( msg ) { 308 var obj = jQuery.parseJSON( msg ); 309 if(obj.status == "success"){ 310 if( $self.parents('form').hasClass('reseller-page') ) { 311 noredirect = !noredirect; 312 } 313 //Hide form inputs if no contact us || resellers page 314 $('#reseller-signup-form input').css('display','none'); 315 $('#reseller-signup-form textarea').css('display','none'); 316 317 var link_signup_param = (form_signup_page) ? "?signupPage=" + form_signup_page : "?signupPage=Resellers"; 318 319 $('.signup-form-notification').html("<h1 style='padding:0px; font-size: 26px'>Thanks, we'll be in touch soon!</h1><p style='font-size: 16px' 'class='sub'>While you wait for someone to get back to you, try our platform for free.</p><a href='http://appinstitute.com/signup/"+ link_signup_param +"'><button style='background:#fe8400; text-transform:initial; padding: 10px 30px; margin-top: 30px;'>Try Our App Builder for Free</button></a>"); 320 //$('.signup-form-notification').html("<h1>Thanks, we'll be in touch soon!</h1><p class='sub'>Success! We have received your request, we will contact you as soon as possible!</p>"); 321 // login to the CMS. Allow time for analytics to be sent. 322 323 // Send analytics data to segment 324 325 var action_value = $("#reseller-signup-form input[name=action]").val(); 326 327 analytics.alias(obj.username, function(){ 328 329 //analytics.track('Site Signup', {Package: 'whitelabel'}); 330 if (action_value == 'whitelabel') { 331 analytics.track('Reseller Enquiry'); 332 if (typeof(customerly) === 'object' && typeof(customerly.attribute) === 'function') { 333 customerly.attribute('name', data.fname); 334 customerly.attribute('email', data.email); 335 customerly.attribute('phone', data.phone); 336 customerly.event('reseller_enquiry'); 337 } 338 } 339 if (action_value == 'pro-build') { 340 analytics.track('Hire A Pro Enquiry'); 341 } 342 343 var traits = { 344 "signuptype": action_value 345 }; 346 347 if (form_referrer) { 348 traits['referrer'] = form_referrer; 349 } 350 351 // Set signuptype attribute 352 analytics.identify( 353 user_id=obj.username, 354 traits=traits 355 ); 356 }); 357 358 if (form_calendly_id) { 359 // Replace the completion message text 360 $('.signup-form-notification').empty().html("<h1 style='padding:0px; font-size: 26px'>Thanks, launching calendar...</h1>"); 361 362 // Open calendar 363 //var calendly_url = 'https://calendly.com/ai-resellers?name=test&[email protected]'; 364 if( !form_fname ) { form_fname = ''; } 365 if( !form_email ) { form_email = ''; } 366 var calendly_url = 'https://calendly.com/'+ form_calendly_id +'?name='+ form_fname +'&email='+ form_email; 367 setTimeout(function() { 368 window.location.href = calendly_url; 369 }, 350); 370 } 371 372 373 374 } else { 375 376 var email = $("#reseller-signup-form input[name=email]").val(); 377 //$('#signup-form input').prop('disabled', 'false'); 378 $('#reseller-signup-form input[type=submit]').css('display', 'inline'); 379 $('.ajax-loader').css('visibility', 'hidden'); 380 $('#reseller-signup-form #bottom-form-submit').css('display','inline-block'); 381 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">'+obj.message+'</p><div class="advice_message"></div>'); 382 383 } 384 __tapSafeSignup = false; 385 386 try{ 387 __loadingMaskReseller.hide(); 388 }catch(e){} 389 }); 390 } else { 391 $('#reseller-signup-form #form-submit').css('display','inline-block'); 392 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">Please complete Your Tel No.</p>') 393 } 394 } else { 395 $('#reseller-signup-form #form-submit').css('display','inline-block'); 396 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">Please complete Your Name.</p>') 397 } 398 } else { 399 $('#reseller-signup-form #form-submit').css('display','inline-block'); 400 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">Please enter a valid email address.</p>') 401 } 402 }); 403 $('#contact-signup-form #form-submit').off('click').on('click', function(event) { 404 405 ai_site_legacy_form_submitted({ form: 'signupf4' }); 406 407 if (isEmail($("#contact-signup-form input[name=email]").val())) { 408 console.log(isEmail($("#contact-signup-form input[name=email]").val())); 409 if ($("#contact-signup-form input[name=fname]").val()) { 410 if ($("#contact-signup-form input[name=phone]").val()) { 411 var $self = $(this), noredirect = false; 412 try{ 413 __loadingMaskReseller.show(); 414 }catch(e){} 415 __tapSafeSignup = true; 416 $.ajax({
417 method: "POST", 418 url: "/ajax-scripts/thanks-ajax.php", 419 data: { 420 email : $("#contact-signup-form input[name=email]").val(), 421 fname : $("#contact-signup-form input[name=fname]").val(), 422 phone : $("#contact-signup-form input[name=phone]").val(), 423 action : $("#contact-signup-form input[name=action]").val(), 424 tellus : $("#contact-signup-form textarea[name=tellus]").val(), 425 form_location : $("#contact-signup-form input[name=form_location]").val() 426 } 427 }) 428 .done(function( msg ) { 429 var obj = jQuery.parseJSON( msg ); 430 if(obj.status == "success"){ 431 if( $self.parents('form').hasClass('reseller-page') ) { 432 noredirect = !noredirect; 433 } 434 //Hide form inputs if no contact us || resellers page 435 $('#contact-signup-form input').css('display','none'); 436 $('#contact-signup-form textarea').css('display','none'); 437 $('.signup-form-notification').html('<p class="sub">Success! We have received your request, we will contact you as soon as possible!</p>'); 438 // login to the CMS. Allow time for analytics to be sent. 439 440 // Send analytics data to segment 441 analytics.alias(obj.username, function(){ 442 analytics.track('Site Signup', {Package: 'enquiry'}); 443 444 // Set signuptype attribute 445 analytics.identify( 446 user_id=obj.username, 447 traits={ 448 "signuptype": "enquiry" 449 } 450 ); 451 }); 452 453 454 } else { 455 456 var email = $("#contact-signup-form input[name=email]").val(); 457 //$('#signup-form input').prop('disabled', 'false'); 458 $('#contact-signup-form input[type=submit]').css('display', 'inline'); 459 $('.ajax-loader').css('visibility', 'hidden'); 460 $('#contact-signup-form #bottom-form-submit').css('display','inline-block'); 461 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">'+obj.message+'</p><div class="advice_message"></div>'); 462 } 463 __tapSafeSignup = false; 464 465 try{ 466 __loadingMaskReseller.hide(); 467 }catch(e){} 468 }); 469 } else { 470 $('#contact-signup-form #form-submit').css('display','inline-block'); 471 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">Please complete Your Tel No.</p>') 472 } 473 } else { 474 $('#contact-signup-form #form-submit').css('display','inline-block'); 475 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">Please complete Your Name.</p>') 476 } 477 } else { 478 $('#contact-signup-form #form-submit').css('display','inline-block'); 479 $('.signup-form-notification').html('<p class="sub-error" style="color:red;">Please enter a valid email address.</p>') 480 } 481 }); 482 483 // Form actions 484 var ai_site_form_submit_enquiry = function($form, form_data) { 485 486 //alert('signupf5'); 487 488 var url = "/ajax-scripts/ai-form-submit-enquiry.php"; 489 490 var error_generic = 'Could not complete your request at this time. Please try again later.'; 491 492 //console.log($form, form_data); 493 494 495 // Append page information 496 form_data.page_url = window.location.hostname + window.location.pathname; 497 498 if (typeof(window.__country) === 'object') { 499 form_data.countryCode = window.__country.code; 500 form_data.countryName = window.__country.name; 501 } 502 503 // Append UTM params 504 var utmParamNames = ['utm_campaign','utm_source','utm_medium','utm_content','utm_term']; 505 for (var i = 0; i < utmParamNames.length; i++) { 506 var utmParamName = utmParamNames[i]; 507 var utmParamValue = localStorage.getItem(utmParamName); 508 if (utmParamValue) { 509 form_data[utmParamName] = utmParamValue; 510 } 511 } 512 513 // Correct misnamed fname on the industry pages. 514 if (typeof(form_data.fname) !== 'undefined') { 515 form_data.name = form_data.fname; 516 delete form_data.fname; 517 } 518 519 // Allow the 'action' to be provided as 'ai_action' ('action' field can break visual composer) 520 if (typeof(form_data.ai_action) !== 'undefined') { 521 form_data.action = form_data.ai_action; 522 delete form_data.ai_action; 523 } 524 525 526 var data = { 527 form_data: form_data, 528 }; 529 530 531 __loadingMaskReseller.show(); 532 533 var ajaxRequest = $.ajax({
534 url: url, 535 method: "POST", 536 data: data 537 }) 538 .done(function( data ) { 539 // Response OK 540 __loadingMaskReseller.hide(); 541 542 if (typeof(data.success) == 'undefined' || !data.success) { // Error 543 var notice = error_generic; 544 if (data.message) { 545 notice = data.message; 546 } 547 $form.setNotice(notice); 548 return; 549 } 550 551 // Display success message 552 $form.setComplete(); 553 554 // Send analytics event 555 if (typeof(analytics) !== 'undefined') { 556 557 if (form_data.event) { 558 analytics.track(form_data.event); 559 } 560 561 if (form_data.action == 'enquiry_direct') { // we need to change this to detect the takeaway form specifically. 562 analytics.track('Enquiry Submitted - Industry Page'); 563 } 564 if (form_data.action == 'enquiry_reseller_program') { 565 analytics.track('Reseller Enquiry'); 566 } 567 568 } 569 570 // Apply customerly attributes/events 571 if (typeof(customerly) === 'object' && typeof(customerly.attribute) === 'function') { 572 if (form_data.name) { customerly.attribute('name', form_data.name); } 573 if (form_data.email) { customerly.attribute('email', form_data.email); } 574 if (form_data.phone) { customerly.attribute('phone', form_data.phone); } 575 576 if (form_data.chat_event) { 577 customerly.event(form_data.chat_event); 578 } 579 } 580 581 if (form_data.stripe_purchase) { 582 setTimeout(function() { // Timout to allow the above event triggers to complete. 583 var stripe = Stripe('pk_live_5A0AARTvyuiSox8plZ3CAHpb'); 584 585 // When the customer clicks on the button, redirect 586 // them to Checkout. 587 stripe.redirectToCheckout({ 588 customerEmail: form_data.email, 589 lineItems: [{price: form_data.stripe_purchase, quantity: 1}], // price_1HcU2LG6YAxwzi75wtV0EPf4 590 mode: 'subscription', 591 successUrl: 'https://appinstitute.com/online-ordering-system-app-success/', 592 cancelUrl: window.location.href, // Return back to this page. 593 billingAddressCollection: 'required', 594 }) 595 .then(function (result) { 596 if (result.error) { 597 // If `redirectToCheckout` fails due to a browser or network 598 // error, display the localized error message to your customer. 599 var displayError = document.getElementById('error-message'); 600 displayError.textContent = result.error.message; 601 } 602 }); 603 }, 800); 604 } 605 606 }) 607 .fail(function( jqXHR, textStatus ) { 608 __loadingMaskReseller.hide(); 609 $form.setNotice(error_generic); 610 }); 611 612 return ajaxRequest; 613 614 }; 615 var ai_site_form_validationErrors = function($form, form_data) { 616 617 form_data = $form.serializeObject(); 618 619 if (!form_data.required) { return false; } 620 621 var required = JSON.parse(form_data.required); // { 'name': 'Name', 'email': 'Email' ... } 622 if (!required) { return false; } 623 624 var validationErrors = []; 625 626 for (var key in required) { 627 var fieldName = required[key]; 628 629 if (typeof(form_data[key]) === 'undefined') { continue; } // ignore if field doesn't exist. 630 631 if (!form_data[key]) { 632 // Required field has falsey/empty value 633 validationErrors.push(fieldName + ' Required'); 634 } 635 636 } 637 638 if (validationErrors.length > 0) { 639 var validationText = validationErrors.join(', ') + '.'; 640 $form.setNotice(validationText); 641 return true; 642 } 643 644 }; 645 646 // General AI form 647 var ai_site_forms = $('.ai-site-form'); 648 649 var ai_site_form_submit = function($form) { 650 651 form_data = $form.serializeObject(); 652 653 if (ai_site_form_validationErrors($form, form_data)) { 654 return false; // Don't submit if there's validation errors. 655 } 656 657 return ai_site_form_submit_enquiry($form, form_data); 658 659 }; 660 661 662 for (var i = 0; i < ai_site_forms.length; i++) { 663 var $form = $(ai_site_forms[i]); 664 665 //$form.find('#form-submit').off('click').on('click', (function($form) { 666 $form.off('submit').on('submit', (function($form) { 667 return function(evt) { 668 evt.preventDefault(); 669 670 671 $form.setNotice = function(html, isWarning) { 672 var $notice = $form.find('.form-notification'); 673 if (!$notice) { return; } 674 675 $notice.html(html); 676 677 if (!isWarning) { 678 $notice.addClass('warning'); 679 } else { 680 $notice.removeClass('warning'); 681 } 682 }; 683 684 $form.setComplete = function() { 685 $form.find('.content-complete').show(); 686 $form.find('.content-form').hide(); 687 }; 688 689 $form.setNotice(''); // Clear message 690 691 ai_site_form_submit($form); 692 }; 693 })($form)); 694 } 695 696 697 698 // Logging for legacy forms. 699 var ai_site_legacy_form_submitted = function(data) { 700 var url = "/ajax-scripts/ai-form-legacy.php"; 701 $.ajax({
702 url: url, 703 method: "POST", 704 data: data 705 }); 706 }; 707 708 709}); 710 711 712 713 714// Set session currency code 715var setCurrencyCodeSession = function( code ) { 716 $.ajax({ 717 method: 'POST', 718 url: '/ajax-scripts/setCurrencyCodeSession.php', 719 data: { code: code }, 720 }); 721}; 722 723 724 725 726 727 728 729 730function post(path, params, method) { 731 method = method || "post"; // Set method to post by default if not specified. 732 733 // The rest of this code assumes you are not using a library. 734 // It can be made less wordy if you use one. 735 var form = document.createElement("form"); 736 form.setAttribute("method", method); 737 form.setAttribute("action", path); 738 739 for(var key in params) { 740 if(params.hasOwnProperty(key)) { 741 var hiddenField = document.createElement("input"); 742 hiddenField.setAttribute("type", "hidden"); 743 hiddenField.setAttribute("name", key); 744 hiddenField.setAttribute("value", params[key]); 745 form.appendChild(hiddenField); 746 } 747 } 748 document.body.appendChild(form); 749 form.submit(); 750} 751 752function isEmail(email) { 753 var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; 754 return regex.test(email); 755} 756 757 758 759 760 761 762(function($){ 763 $.fn.serializeObject = function(){ 764 765 var self = this, 766 json = {}, 767 push_counters = {}, 768 patterns = { 769 "validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/, 770 "key": /[a-zA-Z0-9_]+|(?=\[\])/g, 771 "push": /^$/, 772 "fixed": /^\d+$/, 773 "named": /^[a-zA-Z0-9_]+$/ 774 }; 775 776 777 this.build = function(base, key, value){ 778 base[key] = value; 779 return base; 780 }; 781 782 this.push_counter = function(key){ 783 if(push_counters[key] === undefined){ 784 push_counters[key] = 0; 785 } 786 return push_counters[key]++; 787 }; 788 789 $.each($(this).serializeArray(), function(){ 790 791 // skip invalid keys 792 if(!patterns.validate.test(this.name)){ 793 return; 794 } 795 796 var k, 797 keys = this.name.match(patterns.key), 798 merge = this.value, 799 reverse_key = this.name; 800 801 while((k = keys.pop()) !== undefined){ 802 803 // adjust reverse_key 804 reverse_key = reverse_key.replace(new RegExp("\\[" + k + "\\]$"), ''); 805 806 // push 807 if(k.match(patterns.push)){ 808 merge = self.build([], self.push_counter(reverse_key), merge); 809 } 810 811 // fixed 812 else if(k.match(patterns.fixed)){ 813 merge = self.build([], k, merge); 814 } 815 816 // named 817 else if(k.match(patterns.named)){ 818 merge = self.build({}, k, merge); 819 } 820 } 821 822 json = $.extend(true, json, merge); 823 }); 824 825 return json; 826 }; 827})(jQuery); 828 829
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.