41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
document.addEventListener('DOMContentLoaded', () => {
|
|
document.querySelectorAll('.preview-btn').forEach(btn => {
|
|
btn.addEventListener('click', () => {
|
|
const base64 = btn.getAttribute('data-content');
|
|
const decodedHtml = atob(base64);
|
|
previewTemplate(decodedHtml);
|
|
});
|
|
});
|
|
});
|
|
|
|
function previewTemplate(htmlContent) {
|
|
const popup = window.open('', '미리보기', 'width=800,height=600,scrollbars=yes');
|
|
if (!popup) {
|
|
alert('팝업이 차단되었습니다. 브라우저의 팝업 차단을 해제하고 다시 시도해 주세요.');
|
|
return;
|
|
}
|
|
|
|
const popupContent = `
|
|
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>템플릿 미리보기</title>
|
|
<style>
|
|
body { font-family: sans-serif; padding: 20px; line-height: 1.6; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
${htmlContent}
|
|
</body>
|
|
</html>
|
|
`;
|
|
|
|
popup.document.write(popupContent);
|
|
popup.document.close();
|
|
}
|
|
|
|
|
|
|
|
|