(function() { var take = function() { window.AqurBaseURL = 'https://pr.aqur.com'; window.addEventListener("chatform_initialized", async (event) => { //chatformBtn var launchBtn = document.createElement("img"); var btnUrl = "https://res.cloudinary.com/dts6mbw86/image/upload/f_auto,q_auto/v1739162467/aqur/luju/launchBtn_sy1llq.png"; launchBtn.src = btnUrl; launchBtn.classList.add("launchBtn"); launchBtn.classList.add("chatformBtn"); document.body.appendChild(launchBtn); launchBtn.style.position = "fixed"; launchBtn.style.bottom = "1px"; launchBtn.style.left = "50%"; launchBtn.style.transform = "translateX(-50%)"; // 横方向で中央揃え if (window.innerWidth <= 768) { launchBtn.style.width = "95%"; } else { launchBtn.style.width = "35%"; } const buttons = document.querySelectorAll('.cta__btn'); buttons.forEach(elm => { const anchor = elm.querySelector('a'); const image = elm.querySelector('img'); if (anchor) { anchor.removeAttribute('href'); anchor.classList.add('chatformBtn'); }else if (!anchor && image) { image.classList.add('chatformBtn'); } }); createAqurBinding() }) function render(template, data) { return template.replace(/{{(.*?)}}/g, (match) => { return data[match.split(/{{|}}/).filter(Boolean)[0].trim()] }) } function activateChatformWidget() { if (!chatform_initialized) { console.log("Aqur is not ready") return } const w = document.querySelector('.chatform_widget'); w.classList.toggle("close"); if (w.classList.contains("close")) { document.body.classList.remove("chat_open"); } else { document.body.classList.add("chat_open"); } } var chatform_initialized = false const pid = "luju"; const target = "production"; const mode = "release"; const device = JSON.parse("false".toLowerCase()) ? "mobile" : "pc"; var 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('launch', launch); REF.searchParams.append('hash', "ca45ac18-d9e3-4f89-bd16-cc05d2bec4a0"); 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', "216.73.216.92"); 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'); const params = new URLSearchParams(REF.search.slice(1)); let search = REF.search.slice(1) //console.log(search) //launch = params.get('launch'); 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.closest('.bot_open') || event.target.classList.contains("bot_open") || event.target.id == "chatform_widget_cancelbtn" ) { activateChatformWidget() } }); document.dispatchEvent(new CustomEvent("chatform_widget_creation_complete")); }; setTimeout(creationComplete, 250); window.addEventListener("message", async (event) => { if (event.data.event == "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_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")); } if (event.data.event == "chatform_sent") { //console.log("chatform_sent") var project = event.data.project; var arr = project.data; var chatform = { pid: project.pid, sid: project.sid, uuId: project.uuId, customId:"conversion" } localStorage.setItem('chatform', JSON.stringify(chatform)); bindandSubmit(arr) } window.aqur.bind(event) }, false) } setTimeout(take, 0); function createAqurBinding() { console.log("AqurBindingCreated") //aqur bind start window.aqur = {} window.aqur.debug = false; // false -> to change, true for debug mode 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.setName(event.data.value.values[0].value + event.data.value.values[1].value) window.aqur.setNameKana(event.data.value.values[2].value + event.data.value.values[3].value) window.aqur.save("Name", event.data.value.values[0].value + event.data.value.values[1].value) window.aqur.save("NameKana", event.data.value.values[2].value + 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) } 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 == "password") { window.aqur.setPassword(event.data.value.values[0].value) window.aqur.save("Password", event.data.value.values[0].value) if(window.aqur.City){ window.aqur.setCity(window.aqur.City) } } 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) } } //Binding Method for ECForce window.aqur.setName = (value) => { window.aqur.debug && console.log("debug setName", value); window.aqur.fillInput('input#order_billing_address_attributes_name1', value) } window.aqur.setNameKana = (value) => { window.aqur.debug && console.log("debug setNameKana", value); window.aqur.fillInput('input#order_billing_address_attributes_kana1', value) } window.aqur.setPostalCode = (value) => { window.aqur.debug && console.log("debug setPostalCode", value); window.aqur.fillInput('input[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#form-validation-field-0', value) } //メールアドレス window.aqur.setEmail = (value) => { window.aqur.debug && console.log("debug setEmail", value); window.aqur.fillInput('input#email', value) } //お支払い方法選択 window.aqur.setPaymentMethodTypeKey = (value) => { window.aqur.debug && console.log("debug setPaymentMethodTypeKey", value); window.aqur.chooseSelectBox('select[name="order[payment_attributes][payment_method_id]"]', value) } //クレジットカード番号 window.aqur.setCardNumber = (value) => { window.aqur.debug && console.log("debug setCardNumber", value); window.aqur.fillInput('input[name="order[payment_attributes][source_attributes][number]"]', 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/, '')) } //Helper Method window.aqur.convertToHalfWidth = (input) => { if(input){ return input.replace(/[0-9−ー―‐]/g, (match) => { if (/[0-9]/.test(match)) { // 全角数字を半角数字に変換 return String.fromCharCode(match.charCodeAt(0) - 0xFEE0); } else { return '-'; } }); }else{ return ''; } } 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(", "); } 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) => { const inputElement = document.querySelector(selector); if (inputElement) { let nativeValueSetter = Object.getOwnPropertyDescriptor( window.HTMLInputElement.prototype, "value" ).set; nativeValueSetter.call(inputElement, value); let inputEvent = new Event("input", { bubbles: true }); inputElement.dispatchEvent(inputEvent); } }; 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.chooseSelectVueBox = (selectBoxSelector, value, useOptionVal = true) => { const selectElement = document.querySelector(selectBoxSelector); if (!selectElement) return; let option; if (useOptionVal) { option = selectElement.querySelector(`option[value='${value}']`); } else { option = Array.from(selectElement.options).find(opt => opt.text.trim() === value); } if (option) { // Directly update the select element's value selectElement.value = option.value; // Manually trigger Vue's reactivity update using native property setter let nativeSetter = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value").set; nativeSetter.call(selectElement, option.value); // Dispatch both 'input' and 'change' events to notify Vue selectElement.dispatchEvent(new Event("input", { bubbles: true })); selectElement.dispatchEvent(new Event("change", { bubbles: true })); } }; 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 bindandSubmit(d){ //console.log("d=>",d) // 同意 const Agreement = document.querySelector('input#agree').checked; if (!Agreement) { document.querySelector('input#agree').click() } // 申し込み確認ボタン 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() }, 1000); } else { // console.log("sp click") document.querySelector('input.submit_button_complete_sp_ec').click() setTimeout(() => { document.querySelector('input.submit_button_complete_sp_ec').click() }, 1000); //DisplayAndHideForm("nohideform") } } 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"); if(w.classList.contains("close")){ document.body.classList.remove("chat_open"); } } } function ScrollFormtoSubmit(){ var viewForm = document.querySelector('#new-view'); if (isAndroid()) { //alert("work") window.location.hash = "#new-view" var viewFormPosition = viewForm.getBoundingClientRect().top + window.pageYOffset - 100; // Adjust for header window.scrollTo({ top: viewFormPosition, behavior: 'smooth' }); }else{ requestAnimationFrame(function() { viewForm.scrollIntoView({ behavior: 'smooth', block: 'start' }); }); } } function isAndroid() { return /Android/i.test(navigator.userAgent); }