// $("#telNumber").intlTelInput({separateDialCode: true}); // var passIsChecked = false; // $.get("https://ipinfo.io", function() {}, "jsonp").always(function(resp) { // var countryCode = (resp && resp.country) ? resp.country : ""; // $("#telNumber").intlTelInput("setCountry", countryCode); // }); // $.urlParam = function (name) { // var results = new RegExp('[\?&]' + name).exec(window.location.href); // if (results == null) { // return null; // } else { // // return results[1] || 0; // return decodeURI(results[1]) || 0; // NOTE: handle specialChars // } // } // var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); // console.log('Source = '+ source); // var submitBtn = document.getElementById("submitBtn"); // var verifyBtn = document.getElementById("verifyBtn"); // document.getElementById("companyName").onchange = removeError; // document.getElementById("telNumber").onchange = removeError; // // document.getElementById("companyEmail").onchange = removeError; // // document.getElementById("postcode").onchange = removeError; // document.getElementById("dialCode").onchange = removeError; // document.getElementById("authyCode").onchange = removeError; // document.getElementById("username").onchange = removeError; // // document.getElementById("fullName").onchange = removeError; // document.getElementById("firstName").onchange = removeError; // document.getElementById("lastName").onchange = removeError; // document.getElementById("email").onchange = removeError; // document.getElementById("password").onchange = removeError; // document.getElementById("passwordConfirm").onchange = removeError; // validate(); // setInterval(function () { // removeError(); // submitBtn.reportValidity(); // }, 3000); // function passChecked(){ // passIsChecked = !passIsChecked; // var pass = document.getElementById("passCheckBox"); // if(passIsChecked){ // pass.style.setProperty('background-image',"url('Images/icons/tick-blue.svg')"); // } else { // pass.style.setProperty('background-image',""); // } // document.getElementById('password').type = passIsChecked ? 'text' : 'password'; // document.getElementById('passwordConfirm').type = passIsChecked ? 'text' : 'password' // } // function removeError() { // document.getElementById("companyName").setCustomValidity(""); // document.getElementById("telNumber").setCustomValidity(""); // // document.getElementById("companyEmail").setCustomValidity(""); // // document.getElementById("postcode").setCustomValidity(""); // document.getElementById("dialCode").setCustomValidity(""); // document.getElementById("authyCode").setCustomValidity(""); // document.getElementById("username").setCustomValidity(""); // // document.getElementById("fullName").setCustomValidity(""); // document.getElementById("firstName").setCustomValidity(""); // document.getElementById("lastName").setCustomValidity(""); // document.getElementById("email").setCustomValidity(""); // document.getElementById("password").setCustomValidity(""); // document.getElementById("passwordConfirm").setCustomValidity(""); // submitBtn.setCustomValidity(""); // submitBtn.reportValidity(); // } // $('#signUpUser').on('keyup keypress', function(e) { // var keyCode = e.keyCode || e.which; // if (keyCode === 13) { // e.preventDefault(); // return false; // } // }); // function validate() { // var mode = '';; // if (mode == 'error') // { // submitBtn.setCustomValidity("Failed to create account. Does the user already exist?"); // submitBtn.reportValidity(); // } else if (mode == 'UserExists') // { // submitBtn.setCustomValidity("A user with this Email or Username already exists"); // submitBtn.reportValidity(); // } else if (mode == 'CustomerExists') // { // submitBtn.setCustomValidity("A company with this Email or Name already exists"); // submitBtn.reportValidity(); // } else { // submitBtn.setCustomValidity(""); // } // } // var password = document.getElementById("password") // , passwordConfirm = document.getElementById("passwordConfirm"); // function validatePassword() { // if (password.value != passwordConfirm.value) { // passwordConfirm.setCustomValidity("Passwords Don't Match"); // passwordConfirm.reportValidity(); // } else { // passwordConfirm.setCustomValidity(''); // passwordConfirm.reportValidity(); // } // } // function closeH5_loading(){ // H5_loading.hide(); // } // function create() { // var $myForm = $('#signUpUser') // if (password.value != passwordConfirm.value) { // passwordConfirm.setCustomValidity("Passwords Don't Match"); // passwordConfirm.reportValidity(); // } // else if (!$myForm[0].checkValidity()) { // $myForm.find(':submit').click() // }else{ // H5_loading.show(); // setTimeout(closeH5_loading, 4000); // $.ajax({ // url:"/portal/Functions/communitySignUp.php", //the page containing php script // type: "post", //request type, // data: {companyName: document.getElementById("companyName").value, telNumber: document.getElementById("telNumber").value, dialCode:document.getElementById("dialCode").value, authyCode: document.getElementById("authyCode").value, // firstName:document.getElementById("firstName").value, lastName: document.getElementById("lastName").value, email: document.getElementById("email").value, // username: document.getElementById("username").value, password: document.getElementById("password").value, source: source}, // success:function(result){ // H5_loading.hide(); // if (result == "user") { // location.href = "../portal/CommunitySignUp.php?mode=UserExists"; // } else if (result == "customer") { // location.href = "../portal/CommunitySignUp.php?mode=CustomerExists"; // } else if (result == "token") { // alert("Token does not exist"); // } else { // if (isMobile) { // swal({ // html: '
Please navigate to quicklink.network on a computer and log-in
', // type: "error", // background: "#2D2C2C", // allowEscapeKey: true, // showConfirmButton: false, // allowOutsideClick: false // }); // } // else { // $.ajax({ // type: "POST", // url: "../portal/Functions/login.php", // data: {username: document.getElementById("username").value, password: document.getElementById("password").value}, // success: function() { // location.href = "../portal/Index.php"; // } // }); // } // } // } // }); // } // } // var verifyMethod = 'sms'; // var verifyPhone = ''; // var verifyEmail = ''; // var phoneVerified = false; // var phoneVerifiedNum = ''; // var telAjaxProcess = null; // $(document).on('keyup', '#telNumber', function() { // var code = $("#telNumber").intlTelInput("getSelectedCountryData"); // var telNum = $(this).val(); // if (telAjaxProcess) { // telAjaxProcess.abort(); // } // telAjaxProcess = $.ajax({ // url:"/portal/Functions/checkPhoneNumber.php", // type: "post", // data: {telNum: '+' + code.dialCode + telNum}, // success:function(result){ // telAjaxProcess = null; // if (result != 'fail') { // phoneVerified = true; // phoneVerifiedNum = result; // } // else { // phoneVerified = false; // phoneVerifiedNum = ''; // } // } // }); // }); // $(document).on('change', '#swal-select-method', function() { // var element = $(this); // verifyMethod = element.val(); // }); // var authyID; // $(document).on('click', '#registerButton', function() { // var $myForm = $('#signUpUser') // if (!$myForm[0].checkValidity()) { // // If the form is invalid, submit it. The form won't actually submit; // // this will just cause the browser to display the native HTML5 error messages. // $('#submitBtn').removeAttr('disabled') // $myForm.find(':submit').click() // $('#submitBtn').attr('disabled', 'disabled'); // return; // } // if (!phoneVerified) { // $('#telNumberError').html('Number does not exist or not cellular'); // $('#telNumberError').css('display', ''); // return; // } // if ($('#password').val() != $('#passwordConfirm').val()) { // $('#passwordError').html('Password does not match'); // $('#passwordError').css('display', ''); // return; // } // $('.errorMsg').css('display', 'none'); // $('.errorMsg').html(''); // var email = document.getElementById("email"); // var tel = document.getElementById("telNumber"); // var companyName = document.getElementById("companyName"); // var userName = document.getElementById("username"); // var code = $("#telNumber").intlTelInput("getSelectedCountryData"); // $.post("Functions/checkExistCustomer.php", {email: email.value, companyName: companyName.value, username: userName.value}, function (result) { // authyID = result; // document.getElementById("dialCode").value = code.dialCode; // document.getElementById("authyCode").value = authyID; // if (authyID === "User Exists") { // $('#usernameError').html('Username is taken') // $('#usernameError').css('display', ''); // } // else if (authyID === "Customer Exists") { // $('#companyNameError').html('Companyname is taken'); // $('#companyNameError').css('display', ''); // } // else if (authyID === "Email Exists") { // $('#emailError').html('Email is taken'); // $('#emailError').css('display', ''); // } // else { // verifyMethod = 'sms'; // openVerificationMethodBox(); // } // }); // }); // function openVerificationMethodBox() { // var email = document.getElementById("email"); // swal({ // animation: "slide-from-top", // title: '
Verfication
', // html: '
Please select which method you would like to receive your verfication code.
' + // '', // confirmButtonClass: "swalConfirmButton", // confirmButtonColor: "#3fa7e0", // confirmButtonText: "Send Code", // background: "#2D2C2C", // allowEscapeKey: true, // allowOutsideClick: false, // }).then(function() { // $.ajax({ // url: "Functions/requestVerify.php", // type: "POST", // data: {method: verifyMethod, email: email.value, phoneNumber: phoneVerifiedNum}, // dataType: "text", // success: function(result) { // swal({ // title: '
Verification
', // html: '
Please enter your verification code This has been sent to: ' + (verifyMethod == 'sms' ? phoneVerifiedNum : email.value) + '
' + // '' + // '' + // '' + // '
Re-send code   or   change verfication method
', // // input:"text", // showCancelButton: false, // showCloseButton: false, // showConfirmButton: false, // animation: "slide-from-top", // // inputPlaceholder: "Authentication code..", // confirmButtonClass: "swalConfirmButton", // confirmButtonColor: "#3fa7e0", // confirmButtonText: "Sign Up", // allowEscapeKey: true, // allowOutsideClick: false, // // inputClass:"swalInput", // background: "#2D2C2C", // preConfirm: function(inputValue) { // var value = $('#verifyAuthCode').val(); // return new Promise(function (resolve, reject) { // if (value === false) { // reject('You need to write something!'); // } else if (value === "") { // reject('You need to write something!'); // } else if (value.length < 7) // { // reject('The verification number should be 7 digits!'); // } else if (isNaN(value)) { // reject('You need to enter the verification number!'); // } else { // resolve(); // } // }) // } // }).then(function (value) { // }); // } // }); // }); // } // $(document).on('click', '#changeVerifyMethodSpan', function() { // verifyMethod = 'sms'; // openVerificationMethodBox(); // }); // $(document).on('click', '#resendCode', function() { // var email = document.getElementById("email"); // $.ajax({ // url: "Functions/requestVerify.php", // type: "POST", // data: {method: verifyMethod, email: email.value, phoneNumber: phoneVerifiedNum}, // dataType: "text", // beforeSend: function() { // H5_loading.show(); // }, // success: function(result) { // H5_loading.hide(); // } // }); // }); // $(document).on('click', '#verifyAuthBtn', function() { // var email = document.getElementById("email"); // var tel = document.getElementById("telNumber"); // var companyName = document.getElementById("companyName"); // var userName = document.getElementById("username"); // var code = $("#telNumber").intlTelInput("getSelectedCountryData"); // $.post("Functions/verify.php", {user: authyID, method: verifyMethod, telNumber: phoneVerifiedNum, email: email.value, tel: tel.value, dialCode: code.dialCode, code: $('#verifyAuthCode').val(), username:document.getElementById("username").value}, function (result) { // if (result) // { // create(); // } else { // $('#verifyAuthError').css('display', ''); // } // }); // }); // function verifyCode() { // var $myForm = $('#signUpUser') // if (!$myForm[0].checkValidity()) { // // If the form is invalid, submit it. The form won't actually submit; // // this will just cause the browser to display the native HTML5 error messages. // $('#submitBtn').removeAttr('disabled') // $myForm.find(':submit').click() // $('#submitBtn').attr('disabled', 'disabled'); // } else { // //$('#verifyBtn').attr('disabled', 'disabled'); // var email = document.getElementById("email"); // var tel = document.getElementById("telNumber"); // var companyName = document.getElementById("companyName"); // var userName = document.getElementById("username"); // var code = $("#telNumber").intlTelInput("getSelectedCountryData"); // var userID; // $.post("Functions/register.php", {email: email.value, tel: tel.value, code: code.dialCode, companyName: companyName.value, username: userName.value}, function (result) { // //alert(result); // userID = result; // //alert(userID); // if (userID === "User Exists") // { // //swal("This User already exists"); // $('#verifyBtn').removeAttr('disabled'); // document.getElementById("username").setCustomValidity("A user with this Email or Username already exists"); // document.getElementById("username").reportValidity(); // } else if (userID === "Customer Exists") // { // //swal("This Customer already exists"); // $('#verifyBtn').removeAttr('disabled'); // document.getElementById("companyName").setCustomValidity("A Company with this Email or Username already exists"); // document.getElementById("companyName").reportValidity(); // } else // { // document.getElementById("dialCode").value = code.dialCode; // document.getElementById("authyCode").value = userID; // swal({ // title: '
Verification
', // html: '
Please enter your verification code. This will be sent as an SMS to the telephone entered.
', // input:"text", // showCancelButton: false, // showCloseButton: true, // animation: "slide-from-top", // inputPlaceholder: "Authentication code..", // confirmButtonClass: "swalConfirmButton", // confirmButtonColor: "#3fa7e0", // confirmButtonText:"Sign Up", // inputClass:"swalInput", // allowOutsideClick: false, // allowEscapeKey: true, // background: "#2D2C2C", // preConfirm: function(inputValue) { // return new Promise(function (resolve, reject) { // if (inputValue === false) { // $('#verifyBtn').removeAttr('disabled'); // reject('You need to write something!'); // } else if (inputValue === "") { // $('#verifyBtn').removeAttr('disabled'); // reject('You need to write something!'); // } else if (inputValue.length < 7) // { // reject('The verification number should be 7 digits!'); // }else if (isNaN(inputValue)) { // $('#verifyBtn').removeAttr('disabled'); // reject('You need to enter the verification number!'); // } else { // resolve(); // } // }) // } // }).then(function(inputValue){ // $.post("Functions/verify.php", {user: userID, method: 'sms', email: email.value, tel: tel.value, dialCode: code.dialCode, code: inputValue, username:document.getElementById("username").value}, function (result) { // if (result) // { // swal({ // title: '
Verified
', // type: 'success', // showCancelButton:false, // cancelButtonClass: "swalConfirmButton", // cancelButtonColor: "#3fa7e0", // confirmButtonClass: "swalConfirmButton", // confirmButtonColor: "#3fa7e0", // confirmButtonText: "OK", // background: "#2D2C2C", // allowOutsideClick: false, // allowEscapeKey: true, // html: '
Your code has been verified.
', // }).then(function(result){ // if (result) // { // //$('#verifyBtn').attr('disabled', 'disabled'); // //$('#sub').removeAttr('disabled'); // create(); // } else { // $('#verifyBtn').removeAttr('disabled'); // } // }) .catch(swal.noop) // } else { // swal({ // title: '
Not verified
', // html: '
Your verification code was incorrect.
', // type: "error", // confirmButtonClass: "swalConfirmButton", // confirmButtonColor: "#3fa7e0", // background: "#2D2C2C", // allowOutsideClick: false, // allowEscapeKey: true, // }, // function(){ // }); // } // }); // /* // $.post("Functions/verify.php", {user: userID, code: inputValue, username:document.getElementById("username").value}, function (result) { // if (result) // { // swal("Verified", "Your code has been verified", "success"); // $('#verifyBtn').attr('disabled', 'disabled'); // $('#sub').removeAttr('disabled'); // } else { // $('#verifyBtn').removeAttr('disabled'); // swal("Not verified", "Your verification code was incorrect", "error"); // } // });*/ // }); // } // }); // } // } // (function () { // $('form > div > input').keyup(function () { // var empty = false; // $('form > div > input').each(function () { // if ($(this).val() == '') { // empty = true; // } // }); // if (empty) { // // $('#submitBtn').attr('disabled', 'disabled'); // updated according to http://stackoverflow.com/questions/7637790/how-to-remove-disabled-attribute-with-jquery-ie // $('#verifyBtn').attr('disabled', 'disabled'); // } else { // //R $('#submitBtn').removeAttr('disabled'); // updated according to http://stackoverflow.com/questions/7637790/how-to-remove-disabled-attribute-with-jquery-ie // $('#verifyBtn').removeAttr('disabled'); // } // }); // })() // password.onchange = validatePassword; // passwordConfirm.onkeyup = validatePassword; //