(function() { var take = function() { window.AqurBaseURL = 'https://pr.aqur.com'; window.addEventListener("chatform_initialized", async (event) => { // var launchBtn = document.createElement("img"); // var btnUrl = "https://res.cloudinary.com/dts6mbw86/image/upload/v1744907207/aqur/kkt/floating_banner_gr_zgaors.png"; // launchBtn.src = btnUrl; // launchBtn.classList.add("launchBtn"); // launchBtn.classList.add("chatformBtn"); // document.body.appendChild(launchBtn); // // Style the button // launchBtn.style.position = "fixed"; // launchBtn.style.bottom = "61px"; // launchBtn.style.zIndex = "100000"; // setTimeout(() => { // const DDP_SRC = "https://pr.aqur.com/landix/client/ddp"; // const scripts = document.querySelector(`script[src="${DDP_SRC}"]`); // scripts.remove(); // }, 500); const as = document.querySelectorAll('.chatformBtn'); as.forEach((a, i) => { console.log("remove href!"); a.classList.add("checkChk_" + i); if (a.hasAttribute("href")) { a.setAttribute("data-link", a.getAttribute("href")); a.removeAttribute("href"); } }); createAqurBinding() createVframe(); window.aqur.vframe=vframe; window.aqur.reset() }) function createVframe(){ var url = new URL(window.location.href); let userChatbot = url.searchParams.get('usechatbot') if(userChatbot){ return } vframe = document.createElement("iframe"); vframe.id="vframe"; vframe.sandbox.add('allow-storage-access-by-user-activation'); vframe.sandbox.add('allow-forms'); vframe.sandbox.add('allow-top-navigation-by-user-activation'); vframe.sandbox.add('allow-scripts'); vframe.sandbox.add('allow-same-origin'); vframe.sandbox.add('allow-modals') vframe.width="1px"; vframe.height="1px"; // let vframeUrl = "https://portal-landix.jp/lp-test/request-002-test.html"; //var REF = new URL(vframeUrl) var REF = new URL(window.location.href); REF.searchParams.append('usechatbot', "no"); vframe.src = REF; document.body.appendChild(vframe); let vfmode = url.searchParams.get('vfmode') vframe.width="70%"; vframe.height="450px" vframe.style.display= "block"; vframe.style.zIndex= 100; vframe.style.position= "fixed"; vframe.style.backgroundColor= "white"; vframe.style.top=0; vframe.style.left=0; vframe.style.boxSizing="border-box"; vframe.style.border="2px solid red"; vframe.style.marginTop = "10px"; vframe.style.opacity=0; vframe.style.zIndex = -1000; vframe.addEventListener("load", () => { try { const iframeDoc = vframe.contentWindow?.document; if (!iframeDoc) return; const DDP_SRC = `${window.AqurBaseURL}/landix/client/ddp`; const scripts = iframeDoc.querySelectorAll(`script[src="${DDP_SRC}"]`); //Remove duplicates (keep the first) if (scripts.length > 1) { for (let i = 1; i < scripts.length; i++) { scripts[i].remove(); console.log("Duplicate DDP script removed from iframe."); } } //If none exists, insert it if (scripts.length === 0) { const script = iframeDoc.createElement("script"); script.src = DDP_SRC; iframeDoc.head.appendChild(script); console.log("DDP script inserted into iframe."); } } catch (err) { console.warn("Failed to handle DDP script in iframe:", err); } }); if(vfmode=="debug"){ vframe.style.opacity=1; vframe.style.zIndex=1000; vframe.classList.add('debug'); vframe.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }); if(device=="mobile"){ vframe.height="50%" } const target = document.querySelector('.chatform_widget'); if (target) { target.style.height = "50%"; // 高さを50%に設定 } var param={ event: "chatform_vframe_debug" } vframe.contentWindow.postMessage(param, "*"); } } 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 = "landix"; 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('hash', "7d603c15-09a0-4e91-872c-cf81b6d212ac"); 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.10"); 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 == "redirect_thankPage"){ //console.log("redirect_chatform", event.data.event) const target = document.querySelector('.chatform_widget'); var param={ event: "chatform_clear" } target.contentWindow.postMessage(param, "*"); let redirect = function(){ window.location.href= event.data.url } setTimeout(redirect, 500); } 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_vframe_submit") { //console.log("chatform_sent") var project = event.data.project; var chatform = { pid: project.pid, sid: project.sid, uuId: project.uuId, customId:"conversion" } localStorage.setItem('chatform', JSON.stringify(chatform)); var param={ event: "chatform_bindFormSubmit" } vframe.contentWindow.postMessage(param, "*"); } if(event.data.event == "tryReset"){ window.aqur.reset() } if(event.data.event == "chatform_bindFormErrorFound"){ //console.log("chatform_bindFormErrorFound") const target = document.querySelector('.chatform_widget'); var param={ event: "chatform_bindFormErrorFound", text:event.data.text } target.contentWindow.postMessage(param, "*"); } if (window.aqur && typeof window.aqur.bind === 'function') { 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; } window.aqur.reset = () => { //console.log("do reset",window.aqur) window.aqur.setPropertyType(window.aqur.PropertyType) window.aqur.setArea(window.aqur.Area) window.aqur.setFloorPlan(window.aqur.FloorPlan) window.aqur.setBudget(window.aqur.Budget) window.aqur.setBudgetOne(window.aqur.BudgetOne) window.aqur.setSeason(window.aqur.Season) window.aqur.setFloorArea(window.aqur.FloorArea) window.aqur.setFullName(window.aqur.FullName) window.aqur.setFullNameKana(window.aqur.FullNameKana) window.aqur.setEmail(window.aqur.Email) window.aqur.setTel(window.aqur.Tel) window.aqur.setRailwayLine(window.aqur.RailwayLine) window.aqur.setYourHome(window.aqur.YourHome) window.aqur.setMemo(window.aqur.Memo) } window.aqur.bind = (event) => { //console.log("waq",event.data.event) if(event.data.track){ var track = { pid:event.data.track.pid, sid:event.data.track.sid, uuId:event.data.track.uuId, customId:"conversion" } window.aqur.setTrack(track); window.aqur.save("Track", track); } if (event.data.event == "PropertyType") { var item = window.aqur.getCheckedOptionMA(event.data.value.options) if(item){ window.aqur.setPropertyType(item) window.aqur.save("PropertyType", item) }else{ window.aqur.setPropertyType("") window.aqur.save("PropertyType", "") } } if (event.data.event == "Area") { var item = window.aqur.getCheckedOptionMA(event.data.value.options) if(item){ window.aqur.setArea(item) window.aqur.save("Area", item) }else{ window.aqur.setArea("") window.aqur.save("Area", "") } } if (event.data.event == "FloorPlan") { var item = window.aqur.getCheckedOptionMA(event.data.value.options) if(item){ window.aqur.setFloorPlan(item) window.aqur.save("FloorPlan", item) }else{ window.aqur.setFloorPlan("") window.aqur.save("FloorPlan", "") } } if (event.data.event == "FloorArea") { var item = window.aqur.getCheckedOptionMA(event.data.value.options) if(item){ window.aqur.setFloorArea(item) window.aqur.save("FloorArea", item) }else{ window.aqur.setFloorArea("") window.aqur.save("FloorArea", "") } } if (event.data.event == "Budget") { var item = window.aqur.getCheckedOptionSA(event.data.value.options) if(item){ window.aqur.setBudget(item.value) window.aqur.save("Budget", item.value) } } if (event.data.event == "Budget1") { var item = window.aqur.getCheckedOptionSA(event.data.value.options) if(item){ window.aqur.setBudgetOne(item.value) window.aqur.save("BudgetOne", item.value) } } if (event.data.event == "Season") { var item = window.aqur.getCheckedOptionSA(event.data.value.options) if(item){ window.aqur.setSeason(item.value) window.aqur.save("Season", item.value) }else{ window.aqur.setSeason("") window.aqur.save("Season", "") } } if (event.data.event == "email") { if(event.data.value.values[0].value){ window.aqur.setEmail(event.data.value.values[0].value) window.aqur.save("Email", event.data.value.values[0].value) }else{ window.aqur.setEmail("") window.aqur.save("Email", "") } } if (event.data.event == "tel") { if(event.data.value.values[0].value){ window.aqur.setTel(event.data.value.values[0].value) window.aqur.save("Tel", event.data.value.values[0].value) }else{ window.aqur.setTel("") window.aqur.save("Tel", "") } } if (event.data.event == "name") { var fullName = event.data.value.values[0].value + event.data.value.values[1].value if(fullName){ window.aqur.setFullName(fullName) window.aqur.save("FullName", fullName) }else{ window.aqur.setFullName("") window.aqur.save("FullName", "") } var fullNameKana = event.data.value.values[2].value + event.data.value.values[3].value if(fullNameKana){ window.aqur.setFullNameKana(fullNameKana) window.aqur.save("FullNameKana", fullNameKana) }else{ window.aqur.setFullNameKana("") window.aqur.save("FullNameKana", "") } } if (event.data.event == "RailwayLine") { if(event.data.value.values[0].value){ window.aqur.setRailwayLine(event.data.value.values[0].value) window.aqur.save("RailwayLine", event.data.value.values[0].value) }else{ window.aqur.setRailwayLine("") window.aqur.save("RailwayLine", "") } } if (event.data.event == "YourHome") { if(event.data.value.values[0].value){ window.aqur.setYourHome(event.data.value.values[0].value) window.aqur.save("YourHome", event.data.value.values[0].value) }else{ window.aqur.setYourHome("") window.aqur.save("YourHome", "") } } if (event.data.event == "memo") { if(event.data.value.values[0].value){ window.aqur.setMemo(event.data.value.values[0].value) window.aqur.save("Memo", event.data.value.values[0].value) }else{ window.aqur.setMemo("") window.aqur.save("Memo", "") } } } window.aqur.setTrack = (value) => { window.aqur.debug && console.log("debug setTrack"); localStorage.setItem('chatform', JSON.stringify(value)); } window.aqur.setPropertyType = (value) => { window.aqur.debug && console.log("debug setPropertyType", value); if(value!=undefined && window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setPropertyType",value:value}, "*"); } } window.aqur.setArea = (value) => { window.aqur.debug && console.log("debug setArea", value); if(value!=undefined && window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setArea",value:value}, "*"); } } window.aqur.setFloorPlan = (value) => { window.aqur.debug && console.log("debug setFloorPlan", value); if(value!=undefined && window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setFloorPlan",value:value}, "*"); } } window.aqur.setFloorArea = (value) => { window.aqur.debug && console.log("debug setFloorArea", value); if(value!=undefined && window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setFloorArea",value:value}, "*"); } } window.aqur.setBudget = (value) => { window.aqur.debug && console.log("debug setBudget", value); if(value!=undefined && window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setBudget",value:value}, "*"); } } window.aqur.setBudgetOne = (value) => { window.aqur.debug && console.log("debug setBudgetOne", value); if(value!=undefined && window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setBudgetOne",value:value}, "*"); } } window.aqur.setSeason = (value) => { window.aqur.debug && console.log("debug setSeason", value); if(value!=undefined && window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setSeason",value:value}, "*"); } } window.aqur.setFullName = (value) => { window.aqur.debug && console.log("debug setFullName", value); if(window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setFullName",value:value}, "*"); } } window.aqur.setFullNameKana = (value) => { window.aqur.debug && console.log("debug setFullNameKana", value); if(window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setFullNameKana",value:value}, "*"); } } window.aqur.setEmail = (value) => { window.aqur.debug && console.log("debug setEmail", value); if(window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setEmail",value:value}, "*"); } } window.aqur.setTel = (value) => { window.aqur.debug && console.log("debug setTel", value); if(window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setTel",value:value}, "*"); } } window.aqur.setRailwayLine = (value) => { window.aqur.debug && console.log("debug setRailwayLine", value); if(window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setRailwayLine",value:value}, "*"); } } window.aqur.setYourHome = (value) => { window.aqur.debug && console.log("debug setYourHome", value); if(window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setYourHome",value:value}, "*"); } } window.aqur.setMemo = (value) => { window.aqur.debug && console.log("debug setMemo", value); if(window.aqur.vframe){ window.aqur.vframe.contentWindow.postMessage({ event: "setMemo",value:value}, "*"); } } //Helper Method window.aqur.getCheckedOptionSA = (options) => { var rtn = options.find((v) => v.checked) return rtn } window.aqur.getCheckedOptionMA = (options) => { return options .filter((v) => v.checked) .map((v) => v.value) .join(", "); } } }())