(function() { var take = function() { window.AqurBaseURL = 'https://pr.aqur.com'; window.addEventListener("chatform_initialized", async (event) => { createAqurBinding() const BASE_URL = "https://pr.aqur.com"; const fetchOptions = { method: "POST", headers: { "Content-Type": "application/json" } }; const chatform = localStorage.getItem("chatform"); const alertBox = document.getElementById('alert-box'); if (chatform && alertBox) { async function sendError(trackingData) { let chatformData = JSON.parse(chatform); const response2 = await fetch(`${BASE_URL}/pdi/${chatformData.uuId}`); const data2 = await response2.json(); data2.data.Completed = false; data2.data.status = "Fail"; data2.data.Message = alertBox.textContent.trim(); await fetch(`${BASE_URL}/pdi/set`, { ...fetchOptions, body: JSON.stringify(data2.data) }); } sendError(chatform); } }) function render(template, data) { return template.replace(/{{(.*?)}}/g, (match) => { return data[match.split(/{{|}}/).filter(Boolean)[0].trim()] }) } function activateChatformWidget() { //console.log("working 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 = "inlp"; 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', "e1b370de-30ac-4abe-bd67-406976540398"); REF.searchParams.append('launch', launch); 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.144.31.44"); 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") { //console.log("working 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) } if(window.aqur){ 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.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) { // let fullZip = event.data.value.values[0].value.replace(/-/g, ''); // let Pref = event.data.value.values[1].value // let City = event.data.value.values[2].value // let Street = event.data.value.values[3].value // let Building = event.data.value.values[4].value // if (fullZip.length === 7) { // let formZip = document.querySelector('[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerZip"]').value // // let formZip = formzip1.toString() + formzip2.toString() // if (fullZip !== formZip) { //console.log("bind zip") // window.aqur.setPostalCode(fullZip) // window.aqur.save("PostalCode", Pref) // } // } // window.aqur.setPref(Pref) // window.aqur.setCity(City) // window.aqur.setStreet(Street) // window.aqur.setBuilding(Building) // window.aqur.save("Pref", Pref) // window.aqur.save("City", City) // window.aqur.save("Street", Street) // window.aqur.save("Building", Building) // 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 == "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 == "tel") { window.aqur.setTel(event.data.value.values[0].value) window.aqur.save("Tel", 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 (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 == "payment") { var item = window.aqur.getCheckedOptionSA(event.data.value.options) if (item) { window.aqur.setPaymentMethodTypeKey(item.label) window.aqur.save("Payment", item.value) } } if (event.data.event == "cc") { console.log("debug ", event.data.value.values) window.aqur.setCardNumber(event.data.value.values[0].value) window.aqur.setCardHolderName(event.data.value.values[4].value) window.aqur.setCardExpirationYear(event.data.value.values[1].value) window.aqur.setCardExpirationMonth(event.data.value.values[2].value) window.aqur.setCVC(event.data.value.values[3].value) window.aqur.save("CardNumber", event.data.value.values[0].value) window.aqur.save("CardHolderName", event.data.value.values[4].value) window.aqur.save("CardExpirationYear", event.data.value.values[1].value) window.aqur.save("CardExpirationMonth", event.data.value.values[2].value) window.aqur.save("CardCVC", event.data.value.values[3].value) } } //Binding Method for ECForce //お名前(姓) window.aqur.setLastName = (value) => { window.aqur.debug && console.log("debug setLastName", value); window.aqur.fillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerName1"]', value) } //お名前(名) window.aqur.setFirstName = (value) => { window.aqur.debug && console.log("debug setFirstName", value); window.aqur.fillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerName2"]', value) } //お名前(姓 kana) window.aqur.setLastNameKana = (value) => { window.aqur.debug && console.log("debug setLastNameKana", value); window.aqur.fillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerNameKana1"]', value) } //お名前(名 kana) window.aqur.setFirstNameKana = (value) => { window.aqur.debug && console.log("debug setFirstNameKana", value); window.aqur.fillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerNameKana2"]', value) } //郵便番号 window.aqur.setPostalCode = (value) => { window.aqur.debug && console.log("debug setPostalCode", value); window.aqur.keyBoradFillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerZip"]', value) function callLater() { window.aqur.setCity(window.aqur.City) window.aqur.setStreet(window.aqur.Street) window.aqur.setBuilding(window.aqur.Building) } setTimeout(callLater, 2000); } //都道府県 window.aqur.setPref = (value) => { window.aqur.debug && console.log("debug setPref", value); //window.aqur.chooseSelectBoxLabel('select[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$ddlOwnerAddr1"]', value) } //市郡区/町・村 window.aqur.setCity = (value) => { window.aqur.debug && console.log("debug setCity", value); window.aqur.fillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerAddr2"]', value) } //丁目・番地・建物名・号室 window.aqur.setStreet = (value) => { window.aqur.debug && console.log("debug setStreet", value); window.aqur.fillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerAddr3"]', window.aqur.convertToHalfWidth(value)) } window.aqur.setBuilding = (value) => { window.aqur.debug && console.log("debug setBuilding", value); // const building = document.querySelector('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerAddr4"]') window.aqur.fillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerAddr4"]', window.aqur.convertToHalfWidth(value)) } window.aqur.setBirthdayYear = (value) => { window.aqur.debug && console.log("debug setBirthdayYear", value); window.aqur.chooseSelectBox('select[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$ddlOwnerBirthYear"]', value) } window.aqur.setBirthdayMonth = (value) => { window.aqur.debug && console.log("debug setBirthdayMonth", value); window.aqur.chooseSelectBox('select[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$ddlOwnerBirthMonth"]', value) } window.aqur.setBirthdayDay = (value) => { window.aqur.debug && console.log("debug setBirthdayDay", value); window.aqur.chooseSelectBox('select[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$ddlOwnerBirthDay"]', value) } window.aqur.setGender = (value) => { window.aqur.debug && console.log("debug setGender", value); if(value == "OTHER") value = "UNKNOWN" window.aqur.chooseRadioButton('[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$rblOwnerSex"]', value) } //電話番号 window.aqur.setTel = (value) => { window.aqur.debug && console.log("debug setTel", value); window.aqur.fillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerTel1"]', value) } //メールアドレス window.aqur.setEmail = (value) => { window.aqur.debug && console.log("debug setEmail", value); window.aqur.fillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbOwnerMailAddr"]', value) } window.aqur.setPassword = (value) => { window.aqur.debug && console.log("debug Password", value); window.aqur.fillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$tbUserPassword"]', value) } //お支払い方法選択 window.aqur.setPaymentMethodTypeKey = (value) => { window.aqur.debug && console.log("debug setPaymentMethodTypeKey", value); let paymentMethod = "" if(/NP後払い/.test(value)) { paymentMethod = "NP後払い(コンビニ・郵便局払い)" window.aqur.chooseRadioButtonByLabel('[for="ctl00_ContentPlaceHolder1_ucInputForm_rCartList_ctl01_rPayment_ctl01_rbgPayment"]', paymentMethod) } else if(/クレジットカード/.test(value)) { paymentMethod = "クレジットカード" window.aqur.chooseRadioButtonByLabel('[for="ctl00_ContentPlaceHolder1_ucInputForm_rCartList_ctl01_rPayment_ctl00_rbgPayment"]', paymentMethod) } } //クレジットカード番号 window.aqur.setCardNumber = (value) => { window.aqur.debug && console.log("debug setCardNumber", value); window.aqur.iframeFillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$rPayment$ctl00$tbCreditCardNo1"]', value) if(value.length == 14 || value.length == 15 || value.length == 16){ window.aqur.chooseSelectBoxLabel('select#creditCardCompany', window.aqur.getCardType(value)) } } //クレジットカード名 window.aqur.setCardHolderName = (value) => { window.aqur.debug && console.log("debug setCardHolderName", value); window.aqur.iframeFillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$rPayment$ctl00$tbCreditAuthorName"]', value) } //カードの有効期限(年) window.aqur.setCardExpirationYear = (value) => { window.aqur.debug && console.log("debug setCardExpirationYear", value); window.aqur.chooseSelectBoxLabel('select[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$rPayment$ctl00$ddlCreditExpireYear"]', value) } //カードの有効期限(月) window.aqur.setCardExpirationMonth = (value) => { window.aqur.debug && console.log("debug setCardExpirationMonth", value); window.aqur.chooseSelectBoxLabel('select[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$rPayment$ctl00$ddlCreditExpireMonth"]', (Number(value) < 10 ? 0 + value.toString() : value)) } window.aqur.setCVC = (value) => { window.aqur.debug && console.log("debug setCardCVC", value); window.aqur.iframeFillInput('input[name="ctl00$ContentPlaceHolder1$ucInputForm$rCartList$ctl01$rPayment$ctl00$tbCreditSecurityCode"]', value) } //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.getCardType = (cardNumber) => { const cleanedNumber = cardNumber.replace(/\D/g, ''); if (/^4/.test(cleanedNumber)) { return "VISA"; } else if (/^35/.test(cleanedNumber)) { return "JCB"; } else if (/^5/.test(cleanedNumber)) { return "Mastercard"; } else if (/^36/.test(cleanedNumber)) { return "Diners"; } else if (/^34|^37/.test(cleanedNumber)) { return "AMEX"; } else { return "その他"; // Default case if no match } } 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.keyBoradFillInput = (selector, value) => { let focusEvent = new Event('focus', { bubbles: true, composed: true }); let blurEvent = new Event('blur', { bubbles: true, composed: true }); let changeEvent = new Event('change', { bubbles: true, composed: true }); let keyDownEvent = new KeyboardEvent('keydown', { key: 'Enter', code: 'Enter', bubbles: true, cancelable: true }); let keyUpEvent = new KeyboardEvent('keyup', { key: 'Enter', code: 'Enter', bubbles: true, cancelable: true }); const inputElement = document.querySelector(selector); if (inputElement) { inputElement.dispatchEvent(focusEvent); // Focus the input inputElement.value = value; // Set the value inputElement.dispatchEvent(changeEvent); // Trigger change event inputElement.dispatchEvent(keyDownEvent); // Simulate keydown inputElement.dispatchEvent(keyUpEvent); // Simulate keyup inputElement.dispatchEvent(blurEvent); // Blur the input } }; 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.iframeFillInput = (selector, value) => { let inputEvent = new KeyboardEvent('keydown', { key: 'Enter', code: 'Enter', bubbles: true, cancelable: true }); var iframe = document.getElementById('ureru_creditcard_iframe'); var iDocument; if (iframe) iDocument = iframe.contentDocument || iframe.contentWindow.document; else iDocument = document; const inputElement = iDocument.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.chooseRadioButtonByLabel = (radioLabelSelector, label) => { const labelElements = document.querySelectorAll(radioLabelSelector); for (const labelElement of labelElements) { if (labelElement.textContent.trim() === label) { if (labelElement) { labelElement.click(); return; } } } // If no matching label or radio button is found, you can handle it here console.warn(`No radio button found with label: "${label}"`); }; 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 } }()) const findValue =(d,n)=>{ //console.log(d,n) let value=""; var rtn = value; for(var i=0; i < d.length; i++){ var item = d[i]; if(item.values){ item.values.forEach(function(v) { //console.log(v.name, n) if(v.name==n){ //console.log(n, v.name, reg.test(v.name)) rtn = v.value } }) } } return rtn } function bindandSubmit(data){ //console.log("d=>",data) let Zip = findValue(data, "Zip").toString() let Prefecture = findValue(data, "Prefecture") let City = findValue(data, "City") let Street1 = findValue(data, "Street") let Street2 = findValue(data, "Building") let password = findValue(data, "Password") // console.log(Zip, Prefecture, City, Street1, Street2) window.aqur.setPostalCode(Zip.replace(/-/g, '')) function callLater() { window.aqur.setPref(Prefecture) window.aqur.setCity(City) window.aqur.setStreet(Street1) window.aqur.setBuilding(Street2) } setTimeout(callLater, 2000); // 申し込み確認ボタン if (document.querySelector('#ctl00_ContentPlaceHolder1_ucInputForm_UpdatePanel1 [href*="javascript:doPostbackEvenIfCardAuthFailed=false;"]') !== null) { const submit = () => { window.aqur.setPassword(password) document.querySelector('#ctl00_ContentPlaceHolder1_ucInputForm_UpdatePanel1 [href*="javascript:doPostbackEvenIfCardAuthFailed=false;"]').click() } setTimeout(submit, 3500) } } 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); } function getFormatPhone($INPUT, $STRICT) { $STRICT = $STRICT || false; // 市外局番のグループ定義 // データは http://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/number_shitei.html より入手後、整形 var group = { 5: { "01267": 1, "01372": 1, "01374": 1, "01377": 1, "01392": 1, "01397": 1, "01398": 1, "01456": 1, "01457": 1, "01466": 1, "01547": 1, "01558": 1, "01564": 1, "01586": 1, "01587": 1, "01632": 1, "01634": 1, "01635": 1, "01648": 1, "01654": 1, "01655": 1, "01656": 1, "01658": 1, "04992": 1, "04994": 1, "04996": 1, "04998": 1, "05769": 1, "05979": 1, "07468": 1, "08387": 1, "08388": 1, "08396": 1, "08477": 1, "08512": 1, "08514": 1, "09496": 1, "09802": 1, "09912": 1, "09913": 1, "09969": 1, }, 4: { "0123": 2, "0124": 2, "0125": 2, "0126": 2, "0133": 2, "0134": 2, "0135": 2, "0136": 2, "0137": 2, "0138": 2, "0139": 2, "0142": 2, "0143": 2, "0144": 2, "0145": 2, "0146": 2, "0152": 2, "0153": 2, "0154": 2, "0155": 2, "0156": 2, "0157": 2, "0158": 2, "0162": 2, "0163": 2, "0164": 2, "0165": 2, "0166": 2, "0167": 2, "0172": 2, "0173": 2, "0174": 2, "0175": 2, "0176": 2, "0178": 2, "0179": 2, "0182": 2, "0183": 2, "0184": 2, "0185": 2, "0186": 2, "0187": 2, "0191": 2, "0192": 2, "0193": 2, "0194": 2, "0195": 2, "0197": 2, "0198": 2, "0220": 2, "0223": 2, "0224": 2, "0225": 2, "0226": 2, "0228": 2, "0229": 2, "0233": 2, "0234": 2, "0235": 2, "0237": 2, "0238": 2, "0240": 2, "0241": 2, "0242": 2, "0243": 2, "0244": 2, "0246": 2, "0247": 2, "0248": 2, "0250": 2, "0254": 2, "0255": 2, "0256": 2, "0257": 2, "0258": 2, "0259": 2, "0260": 2, "0261": 2, "0263": 2, "0264": 2, "0265": 2, "0266": 2, "0267": 2, "0268": 2, "0269": 2, "0270": 2, "0274": 2, "0276": 2, "0277": 2, "0278": 2, "0279": 2, "0280": 2, "0282": 2, "0283": 2, "0284": 2, "0285": 2, "0287": 2, "0288": 2, "0289": 2, "0291": 2, "0293": 2, "0294": 2, "0295": 2, "0296": 2, "0297": 2, "0299": 2, "0422": 2, "0428": 2, "0436": 2, "0438": 2, "0439": 2, "0460": 2, "0463": 2, "0465": 2, "0466": 2, "0467": 2, "0470": 2, "0475": 2, "0476": 2, "0478": 2, "0479": 2, "0480": 2, "0493": 2, "0494": 2, "0495": 2, "0531": 2, "0532": 2, "0533": 2, "0536": 2, "0537": 2, "0538": 2, "0539": 2, "0544": 2, "0545": 2, "0547": 2, "0548": 2, "0550": 2, "0551": 2, "0553": 2, "0554": 2, "0555": 2, "0556": 2, "0557": 2, "0558": 2, "0561": 2, "0562": 2, "0563": 2, "0564": 2, "0565": 2, "0566": 2, "0567": 2, "0568": 2, "0569": 2, "0572": 2, "0573": 2, "0574": 2, "0575": 2, "0576": 2, "0577": 2, "0578": 2, "0581": 2, "0584": 2, "0585": 2, "0586": 2, "0587": 2, "0594": 2, "0595": 2, "0596": 2, "0597": 2, "0598": 2, "0599": 2, "0721": 2, "0725": 2, "0735": 2, "0736": 2, "0737": 2, "0738": 2, "0739": 2, "0740": 2, "0742": 2, "0743": 2, "0744": 2, "0745": 2, "0746": 2, "0747": 2, "0748": 2, "0749": 2, "0761": 2, "0763": 2, "0765": 2, "0766": 2, "0767": 2, "0768": 2, "0770": 2, "0771": 2, "0772": 2, "0773": 2, "0774": 2, "0776": 2, "0778": 2, "0779": 2, "0790": 2, "0791": 2, "0794": 2, "0795": 2, "0796": 2, "0797": 2, "0798": 2, "0799": 2, "0820": 2, "0823": 2, "0824": 2, "0826": 2, "0827": 2, "0829": 2, "0833": 2, "0834": 2, "0835": 2, "0836": 2, "0837": 2, "0838": 2, "0845": 2, "0846": 2, "0847": 2, "0848": 2, "0852": 2, "0853": 2, "0854": 2, "0855": 2, "0856": 2, "0857": 2, "0858": 2, "0859": 2, "0863": 2, "0865": 2, "0866": 2, "0867": 2, "0868": 2, "0869": 2, "0875": 2, "0877": 2, "0879": 2, "0880": 2, "0883": 2, "0884": 2, "0885": 2, "0887": 2, "0889": 2, "0892": 2, "0893": 2, "0894": 2, "0895": 2, "0896": 2, "0897": 2, "0898": 2, "0920": 2, "0930": 2, "0940": 2, "0942": 2, "0943": 2, "0944": 2, "0946": 2, "0947": 2, "0948": 2, "0949": 2, "0950": 2, "0952": 2, "0954": 2, "0955": 2, "0956": 2, "0957": 2, "0959": 2, "0964": 2, "0965": 2, "0966": 2, "0967": 2, "0968": 2, "0969": 2, "0972": 2, "0973": 2, "0974": 2, "0977": 2, "0978": 2, "0979": 2, "0980": 2, "0982": 2, "0983": 2, "0984": 2, "0985": 2, "0986": 2, "0987": 2, "0993": 2, "0994": 2, "0995": 2, "0996": 2, "0997": 2, "0180": 3, "0570": 3, "0800": 3, "0990": 3, "0120": 3, }, 3: { "011": 3, "015": 3, "017": 3, "018": 3, "019": 3, "022": 3, "023": 3, "024": 3, "025": 3, "026": 3, "027": 3, "028": 3, "029": 3, "042": 3, "043": 3, "044": 3, "045": 3, "046": 3, "047": 3, "048": 3, "049": 3, "052": 3, "053": 3, "054": 3, "055": 3, "058": 3, "059": 3, "072": 3, "073": 3, "075": 3, "076": 3, "077": 3, "078": 3, "079": 3, "082": 3, "083": 3, "084": 3, "086": 3, "087": 3, "088": 3, "089": 3, "092": 3, "093": 3, "095": 3, "096": 3, "097": 3, "098": 3, "099": 3, "050": 4, "020": $STRICT ? 3 : 4, "070": $STRICT ? 3 : 4, "080": $STRICT ? 3 : 4, "090": $STRICT ? 3 : 4, "060": $STRICT ? 3 : 4, }, 2: { "03": 4, "04": 4, "06": 4, } }; // 市外局番の桁数を取得して降順に並べ替える var code = []; for (num in group) { code.push(num * 1); } code.sort(function ($a, $b) { return ($b - $a); }); // 入力文字から数字以外を削除してnumber変数に格納する var number = String($INPUT).replace(/[0-9]/g, function ($s) { return String.fromCharCode($s.charCodeAt(0) - 65248); }).replace(/\D/g, ""); // 電話番号が10~11桁じゃなかったらfalseを返して終了する if (number.length < 10 || number.length > 11) { return false; } // 市外局番がどのグループに属するか確認していく for (var i = 0, n = code.length; i < n; i++) { var leng = code[i]; var area = number.substring(0, leng); var city = group[leng][area]; // 一致する市外局番を見付けたら整形して整形後の電話番号を返す if (city) { var first = area; var middle = number.substring(first.length, first.length + city); var last = number.substring(first.length + city, number.length); return [first, middle, last] } } };