640 lines
24 KiB
HTML
640 lines
24 KiB
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<html lang="ko">
|
||
|
|
<head>
|
||
|
|
<meta charset="UTF-8">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
|
<title>이종재 | Game & XR Developer</title>
|
||
|
|
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Noto+Sans+KR:wght@300;400;700&display=swap" rel="stylesheet">
|
||
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
||
|
|
<style>
|
||
|
|
:root {
|
||
|
|
--primary: #00f2ff;
|
||
|
|
--secondary: #7000ff;
|
||
|
|
--bg-dark: #0a0a0f;
|
||
|
|
--card-bg: #161625;
|
||
|
|
--text-white: #e2e8f0;
|
||
|
|
--text-dim: #94a3b8;
|
||
|
|
--danger: #ff4757;
|
||
|
|
}
|
||
|
|
|
||
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||
|
|
body {
|
||
|
|
font-family: 'Noto Sans KR', sans-serif;
|
||
|
|
background-color: var(--bg-dark);
|
||
|
|
color: var(--text-white);
|
||
|
|
line-height: 1.7;
|
||
|
|
overflow-x: hidden;
|
||
|
|
}
|
||
|
|
|
||
|
|
h1, h2, h3, .logo, .card-label { font-family: 'Orbitron', sans-serif; }
|
||
|
|
|
||
|
|
nav {
|
||
|
|
background: rgba(10, 10, 15, 0.95);
|
||
|
|
backdrop-filter: blur(10px);
|
||
|
|
padding: 1.2rem 8%;
|
||
|
|
display: flex;
|
||
|
|
justify-content: space-between;
|
||
|
|
align-items: center;
|
||
|
|
position: sticky;
|
||
|
|
top: 0;
|
||
|
|
z-index: 1000;
|
||
|
|
border-bottom: 1px solid rgba(0, 242, 255, 0.1);
|
||
|
|
}
|
||
|
|
nav .logo { font-weight: 700; font-size: 1.4rem; color: var(--primary); letter-spacing: 2px; }
|
||
|
|
nav .links { display: flex; align-items: center; gap: 2rem; }
|
||
|
|
nav .links a {
|
||
|
|
text-decoration: none;
|
||
|
|
color: var(--text-white);
|
||
|
|
font-size: 0.9rem;
|
||
|
|
transition: 0.3s;
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 6px;
|
||
|
|
}
|
||
|
|
nav .links a:hover { color: var(--primary); }
|
||
|
|
nav .links a.profile-link {
|
||
|
|
border: 1px solid var(--primary);
|
||
|
|
padding: 0.5rem 1rem;
|
||
|
|
border-radius: 6px;
|
||
|
|
}
|
||
|
|
nav .links a.profile-link:hover {
|
||
|
|
background: var(--primary);
|
||
|
|
color: #000;
|
||
|
|
}
|
||
|
|
|
||
|
|
header {
|
||
|
|
min-height: 60vh;
|
||
|
|
display: flex;
|
||
|
|
flex-direction: column;
|
||
|
|
justify-content: center;
|
||
|
|
align-items: center;
|
||
|
|
text-align: center;
|
||
|
|
padding: 80px 20px;
|
||
|
|
background:
|
||
|
|
radial-gradient(circle at 30% 50%, rgba(112, 0, 255, 0.15) 0%, transparent 50%),
|
||
|
|
radial-gradient(circle at 70% 50%, rgba(0, 242, 255, 0.1) 0%, transparent 50%);
|
||
|
|
border-bottom: 1px solid rgba(255,255,255,0.05);
|
||
|
|
}
|
||
|
|
header h1 {
|
||
|
|
font-size: 3.5rem;
|
||
|
|
margin-bottom: 1rem;
|
||
|
|
text-shadow: 0 0 30px rgba(0, 242, 255, 0.5);
|
||
|
|
letter-spacing: 2px;
|
||
|
|
}
|
||
|
|
header p { font-size: 1.2rem; color: var(--text-dim); max-width: 800px; padding: 0 20px; }
|
||
|
|
.highlight { color: var(--primary); }
|
||
|
|
|
||
|
|
main { padding: 80px 8%; }
|
||
|
|
.section-header { display: flex; align-items: center; gap: 20px; margin-bottom: 4rem; }
|
||
|
|
.section-header h2 { font-size: 2rem; letter-spacing: 1px; }
|
||
|
|
.line { flex-grow: 1; height: 1px; background: rgba(0, 242, 255, 0.2); }
|
||
|
|
|
||
|
|
.admin-controls {
|
||
|
|
display: flex;
|
||
|
|
gap: 10px;
|
||
|
|
}
|
||
|
|
.admin-controls.hidden { display: none; }
|
||
|
|
|
||
|
|
.btn {
|
||
|
|
padding: 0.6rem 1.2rem;
|
||
|
|
border-radius: 6px;
|
||
|
|
font-family: 'Orbitron', sans-serif;
|
||
|
|
font-size: 0.75rem;
|
||
|
|
letter-spacing: 1.5px;
|
||
|
|
cursor: pointer;
|
||
|
|
border: none;
|
||
|
|
transition: 0.3s;
|
||
|
|
display: inline-flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 8px;
|
||
|
|
}
|
||
|
|
.btn-primary { background: var(--primary); color: #000; font-weight: 700; }
|
||
|
|
.btn-primary:hover { background: #fff; transform: translateY(-2px); }
|
||
|
|
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
|
||
|
|
.btn-outline:hover { background: var(--primary); color: #000; }
|
||
|
|
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
|
||
|
|
.btn-danger:hover { background: var(--danger); color: #fff; }
|
||
|
|
|
||
|
|
.grid {
|
||
|
|
display: grid;
|
||
|
|
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
|
||
|
|
gap: 2.5rem;
|
||
|
|
}
|
||
|
|
|
||
|
|
.card {
|
||
|
|
background: var(--card-bg);
|
||
|
|
border-radius: 1.2rem;
|
||
|
|
overflow: hidden;
|
||
|
|
border: 1px solid rgba(255,255,255,0.05);
|
||
|
|
transition: 0.3s ease;
|
||
|
|
position: relative;
|
||
|
|
}
|
||
|
|
.card:hover { transform: translateY(-10px); border-color: var(--primary); box-shadow: 0 10px 40px rgba(0, 242, 255, 0.1); }
|
||
|
|
|
||
|
|
.card-img {
|
||
|
|
width: 100%;
|
||
|
|
height: 200px;
|
||
|
|
background: linear-gradient(135deg, #1e1e30 0%, #2a1a3e 100%);
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: center;
|
||
|
|
font-size: 3.5rem;
|
||
|
|
color: rgba(255,255,255,0.15);
|
||
|
|
background-size: cover;
|
||
|
|
background-position: center;
|
||
|
|
}
|
||
|
|
|
||
|
|
.card-content { padding: 1.8rem; }
|
||
|
|
.card-label {
|
||
|
|
color: var(--primary);
|
||
|
|
font-size: 0.7rem;
|
||
|
|
letter-spacing: 2px;
|
||
|
|
margin-bottom: 0.8rem;
|
||
|
|
display: block;
|
||
|
|
font-weight: 700;
|
||
|
|
}
|
||
|
|
.card h3 { font-size: 1.4rem; margin-bottom: 0.8rem; }
|
||
|
|
.card p { color: var(--text-dim); margin-bottom: 1.5rem; font-size: 0.95rem; }
|
||
|
|
|
||
|
|
.card-actions {
|
||
|
|
display: flex;
|
||
|
|
gap: 8px;
|
||
|
|
flex-wrap: wrap;
|
||
|
|
}
|
||
|
|
.card-actions.admin-mode {
|
||
|
|
border-top: 1px dashed rgba(255,255,255,0.1);
|
||
|
|
padding-top: 1rem;
|
||
|
|
margin-top: 1rem;
|
||
|
|
}
|
||
|
|
|
||
|
|
.btn-git {
|
||
|
|
display: inline-flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 8px;
|
||
|
|
text-decoration: none;
|
||
|
|
color: #000;
|
||
|
|
background: var(--primary);
|
||
|
|
padding: 0.7rem 1.2rem;
|
||
|
|
border-radius: 0.6rem;
|
||
|
|
font-weight: 700;
|
||
|
|
font-size: 0.85rem;
|
||
|
|
transition: 0.3s;
|
||
|
|
}
|
||
|
|
.btn-git:hover { background: white; }
|
||
|
|
|
||
|
|
.empty-state {
|
||
|
|
text-align: center;
|
||
|
|
padding: 60px 20px;
|
||
|
|
color: var(--text-dim);
|
||
|
|
}
|
||
|
|
.empty-state i { font-size: 3rem; opacity: 0.3; margin-bottom: 1rem; }
|
||
|
|
|
||
|
|
/* 모달 */
|
||
|
|
.modal-overlay {
|
||
|
|
display: none;
|
||
|
|
position: fixed;
|
||
|
|
top: 0; left: 0; right: 0; bottom: 0;
|
||
|
|
background: rgba(0, 0, 0, 0.8);
|
||
|
|
backdrop-filter: blur(8px);
|
||
|
|
z-index: 2000;
|
||
|
|
justify-content: center;
|
||
|
|
align-items: center;
|
||
|
|
padding: 20px;
|
||
|
|
}
|
||
|
|
.modal-overlay.active { display: flex; }
|
||
|
|
.modal {
|
||
|
|
background: var(--card-bg);
|
||
|
|
border: 1px solid rgba(0, 242, 255, 0.3);
|
||
|
|
border-radius: 1rem;
|
||
|
|
padding: 2rem;
|
||
|
|
max-width: 550px;
|
||
|
|
width: 100%;
|
||
|
|
max-height: 90vh;
|
||
|
|
overflow-y: auto;
|
||
|
|
}
|
||
|
|
.modal h2 {
|
||
|
|
color: var(--primary);
|
||
|
|
margin-bottom: 1.5rem;
|
||
|
|
font-size: 1.4rem;
|
||
|
|
letter-spacing: 1px;
|
||
|
|
}
|
||
|
|
.form-group { margin-bottom: 1.2rem; }
|
||
|
|
.form-group label {
|
||
|
|
display: block;
|
||
|
|
margin-bottom: 6px;
|
||
|
|
font-size: 0.85rem;
|
||
|
|
color: var(--text-dim);
|
||
|
|
font-family: 'Orbitron', sans-serif;
|
||
|
|
letter-spacing: 1px;
|
||
|
|
}
|
||
|
|
.form-group input, .form-group textarea, .form-group select {
|
||
|
|
width: 100%;
|
||
|
|
padding: 12px;
|
||
|
|
background: #0a0a0f;
|
||
|
|
border: 1px solid rgba(255,255,255,0.1);
|
||
|
|
border-radius: 6px;
|
||
|
|
color: var(--text-white);
|
||
|
|
font-family: 'Noto Sans KR', sans-serif;
|
||
|
|
font-size: 0.95rem;
|
||
|
|
transition: 0.3s;
|
||
|
|
}
|
||
|
|
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
|
||
|
|
outline: none;
|
||
|
|
border-color: var(--primary);
|
||
|
|
box-shadow: 0 0 0 3px rgba(0, 242, 255, 0.1);
|
||
|
|
}
|
||
|
|
.form-group textarea { min-height: 100px; resize: vertical; }
|
||
|
|
.modal-actions {
|
||
|
|
display: flex;
|
||
|
|
gap: 10px;
|
||
|
|
justify-content: flex-end;
|
||
|
|
margin-top: 1.5rem;
|
||
|
|
}
|
||
|
|
.alert {
|
||
|
|
padding: 12px;
|
||
|
|
border-radius: 6px;
|
||
|
|
margin-bottom: 1rem;
|
||
|
|
font-size: 0.9rem;
|
||
|
|
}
|
||
|
|
.alert-error { background: rgba(255, 71, 87, 0.1); border: 1px solid var(--danger); color: var(--danger); }
|
||
|
|
.alert-success { background: rgba(0, 242, 255, 0.1); border: 1px solid var(--primary); color: var(--primary); }
|
||
|
|
.icon-hint {
|
||
|
|
font-size: 0.75rem;
|
||
|
|
color: var(--text-dim);
|
||
|
|
margin-top: 4px;
|
||
|
|
}
|
||
|
|
.icon-hint a { color: var(--primary); }
|
||
|
|
|
||
|
|
footer {
|
||
|
|
padding: 60px 8% 30px;
|
||
|
|
text-align: center;
|
||
|
|
border-top: 1px solid rgba(255,255,255,0.05);
|
||
|
|
color: var(--text-dim);
|
||
|
|
font-size: 0.9rem;
|
||
|
|
}
|
||
|
|
footer .admin-toggle {
|
||
|
|
display: inline-block;
|
||
|
|
margin-top: 10px;
|
||
|
|
opacity: 0.3;
|
||
|
|
cursor: pointer;
|
||
|
|
transition: 0.3s;
|
||
|
|
}
|
||
|
|
footer .admin-toggle:hover { opacity: 1; color: var(--primary); }
|
||
|
|
|
||
|
|
@media (max-width: 768px) {
|
||
|
|
header h1 { font-size: 2.2rem; }
|
||
|
|
.grid { grid-template-columns: 1fr; }
|
||
|
|
nav { padding: 1rem 5%; }
|
||
|
|
nav .links { gap: 1rem; }
|
||
|
|
main { padding: 60px 5%; }
|
||
|
|
}
|
||
|
|
</style>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
|
||
|
|
<nav>
|
||
|
|
<div class="logo">JONGJAE.XR</div>
|
||
|
|
<div class="links">
|
||
|
|
<a href="#work">PROJECTS</a>
|
||
|
|
<a href="profile.html" class="profile-link">
|
||
|
|
<i class="fa-solid fa-user"></i> PROFILE
|
||
|
|
</a>
|
||
|
|
</div>
|
||
|
|
</nav>
|
||
|
|
|
||
|
|
<header>
|
||
|
|
<h1>이종재 <span class="highlight">Portfolio</span></h1>
|
||
|
|
<p>Game & XR 개발자로서의 기술적 도전과 기록을 담은 공간입니다.<br>Gitea 서버를 통해 실제 <span class="highlight">소스 코드</span>를 확인하실 수 있습니다.</p>
|
||
|
|
</header>
|
||
|
|
|
||
|
|
<main id="work">
|
||
|
|
<div class="section-header">
|
||
|
|
<h2>DEVELOPMENT LOG</h2>
|
||
|
|
<div class="line"></div>
|
||
|
|
<div class="admin-controls hidden" id="adminControls">
|
||
|
|
<button class="btn btn-primary" onclick="openProjectModal()">
|
||
|
|
<i class="fa-solid fa-plus"></i> 새 프로젝트
|
||
|
|
</button>
|
||
|
|
<button class="btn btn-outline" onclick="logout()">
|
||
|
|
<i class="fa-solid fa-right-from-bracket"></i> 로그아웃
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="grid" id="projectsGrid">
|
||
|
|
<!-- 프로젝트가 동적으로 로드됩니다 -->
|
||
|
|
</div>
|
||
|
|
</main>
|
||
|
|
|
||
|
|
<footer>
|
||
|
|
<p>© 2026 Lee Jong-jae. Hosted on Private Synology NAS.</p>
|
||
|
|
<span class="admin-toggle" onclick="openLoginModal()" title="Admin">
|
||
|
|
<i class="fa-solid fa-shield-halved"></i>
|
||
|
|
</span>
|
||
|
|
</footer>
|
||
|
|
|
||
|
|
<!-- 로그인 모달 -->
|
||
|
|
<div class="modal-overlay" id="loginModal">
|
||
|
|
<div class="modal">
|
||
|
|
<h2><i class="fa-solid fa-lock"></i> ADMIN LOGIN</h2>
|
||
|
|
<div id="loginAlert"></div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>비밀번호</label>
|
||
|
|
<input type="password" id="loginPassword" placeholder="비밀번호를 입력하세요"
|
||
|
|
onkeypress="if(event.key==='Enter') doLogin()">
|
||
|
|
</div>
|
||
|
|
<div class="modal-actions">
|
||
|
|
<button class="btn btn-outline" onclick="closeLoginModal()">취소</button>
|
||
|
|
<button class="btn btn-primary" onclick="doLogin()">로그인</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- 프로젝트 등록/수정 모달 -->
|
||
|
|
<div class="modal-overlay" id="projectModal">
|
||
|
|
<div class="modal">
|
||
|
|
<h2 id="projectModalTitle">새 프로젝트</h2>
|
||
|
|
<div id="projectAlert"></div>
|
||
|
|
<input type="hidden" id="projectId">
|
||
|
|
<div class="form-group">
|
||
|
|
<label>제목 *</label>
|
||
|
|
<input type="text" id="projectTitle" placeholder="예: XR 인터랙티브 시뮬레이션">
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>라벨 *</label>
|
||
|
|
<input type="text" id="projectLabel" placeholder="예: UNITY / XR">
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>설명 *</label>
|
||
|
|
<textarea id="projectDescription" placeholder="프로젝트 소개"></textarea>
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>아이콘 (Font Awesome 클래스)</label>
|
||
|
|
<input type="text" id="projectIcon" placeholder="예: fa-solid fa-cube">
|
||
|
|
<p class="icon-hint">예시: <code>fa-solid fa-cube</code> · <code>fa-solid fa-gamepad</code> · <code>fa-solid fa-microchip</code> · <a href="https://fontawesome.com/search?o=r&m=free" target="_blank">아이콘 검색</a></p>
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>썸네일 이미지 URL (선택)</label>
|
||
|
|
<input type="text" id="projectImage" placeholder="비우면 아이콘 표시">
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>링크 URL (Gitea 저장소 등)</label>
|
||
|
|
<input type="text" id="projectLink" placeholder="https://...">
|
||
|
|
</div>
|
||
|
|
<div class="modal-actions">
|
||
|
|
<button class="btn btn-outline" onclick="closeProjectModal()">취소</button>
|
||
|
|
<button class="btn btn-primary" onclick="saveProject()">
|
||
|
|
<i class="fa-solid fa-floppy-disk"></i> 저장
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
// ===== 상태 =====
|
||
|
|
let isAdmin = false;
|
||
|
|
let projects = [];
|
||
|
|
|
||
|
|
// ===== 초기화 =====
|
||
|
|
async function init() {
|
||
|
|
await checkAuth();
|
||
|
|
await loadProjects();
|
||
|
|
}
|
||
|
|
|
||
|
|
// ===== 인증 =====
|
||
|
|
async function checkAuth() {
|
||
|
|
try {
|
||
|
|
const res = await fetch('api/auth.php?action=check');
|
||
|
|
const data = await res.json();
|
||
|
|
isAdmin = data.authenticated === true;
|
||
|
|
document.getElementById('adminControls').classList.toggle('hidden', !isAdmin);
|
||
|
|
} catch (e) {
|
||
|
|
isAdmin = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function openLoginModal() {
|
||
|
|
if (isAdmin) {
|
||
|
|
logout();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
document.getElementById('loginModal').classList.add('active');
|
||
|
|
document.getElementById('loginPassword').focus();
|
||
|
|
}
|
||
|
|
|
||
|
|
function closeLoginModal() {
|
||
|
|
document.getElementById('loginModal').classList.remove('active');
|
||
|
|
document.getElementById('loginPassword').value = '';
|
||
|
|
document.getElementById('loginAlert').innerHTML = '';
|
||
|
|
}
|
||
|
|
|
||
|
|
async function doLogin() {
|
||
|
|
const password = document.getElementById('loginPassword').value;
|
||
|
|
if (!password) return;
|
||
|
|
|
||
|
|
try {
|
||
|
|
const res = await fetch('api/auth.php?action=login', {
|
||
|
|
method: 'POST',
|
||
|
|
headers: { 'Content-Type': 'application/json' },
|
||
|
|
body: JSON.stringify({ password })
|
||
|
|
});
|
||
|
|
const data = await res.json();
|
||
|
|
|
||
|
|
if (data.success) {
|
||
|
|
isAdmin = true;
|
||
|
|
document.getElementById('adminControls').classList.remove('hidden');
|
||
|
|
closeLoginModal();
|
||
|
|
await loadProjects();
|
||
|
|
} else {
|
||
|
|
showAlert('loginAlert', data.error || '로그인 실패', 'error');
|
||
|
|
}
|
||
|
|
} catch (e) {
|
||
|
|
showAlert('loginAlert', '서버 오류', 'error');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
async function logout() {
|
||
|
|
await fetch('api/auth.php?action=logout', { method: 'POST' });
|
||
|
|
isAdmin = false;
|
||
|
|
document.getElementById('adminControls').classList.add('hidden');
|
||
|
|
await loadProjects();
|
||
|
|
}
|
||
|
|
|
||
|
|
// ===== 프로젝트 로드 =====
|
||
|
|
async function loadProjects() {
|
||
|
|
try {
|
||
|
|
const res = await fetch('api/projects.php');
|
||
|
|
projects = await res.json();
|
||
|
|
renderProjects();
|
||
|
|
} catch (e) {
|
||
|
|
console.error('Failed to load projects', e);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function renderProjects() {
|
||
|
|
const grid = document.getElementById('projectsGrid');
|
||
|
|
|
||
|
|
if (!projects || projects.length === 0) {
|
||
|
|
grid.innerHTML = `
|
||
|
|
<div class="empty-state" style="grid-column: 1/-1;">
|
||
|
|
<i class="fa-solid fa-folder-open"></i>
|
||
|
|
<p>아직 등록된 프로젝트가 없습니다.</p>
|
||
|
|
</div>
|
||
|
|
`;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
grid.innerHTML = projects.map(p => `
|
||
|
|
<div class="card">
|
||
|
|
<div class="card-img" ${p.image ? `style="background-image:url('${escapeHtml(p.image)}'); font-size:0;"` : ''}>
|
||
|
|
${!p.image ? `<i class="${escapeHtml(p.icon || 'fa-solid fa-code')}"></i>` : ''}
|
||
|
|
</div>
|
||
|
|
<div class="card-content">
|
||
|
|
<span class="card-label">${escapeHtml(p.label)}</span>
|
||
|
|
<h3>${escapeHtml(p.title)}</h3>
|
||
|
|
<p>${escapeHtml(p.description)}</p>
|
||
|
|
<div class="card-actions">
|
||
|
|
${p.link ? `<a href="${escapeHtml(p.link)}" class="btn-git" target="_blank">
|
||
|
|
<i class="fa-brands fa-git-alt"></i> 소스 코드 보기
|
||
|
|
</a>` : ''}
|
||
|
|
</div>
|
||
|
|
${isAdmin ? `
|
||
|
|
<div class="card-actions admin-mode">
|
||
|
|
<button class="btn btn-outline" onclick="editProject(${p.id})">
|
||
|
|
<i class="fa-solid fa-pen"></i> 수정
|
||
|
|
</button>
|
||
|
|
<button class="btn btn-danger" onclick="deleteProject(${p.id})">
|
||
|
|
<i class="fa-solid fa-trash"></i> 삭제
|
||
|
|
</button>
|
||
|
|
</div>` : ''}
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
`).join('');
|
||
|
|
}
|
||
|
|
|
||
|
|
// ===== 프로젝트 모달 =====
|
||
|
|
function openProjectModal(project = null) {
|
||
|
|
document.getElementById('projectAlert').innerHTML = '';
|
||
|
|
|
||
|
|
if (project) {
|
||
|
|
document.getElementById('projectModalTitle').textContent = '프로젝트 수정';
|
||
|
|
document.getElementById('projectId').value = project.id;
|
||
|
|
document.getElementById('projectTitle').value = project.title;
|
||
|
|
document.getElementById('projectLabel').value = project.label;
|
||
|
|
document.getElementById('projectDescription').value = project.description;
|
||
|
|
document.getElementById('projectIcon').value = project.icon || '';
|
||
|
|
document.getElementById('projectImage').value = project.image || '';
|
||
|
|
document.getElementById('projectLink').value = project.link || '';
|
||
|
|
} else {
|
||
|
|
document.getElementById('projectModalTitle').textContent = '새 프로젝트';
|
||
|
|
document.getElementById('projectId').value = '';
|
||
|
|
['projectTitle', 'projectLabel', 'projectDescription',
|
||
|
|
'projectIcon', 'projectImage', 'projectLink'].forEach(id => {
|
||
|
|
document.getElementById(id).value = '';
|
||
|
|
});
|
||
|
|
document.getElementById('projectIcon').value = 'fa-solid fa-code';
|
||
|
|
}
|
||
|
|
document.getElementById('projectModal').classList.add('active');
|
||
|
|
}
|
||
|
|
|
||
|
|
function closeProjectModal() {
|
||
|
|
document.getElementById('projectModal').classList.remove('active');
|
||
|
|
}
|
||
|
|
|
||
|
|
function editProject(id) {
|
||
|
|
const project = projects.find(p => p.id === id);
|
||
|
|
if (project) openProjectModal(project);
|
||
|
|
}
|
||
|
|
|
||
|
|
async function saveProject() {
|
||
|
|
const id = document.getElementById('projectId').value;
|
||
|
|
const data = {
|
||
|
|
title: document.getElementById('projectTitle').value.trim(),
|
||
|
|
label: document.getElementById('projectLabel').value.trim(),
|
||
|
|
description: document.getElementById('projectDescription').value.trim(),
|
||
|
|
icon: document.getElementById('projectIcon').value.trim(),
|
||
|
|
image: document.getElementById('projectImage').value.trim(),
|
||
|
|
link: document.getElementById('projectLink').value.trim()
|
||
|
|
};
|
||
|
|
|
||
|
|
if (!data.title || !data.label || !data.description) {
|
||
|
|
showAlert('projectAlert', '제목, 라벨, 설명은 필수입니다', 'error');
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
try {
|
||
|
|
let res;
|
||
|
|
if (id) {
|
||
|
|
data.id = parseInt(id);
|
||
|
|
res = await fetch('api/projects.php', {
|
||
|
|
method: 'PUT',
|
||
|
|
headers: { 'Content-Type': 'application/json' },
|
||
|
|
body: JSON.stringify(data)
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
res = await fetch('api/projects.php', {
|
||
|
|
method: 'POST',
|
||
|
|
headers: { 'Content-Type': 'application/json' },
|
||
|
|
body: JSON.stringify(data)
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
const result = await res.json();
|
||
|
|
if (result.success) {
|
||
|
|
closeProjectModal();
|
||
|
|
await loadProjects();
|
||
|
|
} else {
|
||
|
|
showAlert('projectAlert', result.error || '저장 실패', 'error');
|
||
|
|
}
|
||
|
|
} catch (e) {
|
||
|
|
showAlert('projectAlert', '서버 오류', 'error');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
async function deleteProject(id) {
|
||
|
|
if (!confirm('정말 삭제하시겠습니까?')) return;
|
||
|
|
|
||
|
|
try {
|
||
|
|
const res = await fetch(`api/projects.php?id=${id}`, { method: 'DELETE' });
|
||
|
|
const result = await res.json();
|
||
|
|
if (result.success) {
|
||
|
|
await loadProjects();
|
||
|
|
} else {
|
||
|
|
alert(result.error || '삭제 실패');
|
||
|
|
}
|
||
|
|
} catch (e) {
|
||
|
|
alert('서버 오류');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// ===== 유틸 =====
|
||
|
|
function showAlert(elemId, message, type) {
|
||
|
|
const elem = document.getElementById(elemId);
|
||
|
|
elem.innerHTML = `<div class="alert alert-${type}">${escapeHtml(message)}</div>`;
|
||
|
|
if (type === 'success') {
|
||
|
|
setTimeout(() => elem.innerHTML = '', 3000);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function escapeHtml(str) {
|
||
|
|
if (str === null || str === undefined) return '';
|
||
|
|
return String(str)
|
||
|
|
.replace(/&/g, '&')
|
||
|
|
.replace(/</g, '<')
|
||
|
|
.replace(/>/g, '>')
|
||
|
|
.replace(/"/g, '"')
|
||
|
|
.replace(/'/g, ''');
|
||
|
|
}
|
||
|
|
|
||
|
|
// 모달 외부 클릭 시 닫기
|
||
|
|
document.querySelectorAll('.modal-overlay').forEach(overlay => {
|
||
|
|
overlay.addEventListener('click', (e) => {
|
||
|
|
if (e.target === overlay) overlay.classList.remove('active');
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
init();
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|