(function() { var take = function() { console.log("OZ",chatform_initialized) //Inserted Start ! var vframe; var btnClass = ""; window.addEventListener("chatform_initialized", (event) => { //createVframe() const aqurBtn1 = document.querySelectorAll('a.aqurBtn1'); aqurBtn1.forEach((a)=>{ a.removeAttribute("href"); a.style.cursor = 'pointer'; //console.log("reomove href!") }) const aqurBtn2 = document.querySelectorAll('a.aqurBtn2'); aqurBtn2.forEach((a)=>{ a.removeAttribute("href"); a.style.cursor = 'pointer'; //console.log("reomove href!") }) }) function createVframe(btnClass){ var url = new URL(window.location.href); let userChatbot = url.searchParams.get('usechatbot') if(userChatbot){ return } // Check if the iframe already exists var existingVframe = document.getElementById("vframe"); // If the iframe already exists, remove it if(existingVframe) { existingVframe.parentNode.removeChild(existingVframe); } 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'); vframe.sandbox.add('allow-scripts'); vframe.sandbox.add('allow-same-origin'); vframe.width="1px"; vframe.height="1px"; var REF = "" if( btnClass == "oz1" ) { REF = new URL("https://www2.up-edu.com/ochazemi/forms/enter/pamphlet"); } else if ( btnClass == "oz2" ) { REF = new URL("https://www2.up-edu.com/ochazemi/forms/enter/handson"); } //var REF = new URL(window.location.href); REF.searchParams.append('usechatbot', "no"); vframe.src = REF; document.body.appendChild(vframe); vframe.addEventListener("load", (e) => { //console.log(e.target.src) var url = new URL(e.target.src) switch (url.origin) { case 'https://www.example.com': window.location.href= url.href break; default: } }) let vfmode = url.searchParams.get('vfmode') if(vfmode=="debug"){ const lpshoppingcolumn = document.querySelector('#lpshoppingcolumn, #smp-lpshoppingcolumn'); if(lpshoppingcolumn){ lpshoppingcolumn.style.display= "block"; } vframe.width="70%"; vframe.height="250px" 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.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }); var param={ event: "chatform_vframe_debug" } vframe.contentWindow.postMessage(param, "*"); } } //Inserted End //Default function render(template, data){ //console.log("render",template,data) return template.replace(/{{(.*?)}}/g, (match) => { return data[match.split(/{{|}}/).filter(Boolean)[0].trim()] }) } function activateChatformWidget(){ console.log("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 = "oz"; 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', "1382487b-f738-41e8-8882-d95cd243a01e"); 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.145.11.77"); 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.closest('.aqurBtn1') || event.target.classList.contains("aqurBtn1") || event.target.closest('.aqurBtn2') || event.target.classList.contains("aqurBtn2") || event.target.id == "chatform_widget_cancelbtn" ) { activateChatformWidget() } if(event.target.classList.contains("aqurBtn1")){ var param={ type: "chatform_shareParams", btnClass:"aqurBtn1" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); //vframe.contentWindow.postMessage(param, "*"); createVframe("oz1") btnClass = "aqurBtn1" } if(event.target.classList.contains("aqurBtn2")){ var param={ type: "chatform_shareParams", btnClass:"aqurBtn2" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); //vframe.contentWindow.postMessage(param, "*"); createVframe("oz2") btnClass = "aqurBtn2" } }); const as = document.querySelectorAll('.aqurBtn2'); as.forEach((a)=>{ a.removeAttribute("href") }) document.dispatchEvent(new CustomEvent("chatform_widget_creation_complete")); }; setTimeout(creationComplete, 0); window.addEventListener("message", (event) => { //console.log("event.data.event", 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); } /* Default Actions*/ if(event.data.event == "chatform_start"){ console.log(event.data.uuId) } 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("chatform_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_bind"){ //console.log("chatform_vframe_bind",event.data.project) var project = event.data.project; var param={ event: "chatform_bindForm", data:project, btnClass: btnClass } vframe.contentWindow.postMessage(param, "*"); } if(event.data.event == "chatform_vframe_submit"){ //console.log("chatform_vframe_submit") var data = event.data.project; var param={ event: "chatform_bindFormSubmit" } vframe.contentWindow.postMessage(param, "*"); } 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(event.data.event == "chatform_bindClick"){ //console.log("chatform_bindClick",event.data) document.getElementById(event.data.elementId).click(); } if(event.data.event == "chatform_bindCheck"){ //console.log("chatform_bindCheck",event.data) document.getElementById(event.data.elementId).click(); } },false) } setTimeout(take, 0); }())