- JS 논리 오류 수정: gallery.js lightbox 초기화 타이밍, 터치 리스너 누적, IntersectionObserver 통합 - XSS 방지: qna.js showNoResults innerHTML → textContent, 정규식 이스케이프 추가 - 안전성 개선: popup.js ESC 가드, portfolio.js getIframe optional chaining, backgrounds/props null 가드 - 이미지 최적화: 스튜디오 12장 WebP 압축 (4.0MB → 2.2MB, 46% 감소) - 360 이미지: git 히스토리에서 원본 복구 후 4096×2048 리사이즈 (해상도 4.6배 향상) - 360 뷰어: image-rendering auto 전환, naturalWidth/Height 기반 렌더링으로 품질 개선 - 크리에이터 사인 추가: 얌하 (3.3KB), 구슬요 (5.9KB) WebP 변환 및 마키 삽입 - 불필요 코드 제거: gallery.js 미사용 함수 6개 삭제 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
98 lines
2.8 KiB
JavaScript
98 lines
2.8 KiB
JavaScript
/**
|
|
* 밍글 스튜디오 메인 팝업 관리
|
|
*/
|
|
|
|
// 쿠키 관련 함수
|
|
function setCookie(name, value, days) {
|
|
const date = new Date();
|
|
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
const expires = "expires=" + date.toUTCString();
|
|
document.cookie = name + "=" + value + ";" + expires + ";path=/";
|
|
}
|
|
|
|
function getCookie(name) {
|
|
const nameEQ = name + "=";
|
|
const ca = document.cookie.split(';');
|
|
for(let i = 0; i < ca.length; i++) {
|
|
let c = ca[i];
|
|
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// 팝업 표시 함수
|
|
function showPopup() {
|
|
const popup = document.getElementById('mainPopup');
|
|
if (popup) {
|
|
popup.classList.add('active');
|
|
document.body.style.overflow = 'hidden'; // 스크롤 방지
|
|
}
|
|
}
|
|
|
|
// 팝업 닫기 함수
|
|
function closePopup() {
|
|
const popup = document.getElementById('mainPopup');
|
|
const dontShowToday = document.getElementById('dontShowToday');
|
|
|
|
if (popup) {
|
|
popup.classList.remove('active');
|
|
document.body.style.overflow = ''; // 스크롤 복원
|
|
|
|
// "하루동안 보지 않기" 체크된 경우
|
|
if (dontShowToday && dontShowToday.checked) {
|
|
setCookie('hideMainPopup', 'true', 1); // 1일간 쿠키 저장
|
|
}
|
|
}
|
|
}
|
|
|
|
// 페이지 로드 시 실행
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// 쿠키 확인
|
|
const hidePopup = getCookie('hideMainPopup');
|
|
|
|
// 쿠키가 없으면 팝업 표시 (1초 후)
|
|
if (!hidePopup) {
|
|
setTimeout(showPopup, 1000);
|
|
}
|
|
|
|
// 닫기 버튼 이벤트
|
|
const closeBtn = document.getElementById('popupCloseBtn');
|
|
if (closeBtn) {
|
|
closeBtn.addEventListener('click', closePopup);
|
|
}
|
|
|
|
// X 버튼 이벤트
|
|
const closeX = document.getElementById('popupCloseX');
|
|
if (closeX) {
|
|
closeX.addEventListener('click', closePopup);
|
|
}
|
|
|
|
// 오버레이 클릭 시 닫기
|
|
const overlay = document.getElementById('mainPopup');
|
|
if (overlay) {
|
|
overlay.addEventListener('click', function(e) {
|
|
if (e.target === overlay) {
|
|
closePopup();
|
|
}
|
|
});
|
|
}
|
|
|
|
// ESC 키로 닫기
|
|
document.addEventListener('keydown', function(e) {
|
|
const popup = document.getElementById('mainPopup');
|
|
if (e.key === 'Escape' && popup && popup.classList.contains('active')) {
|
|
closePopup();
|
|
}
|
|
});
|
|
|
|
// CTA 버튼 클릭 시 연락처 페이지로 이동
|
|
const ctaBtn = document.getElementById('popupCtaBtn');
|
|
if (ctaBtn) {
|
|
ctaBtn.addEventListener('click', function() {
|
|
closePopup();
|
|
window.location.href = '/contact';
|
|
});
|
|
}
|
|
});
|