"; setTimeout(() => { this.$refs.responseforgot.innerHTML = ""; }, 4000) } else { setTimeout(() => { this.$refs.forgotsubmit.innerHTML = "Resend"; this.$refs.forgotsubmitbutton.disabled = false; }, 2000); this.$refs.responseforgot.innerHTML = "
" + data.message + "
"; setTimeout(() => { this.$refs.responseforgot.innerHTML = ""; }, 4000) } }); } }, loginform() { this.$refs.loginsubmit.innerHTML = "Please wait..."; this.$refs.loginsubmitbutton.disabled = true; this.inputElements = [...document.getElementById('ajaxlogin-login-formpdp-wishlist').querySelectorAll("[data-rules]")]; this.inputElements.map((input) => { if (Iodine.is(input.value, JSON.parse(input.dataset.rules)) !== true) { this.$refs.loginsubmit.innerHTML = "Login"; this.$refs.loginsubmitbutton.disabled = false; const error = Iodine.is(input.value, JSON.parse(input.dataset.rules)); event.preventDefault(); input.classList.add("invalid"); Iodine.messages.required = "This is a required field."; Iodine.messages.email = "Please enter a valid email address (Ex: johndoe@domain.com)."; this[input.name].errorMessage = Iodine.getErrorMessage(error); } else { input.classList.remove("invalid"); this[input.name].errorMessage = ""; } }); if (document.getElementById('ajaxlogin-login-formpdp-wishlist').querySelectorAll(".invalid").length == 0) { const formdata = { "form_key": document.getElementById("ajaxlogin-create-form").elements["form_key"].value, "username": this.$refs.loginusername.value, "password": this.$refs.loginpassword.value }; // Get the current URL const currentURL = window.location.href; fetch('https://www.slideteam.net/free/ajax/login/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest' }, body: JSON.stringify(formdata) }) .then(response => { return response.json() }).then(data => { console.log(data); if (data.errors) { document.querySelector('.response-msg').style.display = 'block'; this.$refs.registerresponse.innerHTML = "
" + data.message + "
"; } else { this.$refs.registerresponse.innerHTML = "
" + data.message + "
"; } setTimeout(function() { document.querySelector('.response-msg').style.display = 'none'; }, 5000); if (data.errors) { this.$refs.loginsubmit.innerHTML = "Login"; this.$refs.loginsubmitbutton.disabled = false; } else { var productId = document.querySelector(".currentProduct").value; if (productId) { let formkey = document.querySelector('input[name="form_key"]').value; hyva.setCookie('form_key', formkey); if (this.isAddedToWishlist) { document.getElementById("favouritepopupbutton").click(); return; } this.isLoading = true; const postParams = { action: BASE_URL + "wishlist/index/add/", data: { product: productId, uenc: btoa(window.location.href) } } postParams.data['form_key'] = document.querySelector('input[name=form_key]').value; let qty = document.getElementById(`qty[${productId}]`); postParams.data['qty'] = (qty != null) ? 1 : qty; let postData = Object.keys(postParams.data).map(key => { return `${key}=${postParams.data[key]}`; }).join('&'); // take the all the input fields that configure this product // includes custom, configurable, grouped and bundled options Array.from(document.querySelectorAll( '[name^=options], [name^=super_attribute], [name^=bundle_option], [name^=super_group], [name^=links]')).map(input => { if (input.type === "select-multiple") { Array.from(input.selectedOptions).forEach(option => { postData += `&${input.name}=${option.value}` }) } else { // skip "checkable inputs" that are not checked if (!(['radio', 'checkbox', 'select'].includes(input.type) && !input.checked)) { postData += `&${input.name}=${input.value}` } } }); fetch(postParams.action, { "headers": { "content-type": "application/x-www-form-urlencoded; charset=UTF-8", }, "body": postData, "method": "POST", "mode": "cors", "credentials": "include" }).then(function(response) { if (response.redirected) { var url = response.url; if (url.indexOf("customer/account/login") == -1) { localStorage.setItem("addToWishlist", true); } window.location.href = response.url; } else if (response.ok) { return response.json(); } else { typeof window.dispatchMessages !== "undefined" && window.dispatchMessages( [{ type: "warning", text: "Could not add item to wishlist." }], 5000 ); } }).then(function(response) { if (!response) { return; } typeof window.dispatchMessages !== "undefined" && window.dispatchMessages( [{ type: (response.success) ? "success" : "error", text: (response.success) ? "Product has been added to your Wish List." : response.error_message }], 5000 ); const reloadCustomerDataEvent = new CustomEvent("reload-customer-section-data"); window.dispatchEvent(reloadCustomerDataEvent); }).catch(function(error) { typeof window.dispatchMessages !== "undefined" && window.dispatchMessages( [{ type: "error", text: error }], 5000 ); }); } else { window.location.href; } } }); } }, submitEmail() { this.inputElements = [...document.getElementById('ajaxlogin-create-form-wishlist').querySelectorAll("input[data-rules]")]; this.inputElements.map((input) => { if (Iodine.is(input.value, JSON.parse(input.dataset.rules)) !== true) { const error = Iodine.is(input.value, JSON.parse(input.dataset.rules)); event.preventDefault(); input.classList.add("invalid"); Iodine.messages.required = "This is a required field."; Iodine.messages.email = "Please enter a valid email address (Ex: johndoe@domain.com)."; Iodine.messages.minimum = "Minimum length of this field must be equal or greater than 1 symbols. Leading and trailing spaces will be ignored."; this[input.name].errorMessage = Iodine.getErrorMessage(error); } else { input.classList.remove("invalid"); this[input.name].errorMessage = ""; // Show the signup pass popup if email is valid this.IsSignupEmail = false; this.IsSignupPass = true; this.Isregisterform = true; this.email = this.$refs.registeremail.value; } }); }, submitForm() { this.inputElements = [...document.getElementById('ajaxlogin-create-form-pass-wishlist').querySelectorAll("input[data-rules]")]; this.inputElements.map((input) => { if (Iodine.is(input.value, JSON.parse(input.dataset.rules)) !== true) { const error = Iodine.is(input.value, JSON.parse(input.dataset.rules)); event.preventDefault(); input.classList.add("invalid"); Iodine.messages.required = "This is a required field."; Iodine.messages.email = "Please enter a valid email address (Ex: johndoe@domain.com)."; Iodine.messages.minimum = "Minimum length of this field must be equal or greater than 1 symbols. Leading and trailing spaces will be ignored."; this[input.name].errorMessage = Iodine.getErrorMessage(error); } else { input.classList.remove("invalid"); this[input.name].errorMessage = ""; } }); if (document.getElementById('create-from-wrapper-pass').querySelectorAll(".invalid").length == 0) { this.$refs.signupPass.innerHTML = "Please wait..."; this.$refs.signupPassButton.disabled = true; let $form = document.getElementById('ajaxlogin-create-form-pass'); if (!this.hasCaptchaToken) { this.errors = 1; const executeGreCaptcha = () => { grecaptcha.ready(() => { grecaptcha.execute( '6Lfy\u002DrUgAAAAALziuUTD4krRaDb_vjmhsTEx2cMO', {action: 'submit'} ).then((token) => { if (token && token.length > 0) { $form['g\u002Drecaptcha\u002Dresponse'].value = token; this.errors = 0; this.hasCaptchaToken = 1; (this.submitForm || $form.submit).call(this); } else { this.errors = 1; const error = 'ReCaptcha\u0020validation\u0020failed,\u0020please\u0020try\u0020again'; if (this.setErrorMessages) { this.setErrorMessages([error]) this.displayErrorMessage = true; } else { window.dispatchMessages && window.dispatchMessages([{type: "error", text: error}], 5000); } } }).catch(exception => { console.error(exception || `An unknown error occurred during ReCaptcha validation. Are the tokens and the domain correctly set up in the Google console?`) }); }) } if (window.grecaptcha) { executeGreCaptcha(); } else { const recaptchaUrl = "https://www.google.com/recaptcha/api.js?render=6Lfy\u002DrUgAAAAALziuUTD4krRaDb_vjmhsTEx2cMO"; const script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.setAttribute('src', recaptchaUrl); document.head.appendChild(script); script.addEventListener("load", executeGreCaptcha, false); } } if (this.errors === 0) { const formdata = { "form_key": document.getElementById("ajaxlogin-create-form-pass").elements["form_key"].value, "email": this.$refs.registeremail.value, "password": this.$refs.registerpassword.value, "productid": this.$refs.registerproduct.value, "is_subscribed": document.querySelector('#is_subscribed').checked, 'g-recaptcha-response': $form.querySelector('input[name="g-recaptcha-response"]').value }; fetch('https://www.slideteam.net/free/ajax/registerpopup/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest' }, body: JSON.stringify(formdata) }).then(response => { return response.json() }).then(data => { if (data.errors) { this.$refs.registerresponse.style.display = 'Block'; this.$refs.registerresponse.innerHTML = "
" + data.message + "
"; this.errors = 1; this.hasCaptchaToken = 0; } else { this.$refs.registerresponse.innerHTML = "
" + data.message + "
"; } setTimeout(function() { document.querySelector('.response-msg').style.display = 'none'; }, 5000); if (data.errors) { this.$refs.signupPass.innerHTML = "Sign Up"; this.$refs.signupPassButton.disabled = false; } else { var productId = document.querySelector(".currentProduct").value; if (productId) { let formkey = document.querySelector('input[name="form_key"]').value; hyva.setCookie('form_key', formkey); if (this.isAddedToWishlist) { document.getElementById("favouritepopupbutton").click(); return; } this.isLoading = true; const postParams = { action: BASE_URL + "wishlist/index/add/", data: { product: productId, uenc: btoa(window.location.href) } } postParams.data['form_key'] = document.querySelector('input[name=form_key]').value; let qty = document.getElementById(`qty[${productId}]`); postParams.data['qty'] = (qty != null) ? 1 : qty; let postData = Object.keys(postParams.data).map(key => { return `${key}=${postParams.data[key]}`; }).join('&'); // take the all the input fields that configure this product // includes custom, configurable, grouped and bundled options Array.from(document.querySelectorAll( '[name^=options], [name^=super_attribute], [name^=bundle_option], [name^=super_group], [name^=links]')).map(input => { if (input.type === "select-multiple") { Array.from(input.selectedOptions).forEach(option => { postData += `&${input.name}=${option.value}` }) } else { // skip "checkable inputs" that are not checked if (!(['radio', 'checkbox', 'select'].includes(input.type) && !input.checked)) { postData += `&${input.name}=${input.value}` } } }); fetch(postParams.action, { "headers": { "content-type": "application/x-www-form-urlencoded; charset=UTF-8", }, "body": postData, "method": "POST", "mode": "cors", "credentials": "include" }).then(function(response) { if (response.redirected) { var url = response.url; if (url.indexOf("customer/account/login") == -1) { localStorage.setItem("addToWishlist", true); } window.location.href = response.url; } else if (response.ok) { return response.json(); } else { typeof window.dispatchMessages !== "undefined" && window.dispatchMessages( [{ type: "warning", text: "Could not add item to wishlist." }], 5000 ); } }).then(function(response) { if (!response) { return; } typeof window.dispatchMessages !== "undefined" && window.dispatchMessages( [{ type: (response.success) ? "success" : "error", text: (response.success) ? "Product has been added to your Wish List." : response.error_message }], 5000 ); const reloadCustomerDataEvent = new CustomEvent("reload-customer-section-data"); window.dispatchEvent(reloadCustomerDataEvent); }).catch(function(error) { typeof window.dispatchMessages !== "undefined" && window.dispatchMessages( [{ type: "error", text: error }], 5000 ); }); } else { window.location.href; } } }); } } }, forgotemail() { if (this.$refs.forgotsubmit.innerHTML != "Submit") { this.$refs.forgotsubmit.innerHTML = "Submit"; } }, submit: function(event) { this.inputElements = [...this.$el.querySelectorAll("[data-rules]")]; this.inputElements.map((input) => { if (Iodine.is(input.value, JSON.parse(input.dataset.rules)) !== true) { const error = Iodine.is(input.value, JSON.parse(input.dataset.rules)); event.preventDefault(); input.classList.add("invalid"); Iodine.messages.required = "This is a required field."; Iodine.messages.email = "Please enter a valid email address (Ex: johndoe@domain.com)."; this[input.name].errorMessage = Iodine.getErrorMessage(error); } else { input.classList.remove("invalid"); this[input.name].errorMessage = ""; } }); }, countrychange() { var element = document.getElementById('country-isd-code'); document.querySelector('#country_id').value = element.options[element.selectedIndex].getAttribute("id"); document.querySelector('#country_value').value = element.options[element.selectedIndex].getAttribute("value"); document.querySelector('#country-code-error').style.display = 'none'; } } }