(function() { var take = function() { document.addEventListener("DOMContentLoaded", () => { //console.log("DOMContentLoaded") }) window.addEventListener("chatform_initialized", (event) => { //console.log("aqur_initialized") /* var launchBtn = document.createElement("img"); var btnUrl = "https://res.cloudinary.com/dts6mbw86/image/upload/f_auto/v1709101462/aqur/mtg/chatbot_btn_fgz5fl.png" launchBtn.src = btnUrl; launchBtn.classList.add("launchBtn"); launchBtn.classList.add("chatformBtn"); document.body.appendChild(launchBtn); launchBtn.style.position = "fixed"; launchBtn.style.bottom = "61px"; */ const element = document.querySelector('a.fixed-offer__btn'); if (element) { element.classList.add('chatformBtn'); element.style.cursor = 'pointer'; } DisplayAndHideForm("hideform") createAqurBinding() }) function render(template, data){ //console.log("render",template,data) return template.replace(/{{(.*?)}}/g, (match) => { return data[match.split(/{{|}}/).filter(Boolean)[0].trim()] }) } function activateChatformWidget(){ if(!chatform_initialized){ console.log("chatbot is not ready yet") return } const w = document.querySelector('.chatform_widget'); w.classList.toggle("close"); w.classList.toggle("normal"); if(w.classList.contains("close")){ document.body.classList.remove("chat_open"); }else{ document.body.classList.add("chat_open"); } } var chatform_initialized = false const pid = "msm"; const target = "production"; const mode = "release"; const device = JSON.parse("false".toLowerCase())?"mobile":"pc"; const launch = "click"; const client = "https://form.aqur.com/"; let REF = new URL(window.location); let userChatbot = REF.searchParams.get('usechatbot') if(userChatbot=="no"){ console.log("no chatbot") return } REF.searchParams.append('pid', pid); REF.searchParams.append('mode', mode); REF.searchParams.append('target', target); REF.searchParams.append('hash', "1a8d4d9d-bfc7-419c-bbf4-f2aa265ac116"); REF.searchParams.append('browser', "undefined"); REF.searchParams.append('device', device); REF.searchParams.append('os', "undefined"); REF.searchParams.append('ua', "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)"); REF.searchParams.append('ip', "3.141.7.186"); REF.searchParams.append('ref', REF.href); REF.searchParams.append('path', REF.pathname); //for UI REF.searchParams.append('CLIENT_ID', 'PR'); REF.searchParams.append('BASE_URL', 'https://pr.aqur.com'); REF.searchParams.append('HEADER_LABEL', 'お申し込みはこちらから!'); REF.searchParams.append('HEADER_BG_COLOR', '#fff'); REF.searchParams.append('HEADER_LABEL_COLOR', '#fff'); REF.searchParams.append('SHOW_TIMER', 'false'); REF.searchParams.append('ICON_PATH', 'https://res.cloudinary.com/dts6mbw86/image/upload/v1713319985/aqur/common/icon_azvikf.png'); let utm_content = REF.searchParams.get('utm_content') if(utm_content){ let agent = utm_content.substring(utm_content.lastIndexOf("_")+1, utm_content.length) if(agent){ REF.searchParams.append('agent', agent); } } let search = REF.search.slice(1) //console.log(search) let widget = render( ''+ '', { device : device, client : client, search : (search)?"&"+search:"", } ); const body = document.body; if(body){ var filterId; const chatbotProgressBar = "
" body.insertAdjacentHTML('beforeend', chatbotProgressBar); body.classList.add(device) body.insertAdjacentHTML('beforeend', widget); const target = document.querySelector('.chatform_widget'); const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if(!target.classList.contains("close")){ var contentWindow = target.contentWindow; if(contentWindow){ contentWindow.postMessage("chat_open", "*"); contentWindow.postMessage( { type:"filterIdChanged", data:filterId }, "*"); } } }); }); const config = { characterData: true, attributes:true, subtree: true }; observer.observe(target, config); } let creationComplete = function(){ if(device=="pc"){ var resize=()=>{ let zoom_level = window.devicePixelRatio || window.screen.availWidth / document.documentElement.clientWidth * 100; const targets = document.querySelectorAll('body,.chatform_widget'); if(zoom_level>=3){ targets[0].classList.add("mobile") targets[0].classList.remove("pc") targets[1].classList.add("mobile") targets[1].classList.remove("pc") }else{ targets[0].classList.add("pc") targets[0].classList.remove("mobile") targets[1].classList.add("pc") targets[1].classList.remove("mobile") } } resize() window.addEventListener("resize", () => { resize() }) } document.addEventListener('click', (event) => { if (event.target && event.target.closest('.chatformBtn ') || event.target.classList.contains("chatformBtn") || event.target.id == "chatform_widget_cancelbtn" ) { activateChatformWidget() filterId = event.target.closest(".chatformBtn").dataset.filterid } }); document.dispatchEvent(new CustomEvent("chatform_widget_creation_complete")); }; setTimeout(creationComplete, 0); window.addEventListener("message", (event) => { // if(event.data.event == "chatform_gotoCart"){ //console.log("chatform_gotoCart") // var clickOnAddToCartContentAsset = document.querySelector("#formLPSection .clickOnAddToCartContentAsset"); // activateChatformWidget(); // clickOnAddToCartContentAsset.click() // } if(event.data.event == "chatform_savedata"){ } if(event.data.event == "chatform_sent"){ //activateChatformWidget(); var project = event.data.project; var arr = event.data.project.data var chatform = { pid:project.pid, sid:project.sid, uuId:project.uuId, id:arr[arr.length-1].id } localStorage.setItem('chatform', JSON.stringify(chatform)); //console.log("arr",arr) let Payment = findOptionByCustomId(arr, "payment_method_id", "payment"); ChatformSubmitForm(Payment) } if(event.data.event == "loginUser") { let userData = event.data.data let pathName = window.location.pathname ChatFormWidgetHide() DisplayAndHideForm("nohideform") ScrollFormtoSubmit() const toggleCheckbox = (checkboxSelector, checked) => { return new Promise((resolve, reject) => { const checkbox = document.querySelector(checkboxSelector); if (checkbox) { checkbox.checked = checked; let event = new Event('change', { bubbles: true, composed: true }); checkbox.dispatchEvent(event); resolve(`Checkbox with selector '${checkboxSelector}' set to ${checked} and event dispatched.`); } else { reject(new Error(`Checkbox with selector '${checkboxSelector}' not found.`)); } }); }; const fillInput = (selector, value) => { return new Promise((resolve, reject) => { // Create an InputEvent for the change event let inputEvent = new Event('input', { bubbles: true, cancelable: true }); let changeEvent = new Event('change', { bubbles: true, cancelable: true }); const inputElement = document.querySelector(selector); if (inputElement) { inputElement.value = value; inputElement.dispatchEvent(inputEvent); inputElement.dispatchEvent(changeEvent); resolve(`Input with selector "${selector}" filled and events dispatched`); } else { reject(`Element with selector "${selector}" not found.`); } }); }; const bindLogin = async () => { await toggleCheckbox('#show-login-view', true) location.hash = "#show-login-view" await new Promise(resolve => setTimeout(resolve, 1000)); await fillInput('[name="customer[email]"]', userData.username) await fillInput('[name="customer[password]"]', userData.password) await new Promise(resolve => setTimeout(resolve, 500)); if(document.querySelector('.login_button_sp_ec')) { // SP document.querySelector('.login_button_sp_ec').click() } else { // PC document.querySelector('.login_button_ec').click() } } setTimeout(bindLogin, 1000) } if(event.data.event == "chatform_close"){ //console.log("chatform_close") activateChatformWidget(); } if(event.data.event == "chatform_evalScript"){ window.eval(event.data.script) } if(event.data.event == "chatform_insertTag"){ body.insertAdjacentHTML( "beforeend", event.data.tag ); event.data.scripts.forEach((item)=>{ eval(item.textContent)}) } if(event.data.event == "chatform_start"){ console.log(event.data.uuId) } if(event.data.event == "chatform_initialized"){ console.log("aqur_initialized") document.getElementById("chatbotProgressBar").style.width = "100%"; var opacity = function(){ document.getElementById("chatbotProgressBar").style.opacity = "0"; }; setTimeout(opacity, 1000); chatform_initialized = true; if(launch=="auto"){ activateChatformWidget(); } window.dispatchEvent(new CustomEvent("chatform_initialized")); } window.aqur.bind(event) },false) } setTimeout(take, 0); }()) function createAqurBinding(){ //console.log("AqurBindingCreated") //aqur bind start window.aqur = {} window.aqur.debug = false; window.aqur.save = (key, value) => { window.aqur[key] = value; // You can access data anytime using window.aqur.XXX } window.aqur.bind = (event) => { //console.log("waq",event.data.event) if (event.data.event == "name") { window.aqur.setLastName(event.data.value.values[0].value) window.aqur.setFirstName(event.data.value.values[1].value) window.aqur.setLastNameKana(event.data.value.values[2].value) window.aqur.setFirstNameKana(event.data.value.values[3].value) window.aqur.save("LastName", event.data.value.values[0].value) window.aqur.save("FirstName", event.data.value.values[1].value) window.aqur.save("LastNameKana", event.data.value.values[2].value) window.aqur.save("FirstNameKana", event.data.value.values[3].value) } if (event.data.event == "address") { var FullAddress = event.data.value.values[0].value + event.data.value.values[1].value + event.data.value.values[2].value + event.data.value.values[3].value + event.data.value.values[4].value; if(FullAddress!=window.aqur.FullAddress){ window.aqur.setPostalCode(event.data.value.values[0].value) window.aqur.setPref(event.data.value.values[1].value) window.aqur.setCity(event.data.value.values[2].value) window.aqur.setStreet(event.data.value.values[3].value) window.aqur.setBuilding(event.data.value.values[4].value) window.aqur.save("PostalCode", event.data.value.values[0].value) window.aqur.save("Pref", event.data.value.values[1].value) window.aqur.save("City", event.data.value.values[2].value) window.aqur.save("Street", event.data.value.values[3].value.replace(/[−ー―‐-〜]/g, '-')) window.aqur.save("Building", event.data.value.values[4].value.replace(/[−ー―‐-〜]/g, '-')) window.aqur.save("FullAddress", event.data.value.values[0].value + event.data.value.values[1].value + event.data.value.values[2].value + event.data.value.values[3].value + event.data.value.values[4].value ) } } if (event.data.event == "tel") { window.aqur.setTel(event.data.value.values[0].value) window.aqur.save("Tel", event.data.value.values[0].value) //for password 自動入力 let pwd = "a" + event.data.value.values[0].value.slice(-7) window.aqur.setPassword(pwd) window.aqur.save("Password", pwd) } if (event.data.event == "birthday") { window.aqur.setBirthdayYear(Number(event.data.value.values[0].value)) window.aqur.setBirthdayMonth(Number(event.data.value.values[1].value)) window.aqur.setBirthdayDay(Number(event.data.value.values[2].value)) window.aqur.save("Year", event.data.value.values[0].value) window.aqur.save("Month", event.data.value.values[1].value) window.aqur.save("Day", event.data.value.values[2].value) } if (event.data.event == "gender") { var item = window.aqur.getCheckedOptionSA(event.data.value.options) if(item){ window.aqur.setGender(item.value) window.aqur.save("Gender", item.value) } } if (event.data.event == "email") { window.aqur.setEmail(event.data.value.values[0].value) window.aqur.save("Email", event.data.value.values[0].value) } if (event.data.event == "SelOtherDeli") { var item = window.aqur.getCheckedOptionSA(event.data.value.options) if(item){ window.aqur.setSelOtherDeli(item.value) window.aqur.save("SelOtherDeli", item.value) } } if (event.data.event == "otherName") { window.aqur.setOtherLastName(event.data.value.values[0].value) window.aqur.setOtherFirstName(event.data.value.values[1].value) window.aqur.setOtherLastNameKana(event.data.value.values[2].value) window.aqur.setOtherFirstNameKana(event.data.value.values[3].value) window.aqur.save("OtherLastName", event.data.value.values[0].value) window.aqur.save("OtherFirstName", event.data.value.values[1].value) window.aqur.save("OtherLastNameKana", event.data.value.values[2].value) window.aqur.save("OtherFirstNameKana", event.data.value.values[3].value) } if (event.data.event == "otherDeli") { var FullAddress = event.data.value.values[0].value + event.data.value.values[1].value + event.data.value.values[2].value + event.data.value.values[3].value + event.data.value.values[4].value; if(FullAddress!=window.aqur.OtherFullAddress){ window.aqur.setOtherPostalCode(event.data.value.values[0].value) window.aqur.setOtherPref(event.data.value.values[1].value) window.aqur.setOtherCity(event.data.value.values[2].value) window.aqur.setOtherStreet(event.data.value.values[3].value) window.aqur.setOtherBuilding(event.data.value.values[4].value) window.aqur.save("OtherPostalCode", event.data.value.values[0].value) window.aqur.save("OtherPref", event.data.value.values[1].value) window.aqur.save("OtherCity", event.data.value.values[2].value) window.aqur.save("OtherStreet", event.data.value.values[3].value.replace(/[−ー―‐-〜]/g, '-')) window.aqur.save("OtherBuilding", event.data.value.values[4].value.replace(/[−ー―‐-〜]/g, '-')) window.aqur.save("OtherFullAddress", event.data.value.values[0].value + event.data.value.values[1].value + event.data.value.values[2].value + event.data.value.values[3].value + event.data.value.values[4].value ) } } if (event.data.event == "payment") { var item = window.aqur.getCheckedOptionSA(event.data.value.options) if(item){ window.aqur.setPaymentMethodTypeKey(item.value) window.aqur.save("Payment", item.value) } } if (event.data.event == "cc") { window.aqur.setCardNumber(event.data.value.values[0].value) window.aqur.setCardExpirationYear(event.data.value.values[1].value) window.aqur.setCardExpirationMonth(event.data.value.values[2].value) window.aqur.setCardCvc(event.data.value.values[3].value) window.aqur.setCardHolderName(event.data.value.values[4].value) window.aqur.save("CardNumber", event.data.value.values[0].value) window.aqur.save("CardExpirationYear", event.data.value.values[1].value) window.aqur.save("CardExpirationMonth", event.data.value.values[2].value) window.aqur.save("CardExpirationCvc", event.data.value.values[3].value) window.aqur.save("CardExpirationHolderName", event.data.value.values[4].value) } if (event.data.event == "coupon") { if(event.data.value.values[0].value && event.data.value.values[0].value != "undefined"){ window.aqur.setCouponMethod(event.data.value.values[0].value) window.aqur.save("CouponMethod", event.data.value.values[0].value) }else{ window.aqur.setCouponMethod("") window.aqur.save("CouponMethod", "") } } if (event.data.event == "upsellSelect") { var item = window.aqur.getCheckedOptionSA(event.data.value.options) if(item && item.value == "1"){ window.aqur.setProduct("83") }else if(item && item.value == "2"){ window.aqur.setProduct("77") } } } //Binding Method for ECForce window.aqur.setLastName = (value) => { window.aqur.debug && console.log("debug setLastName", value); if(!document.querySelector('[name="order[billing_address_attributes][name02]"]')){ var concat = value +" "+window.aqur.FirstName window.aqur.fillInput('[name="order[billing_address_attributes][name01]"]', concat) }else{ window.aqur.fillInput('[name="order[billing_address_attributes][name01]"]', value) } } window.aqur.setFirstName = (value) => { window.aqur.debug && console.log("debug setFirstName", value); window.aqur.fillInput('[name="order[billing_address_attributes][name02]"]', value) } window.aqur.setLastNameKana = (value) => { window.aqur.debug && console.log("debug setLastNameKana", value); if(!document.querySelector('[name="order[billing_address_attributes][kana02]"]')){ var concat = value +" "+window.aqur.FirstNameKana window.aqur.fillInput('[name="order[billing_address_attributes][kana01]"]', concat) }else{ window.aqur.fillInput('[name="order[billing_address_attributes][kana01]"]', value) } } window.aqur.setFirstNameKana = (value) => { window.aqur.debug && console.log("debug setFirstNameKana", value); window.aqur.fillInput('[name="order[billing_address_attributes][kana02]"]', value) } window.aqur.setPostalCode = (value) => { window.aqur.debug && console.log("debug setPostalCode", value); window.aqur.fillInput('[name="order[billing_address_attributes][zip01]"]', value) function callLater() { window.aqur.setCity(window.aqur.City) window.aqur.setStreet(window.aqur.Street) window.aqur.setBuilding(window.aqur.Building) } setTimeout(callLater, 1000); } window.aqur.setPref = (value) => { window.aqur.debug && console.log("debug setPref", value); window.aqur.chooseSelectBoxLabel('select[name="order[billing_address_attributes][prefecture_id]"]', value) } window.aqur.setCity = (value) => { window.aqur.debug && console.log("debug setCity", value); window.aqur.fillInput('input[name="order[billing_address_attributes][addr01]"]', value) } window.aqur.setStreet = (value) => { window.aqur.debug && console.log("debug setStreet", value); if(!document.querySelector('input#order_billing_address_attributes_addr03')){ var concat = value +" "+window.aqur.Building window.aqur.fillInput('input#order_billing_address_attributes_addr02', concat) }else{ window.aqur.fillInput('input#order_billing_address_attributes_addr02', value) } } window.aqur.setBuilding = (value) => { window.aqur.debug && console.log("debug setBuilding", value); window.aqur.fillInput('input#order_billing_address_attributes_addr03', value) } window.aqur.setTel = (value) => { window.aqur.debug && console.log("debug setTel", value); window.aqur.fillInput('input[name="order[billing_address_attributes][tel01]"]', value.replace(/-/g,'')) window.aqur.fillInput('[name="order[shipping_address_attributes][tel01]"]', value.replace(/-/g,'')) } window.aqur.setEmail = (value) => { window.aqur.debug && console.log("debug setEmail", value); window.aqur.fillInput('input[name="order[email]"]', value) } window.aqur.setBirthdayYear = (value) => { window.aqur.debug && console.log("debug setBirthdayYear", value); window.aqur.chooseSelectBox('select[name="order[customer_attributes][birth(1i)]"]', value) } window.aqur.setBirthdayMonth = (value) => { window.aqur.debug && console.log("debug setBirthdayMonth", value); window.aqur.chooseSelectBox('select[name="order[customer_attributes][birth(2i)]"]', value) } window.aqur.setBirthdayDay = (value) => { window.aqur.debug && console.log("debug setBirthdayDay", value); window.aqur.chooseSelectBox('select[name="order[customer_attributes][birth(3i)]"]', value) } window.aqur.setGender = (value) => { window.aqur.debug && console.log("debug setGender", value); window.aqur.chooseSelectBox('[name="order[customer_attributes][sex_id]"]', value) } window.aqur.setPassword = (value) => { window.aqur.debug && console.log("debug setPassword", value); window.aqur.fillInput('input[name="order[customer_attributes][password]"]', value) } window.aqur.setSelOtherDeli = (value) => { window.aqur.debug && console.log("debug setSelOtherDeli", value); window.aqur.chooseSelectBox('select#shipping_address_id', value) } window.aqur.setOtherLastName = (value) => { window.aqur.debug && console.log("debug setOtherLastName", value); if(!document.querySelector('input#order_shipping_address_attributes_name2')){ var concat = value +" "+window.aqur.FirstName window.aqur.fillInput('input#order_shipping_address_attributes_name1', concat) }else{ window.aqur.fillInput('input#order_shipping_address_attributes_name1', value) } } window.aqur.setOtherFirstName = (value) => { window.aqur.debug && console.log("debug setOtherFirstName", value); window.aqur.fillInput('input#order_shipping_address_attributes_name2', value) } window.aqur.setOtherLastNameKana = (value) => { window.aqur.debug && console.log("debug setOtherLastNameKana", value); if(!document.querySelector('input#order_shipping_address_attributes_kana2')){ var concat = value +" "+window.aqur.FirstNameKana window.aqur.fillInput('input#order_shipping_address_attributes_kana1', concat) }else{ window.aqur.fillInput('input#order_shipping_address_attributes_kana1', value) } } window.aqur.setOtherFirstNameKana = (value) => { window.aqur.debug && console.log("debug setOtherFirstNameKana", value); window.aqur.fillInput('input#order_shipping_address_attributes_kana2', value) } window.aqur.setOtherPostalCode = (value) => { window.aqur.debug && console.log("debug setOtherPostalCode", value); window.aqur.fillInput('input#order_shipping_address_attributes_zip01', value) function callLater() { window.aqur.setOtherCity(window.aqur.OtherCity) window.aqur.setOtherStreet(window.aqur.OtherStreet) window.aqur.setOtherBuilding(window.aqur.OtherBuilding) } setTimeout(callLater, 1000); } window.aqur.setOtherPref = (value) => { window.aqur.debug && console.log("debug setOtherPref", value); window.aqur.chooseSelectBoxLabel('select#order_shipping_address_attributes_prefecture_name', value) } window.aqur.setOtherCity = (value) => { window.aqur.debug && console.log("debug setOtherCity", value); window.aqur.fillInput('input#order_shipping_address_attributes_addr01', value) } window.aqur.setOtherStreet = (value) => { window.aqur.debug && console.log("debug setOtherStreet", value); if(!document.querySelector('input#order_shipping_address_attributes_addr03')){ var concat = value +" "+window.aqur.Building window.aqur.fillInput('input#order_shipping_address_attributes_addr02', concat) }else{ window.aqur.fillInput('input#order_shipping_address_attributes_addr02', value) } } window.aqur.setOtherBuilding = (value) => { window.aqur.debug && console.log("debug setOtherBuilding", value); window.aqur.fillInput('input#order_shipping_address_attributes_addr03', value) } window.aqur.setPaymentMethodTypeKey = (value) => { window.aqur.debug && console.log("debug setPaymentMethodTypeKey", value); window.aqur.chooseSelectBox('[name="order[payment_attributes][payment_method_id]"]', value) } window.aqur.setCardNumber = (value) => { window.aqur.debug && console.log("debug setCardNumber", value); window.aqur.fillInput('[name="order[payment_attributes][source_attributes][number]"]', value) } window.aqur.setCardHolderName = (value) => { window.aqur.debug && console.log("debug setCardHolderName", value); window.aqur.fillInput('[name="order[payment_attributes][source_attributes][name]"]', value) } window.aqur.setCardCvc = (value) => { window.aqur.debug && console.log("debug setCardCvc", value); window.aqur.fillInput('[name="cvv"]', value) } window.aqur.setCardExpirationYear = (value) => { window.aqur.debug && console.log("debug setCardExpirationYear", value); window.aqur.chooseSelectBox('[name="order[payment_attributes][source_attributes][year]"]', value) } window.aqur.setCardExpirationMonth = (value) => { window.aqur.debug && console.log("debug setCardExpirationMonth", value); window.aqur.chooseSelectBox('[name="order[payment_attributes][source_attributes][month]"]', value.replace(/^0/, '')) } window.aqur.setCouponMethod = (value) => { window.aqur.debug && console.log("debug setCouponMethod", value); window.aqur.fillInput('[name="order[coupon_code]"]', value) } window.aqur.setProduct = (value) => { window.aqur.debug && console.log("debug setProduct", value); window.aqur.chooseSelectBox('select#variant_id', value) } //Helper Method window.aqur.getCheckedOptionSA = (options) => { var rtn = options.find((v) => v.checked) return rtn } window.aqur.getCheckedOptionMA = (options) => { var checkedOptions = options.filter((v) => v.checked); var rtn = checkedOptions.map((v) => v.value); return rtn.join(", "); } //You can add more helper here (they shold be in window.aqur.xxx) window.aqur.waitForElement = (selectors, timeout = 5000) => { return new Promise((resolve, reject) => { const interval = 100; let elapsedTime = 0; const checkExistence = () => { for (const selector of selectors) { const element = document.querySelector(selector); if (element) { resolve(element); return; } } elapsedTime += interval; if (elapsedTime >= timeout) { reject(new Error(`None of the elements with selectors "${selectors.join(', ')}" were found within the timeout`)); } else { setTimeout(checkExistence, interval); } }; checkExistence(); }); }; window.aqur.fillInput = (selector, value) => { let inputEvent = new KeyboardEvent('keydown', { key: 'Enter', code: 'Enter', bubbles: true, cancelable: true }); const inputElement = document.querySelector(selector); if (inputElement) { inputElement.value = value; inputElement.dispatchEvent(inputEvent); } }; window.aqur.chooseRadioButton = (radioSelector, value) => { const radioButton = document.querySelector(`${radioSelector}[value='${value}']`); if (radioButton) { radioButton.checked = true; let event = new Event('change', { bubbles: true, composed: true }) radioButton.dispatchEvent(event); } }; window.aqur.chooseSelectBox = (selectBoxSelector, value, useOptionVal = true) => { let option = "" if(useOptionVal) { option = document.querySelector(`${selectBoxSelector} option[value='${value}']`); } else { option = document.querySelector(`${selectBoxSelector} option[label='${value}']`); } const selectElement = document.querySelector(`${selectBoxSelector}`); if (option && selectElement) { option.selected = true; const event = new Event('change', { bubbles: true, composed: true }) selectElement.dispatchEvent(event); } }; window.aqur.chooseSelectBoxLabel = (selectBoxSelector, label) => { const selectElement = document.querySelector(selectBoxSelector); var option; if(selectElement){ option = Array.from(selectElement.options).find( opt => opt.textContent.trim() === label ); } if (option) { option.selected = true; const event = new Event('change', { bubbles: true, composed: true }); selectElement.dispatchEvent(event); } }; //aqur bind finish } function ChatformSubmitForm(Payment){ const Agreement = document.querySelector('input[name="agree"]').checked; if (!Agreement) { document.querySelector('input[name="agree"]').click() } DisplayAndHideForm("nohideform") if (Payment == "1" || Payment.includes("クレジットカード")) { ChatFormWidgetHide() }else{ //Submit if (document.querySelector('input.submit_button_complete_ec') !== null) { console.log("pc click") document.querySelector('input.submit_button_complete_ec').click() setTimeout(() => { document.querySelector('input.submit_button_complete_ec').click() }, 700); } else { console.log("sp click") document.querySelector('input.submit_button_complete_sp_ec').click() setTimeout(() => { document.querySelector('input.submit_button_complete_sp_ec').click() }, 700); //DisplayAndHideForm("nohideform") } } ScrollFormtoSubmit() } function DisplayAndHideForm(init){ document.body.style.overflow = 'auto'; document.documentElement.style.overflow = 'auto'; if(init == "hideform"){ console.log("hide work") if (document.querySelector('.login_message_box_ec') !== null && document.querySelector("#alert-box") === null && document.querySelector(".alert-danger_ec") === null ) { // console.log("hide work ec") document.querySelector('form#login-view').style.setProperty('display', 'none', 'important'); document.querySelector('#view-billing-information-header').style.setProperty('display', 'none', 'important'); document.querySelector('.login_message_box_ec').style.setProperty('display', 'none', 'important'); document.querySelector('form#new-view').style.setProperty('display', 'none', 'important'); }else if(document.querySelector('.login_message_box_sp_ec') !== null && document.querySelector("#alert-box") ===null && document.querySelector(".alert-danger_sp_ec") ===null ){ //console.log("hide work sp") document.querySelector('form#login-view').style.setProperty('display', 'none', 'important'); document.querySelector('#view-billing-information-header').style.setProperty('display', 'none', 'important'); document.querySelector('.login_message_box_sp_ec').style.setProperty('display', 'none', 'important'); document.querySelector('form#new-view').style.setProperty('display', 'none', 'important'); } }else if(init == "nohideform"){ console.log("no hide work") if (document.querySelector('.login_message_box_ec') !== null && document.querySelector("#alert-box") === null && document.querySelector(".alert-danger_ec") === null ){ // console.log("no hide work ec") if(document.querySelector("#show-login-view").checked){ document.querySelector('form#login-view').style.removeProperty('display'); } document.querySelector('#view-billing-information-header').style.removeProperty('display'); document.querySelector('.login_message_box_ec').style.removeProperty('display'); document.querySelector('form#new-view').style.removeProperty('display'); }else if(document.querySelector('.login_message_box_sp_ec') !== null && document.querySelector("#alert-box") === null && document.querySelector(".alert-danger_sp_ec") === null ){ //console.log("no hide work sp") if(document.querySelector("#show-login-view").checked){ document.querySelector('form#login-view').style.removeProperty('display'); } document.querySelector('#view-billing-information-header').style.removeProperty('display'); document.querySelector('.login_message_box_sp_ec').style.removeProperty('display'); document.querySelector('form#new-view').style.removeProperty('display'); } } } function ChatFormWidgetHide(){ console.log("ChatFormWidgetHide") if(localStorage.getItem("chatform")){ document.querySelector("body").click() const target = document.querySelector('.chatform_widget'); var param={ event: "chatform_BeforeSubmit", } target.contentWindow.postMessage(param, "*"); const w = document.querySelector('.chatform_widget'); w.classList.toggle("close"); w.classList.toggle("@wmode"); if(w.classList.contains("close")){ document.body.classList.remove("chat_open"); } } } function ScrollFormtoSubmit(){ var submitButton = document.querySelector('#submit'); if (isAndroid()) { //alert("work") window.location.hash = "#submit" var submitButtonPosition = submitButton.getBoundingClientRect().top + window.pageYOffset - 100; // Adjust for header window.scrollTo({ top: submitButtonPosition, behavior: 'smooth' }); }else{ requestAnimationFrame(function() { submitButton.scrollIntoView({ behavior: 'smooth', block: 'start' }); }); } } function isAndroid() { return /Android/i.test(navigator.userAgent); } //radio return single value function findOptionByCustomId(d, n, c) { let value = "Undefind"; rtn = value; for (var i = 0; i < d.length; i++) { var item = d[i]; if (item.options && item.customId == c) { item.options.forEach(function (v) { var reg = new RegExp(n) if (reg.test(v.name) && v.checked) { rtn = v.value } }) } } return rtn }