알로메가 운세 분석
당신의 천시(天時)를 확인합니다
생년월일 및 달력 종류
출생 시간
공간의 기운
현재 머무는 지리(地理)를 파악합니다
거주 지역 선택
지천태 (泰)
기본 운세 요약
? 투자 리포트
알로메가 데이터 인사이트
실전 투자 가이드
지리적 궁합 (거주지 적합도)
80점
아생(我生)
(나의 기운: 목(木))
🪐 매크로 점성술 분석 (시장 사이클)
풍수 비보(裨補) 조언
오늘의 행운 아이템
// 날짜 드롭다운 초기화 const yearSelect = document.getElementById('birth_year'); const monthSelect = document.getElementById('birth_month'); const daySelect = document.getElementById('birth_day');
const currentYear = new Date().getFullYear(); for (let i = currentYear; i >= 1930; i--) { const opt = document.createElement('option'); opt.value = i; opt.innerText = i + '년'; yearSelect.appendChild(opt); } yearSelect.value = 1990;
for (let i = 1; i <= 12; i++) { const opt = document.createElement('option'); opt.value = i; opt.innerText = i + '월'; monthSelect.appendChild(opt); } monthSelect.value = 1; function updateDays() { const year = yearSelect.value; const month = monthSelect.value; const daysInMonth = new Date(year, month, 0).getDate(); const currentDay = daySelect.value; daySelect.innerHTML = ''; for (let i = 1; i <= daysInMonth; i++) { const opt = document.createElement('option'); opt.value = i; opt.innerText = i + '일'; daySelect.appendChild(opt); } if(currentDay <= daysInMonth) daySelect.value = currentDay || 1; } yearSelect.onchange = updateDays; monthSelect.onchange = updateDays; updateDays(); // 지역 데이터 let regions = {}; async function fetchRegions() { try { const response = await fetch('/astro_pick/regions'); regions = await response.json(); const lv1Select = document.getElementById('region_lv1'); lv1Select.innerHTML = ''; for (const lv1 in regions) { const opt = document.createElement('option'); opt.value = lv1; opt.innerText = lv1; lv1Select.appendChild(opt); } // Set default to 서울특별시 if it exists, else the first key if(regions['서울특별시']) { lv1Select.value = '서울특별시'; } else if(Object.keys(regions).length > 0) { lv1Select.value = Object.keys(regions)[0]; }
updateRegions(); } catch (e) { console.error('Failed to fetch regions:', e); } }
function updateRegions() { const lv1 = document.getElementById('region_lv1').value; const lv2Select = document.getElementById('region_lv2'); lv2Select.innerHTML = ''; (regions[lv1] || []).forEach(r => { const opt = document.createElement('option'); opt.value = r; opt.innerText = r; lv2Select.appendChild(opt); }); } fetchRegions();
function nextStep(n) { document.querySelectorAll('.step').forEach(s => s.classList.remove('active')); document.getElementById(`step-${n}`).classList.add('active'); window.scrollTo(0, 0); }
async function cast() { const year = yearSelect.value; const month = monthSelect.value.padStart(2, '0'); const day = daySelect.value.padStart(2, '0'); const birth_date = `${year}-${month}-${day}`; const birth_time = document.getElementById('birth_time').value; const region_lv1 = document.getElementById('region_lv1').value; const region_lv2 = document.getElementById('region_lv2').value; const calTypeSelect = document.getElementById('calendar_type').value;
const calendar_type = calTypeSelect === 'solar' ? 'solar' : 'lunar'; const is_leap = calTypeSelect === 'lunar_leap';
nextStep('loading');
const loadingMsg = document.getElementById('loading-msg'); const messages = ["천지의 기운을 모으고 있습니다...", "주역 괘를 분석 중입니다...", "풍수 지리를 살피는 중...", "당신의 운명을 해독합니다..."]; let msgIdx = 0; loadingMsg.innerText = messages[0]; const msgInterval = setInterval(() => { msgIdx = (msgIdx + 1) % messages.length; loadingMsg.style.opacity = 0; setTimeout(() => { loadingMsg.innerText = messages[msgIdx]; loadingMsg.style.opacity = 1; }, 200); }, 800);
const fetchPromise = fetch('/astro_pick/cast', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ birth_date, birth_time, region_lv1, region_lv2, calendar_type, is_leap }) }).then(res => res.json());
const minWaitPromise = new Promise(resolve => setTimeout(resolve, 2800));
try { const [data] = await Promise.all([fetchPromise, minWaitPromise]);
document.getElementById('hex-name').innerText = `${data.name_kr} (${data.name_cn})`; document.getElementById('hex-summary').innerText = data.summary; document.getElementById('user-zodiac-badge').innerText = `나의 별자리: ${data.user_zodiac}`; document.getElementById('display-age-kr').innerText = `${data.user_age_kr}세`; document.getElementById('display-age-intl').innerText = data.user_age_intl; document.getElementById('region-fs-info').innerText = `${data.region_fengshui.mountain}의 기운 (${data.region_fengshui.element})`; document.getElementById('tarot-name').innerText = data.tarot;
const tarotKeyword = data.tarot.split(' ')[0].replace(/[^a-zA-Z]/g, '').toLowerCase(); document.getElementById('tarot-image').src = `https://api.dicebear.com/7.x/identicon/svg?seed=${tarotKeyword}`;
const visuals = { "111111": "䷀", "000000": "䷁", "010001": "䷂", "100010": "䷃", "010111": "䷄", "111010": "䷅", "000010": "䷆", "010000": "䷇", "110111": "䷈", "111011": "䷉", "000111": "䷊", "111000": "䷋", "111101": "䷌", "101111": "䷍", "000100": "䷎", "001000": "䷏", "011001": "䷐", "100011": "䷑", "000011": "䷒", "110000": "䷓", "101001": "䷔", "100101": "䷕", "100000": "䷖", "000001": "䷗", "111001": "䷘", "100111": "䷙", "100001": "䷚", "011110": "䷛", "010010": "䷜", "101101": "䷝", "011100": "䷞", "001110": "䷟", "111100": "䷠", "001111": "䷡", "101000": "䷢", "000101": "䷣", "110101": "䷤", "101011": "䷥", "010100": "䷦", "001010": "䷧", "100011": "䷨", "110001": "䷩", "011111": "䷪", "111110": "䷫", "011000": "䷬", "000110": "䷭", "011010": "䷮", "010110": "䷯", "011101": "䷰", "101110": "䷱", "001001": "䷲", "100100": "䷳", "110100": "䷴", "001011": "䷵", "001101": "䷶", "101100": "䷷", "110110": "䷸", "011011": "䷹", "110010": "䷺", "010011": "䷻", "110011": "䷼", "001100": "䷽", "010101": "䷾", "101010": "䷿" }; document.getElementById('hex-visual').innerText = visuals[data.binary_code] || "䷊";
document.getElementById('hex-modern-interpretation').innerText = data.modern_interpretation; document.getElementById('fengshui-advice').innerText = data.region_fengshui.description; document.getElementById('lucky-color').innerText = data.region_fengshui.lucky_color; document.getElementById('lucky-item').innerText = data.region_fengshui.lucky_item; document.getElementById('lucky-direction').innerText = data.region_fengshui.lucky_direction;
// Compatibility logic update document.getElementById('comp-score').innerText = data.region_fengshui.compatibility_score + '점'; document.getElementById('comp-rel').innerText = data.region_fengshui.compatibility_rel; document.getElementById('comp-user-elem').innerText = data.region_fengshui.user_element; document.getElementById('comp-desc').innerText = data.region_fengshui.compatibility_desc; document.getElementById('astro-advice').innerText = data.region_fengshui.astrology_advice;
nextStep(3); } catch (err) { alert("분석 중 오류가 발생했습니다."); nextStep(2); } finally { clearInterval(msgInterval); } }
function shareResult() { // Extract elements safely const hexName = document.getElementById('hex-name').innerText; const modernInt = document.getElementById('hex-modern-interpretation').innerText; const compScore = document.getElementById('comp-score').innerText; const compRel = document.getElementById('comp-rel').innerText; const luckyColor = document.getElementById('lucky-color').innerText; const luckyItem = document.getElementById('lucky-item').innerText; const luckyDir = document.getElementById('lucky-direction').innerText; const regLv1 = document.getElementById('region_lv1').value; const regLv2 = document.getElementById('region_lv2').value;
// Build dynamic text const shareText = `[알로메가 천기누설] 투자/풍수 분석 결과 🔮\n\n` + `📊 괘상: ${hexName}\n` + `📈 투자 조언:\n${modernInt}\n\n` + `📍 ${regLv2} 궁합: ${compScore} (${compRel})\n` + `🍀 행운템: ${luckyItem} (${luckyColor})\n` + `🧭 행운 방향: ${luckyDir}\n\n` + `나의 명리·풍수 분석 알아보기 👇`;
const shareData = { title: '알로메가 천기누설 분석', text: shareText, url: 'https://www.alomega.org/fortune/' };
// Try native share API if (navigator.share) { navigator.share(shareData).catch(err => { console.error('Share failed:', err); }); } else { // Fallback to clipboard const clipboardText = `${shareData.text}\n${shareData.url}`; navigator.clipboard.writeText(clipboardText).then(() => { alert('운세 요약 결과와 링크가 클립보드에 복사되었습니다.\n카카오톡이나 SNS에 붙여넣기 하세요!'); }).catch(err => { alert('링크 복사에 실패했습니다.'); }); } }