(function() { //DDP var take = async function() { const BASE_URL = "https://blc.aqur.com"; const fetchOptions = { method: "POST", headers: { "Content-Type": "application/json" } }; const chatform = localStorage.getItem("chatform"); if (/reserve-fix/.test(window.location.pathname)) { document.addEventListener("DOMContentLoaded", () => { // 都道府県の情報を取得 const prefectureSelect = document.getElementById('prefectureSelect'); const prefectureOptions = Array.from(prefectureSelect.options).map(option => ({ value: option.value, text: option.textContent })).filter(option => option.value !== ''); // 空のオプションを除外 const stationData = document.querySelectorAll('.station-select-block .prefecture-block button'); const prefectureData = {}; document.querySelectorAll('.prefecture-block').forEach(prefBlock => { const prefectureName = prefBlock.getAttribute('data-station'); const stations = []; prefBlock.querySelectorAll('.station-block').forEach(button => { stations.push({ name: button.textContent.trim(), clinicId: button.getAttribute('data-clinicid'), metakey: button.getAttribute('data-metakey') }); }); prefectureData[prefectureName] = stations; }); const stationDataArray = Array.from(stationData).map(button => ({ name: button.textContent.trim(), clinicId: button.getAttribute('data-clinicid'), metakey: button.getAttribute('data-metakey') })); var param = { event: "stationData", prefectureData: prefectureData, stationData: stationDataArray, prefectureOptions: prefectureOptions }; window.parent.postMessage(param, "*"); window.addEventListener('message', (event) => { if (event.data.event === 'getstationData') { var param = { event: "stationData", prefectureData: prefectureData, stationData: stationDataArray, prefectureOptions: prefectureOptions }; window.parent.postMessage(param, "*"); } }); }) } if (chatform) { if (/reserve-done-fix/.test(window.location.pathname)) { async function complete(data) { try { const orderId = new URLSearchParams(window.location.search).get('rid'); if (orderId) { const completeTarget = JSON.parse(data); await fetch(`${BASE_URL}/pdi/complete`, { ...fetchOptions, body: JSON.stringify({ pid: completeTarget.pid, sid: completeTarget.sid, uuId: completeTarget.uuId }) }); localStorage.removeItem("chatform"); } } catch (error) { console.error('Error:', error); } } complete(chatform); } } } setTimeout(take, 0); }())