Update index.html
Browse files- index.html +295 -40
index.html
CHANGED
|
@@ -109,20 +109,6 @@ canvas{max-height:250px;}
|
|
| 109 |
.progress-fill{height:100%;background:linear-gradient(90deg,#28a745,#20c997);transition:width 0.3s;}
|
| 110 |
.tooltip{position:relative;display:inline-block;cursor:help;}
|
| 111 |
.tooltip:hover::after{content:attr(data-tooltip);position:absolute;bottom:100%;left:50%;transform:translateX(-50%);padding:8px 12px;background:#000;color:#fff;border-radius:6px;font-size:12px;white-space:nowrap;margin-bottom:5px;z-index:1000;box-shadow:0 2px 8px rgba(0,0,0,0.5);}
|
| 112 |
-
|
| 113 |
-
/* ๐ฑ ๋ชจ๋ฐ์ผ ๋ฐ์ํ */
|
| 114 |
-
.mobile-tab-bar{display:none;}
|
| 115 |
-
@media (max-width: 768px) {
|
| 116 |
-
.container{flex-direction:column;padding-bottom:60px;}
|
| 117 |
-
.board-section{width:100%!important;border-right:none;display:none;}
|
| 118 |
-
.board-section.mobile-active{display:block!important;}
|
| 119 |
-
.mypage-section{width:100%!important;display:none;}
|
| 120 |
-
.mypage-section.mobile-active{display:block!important;}
|
| 121 |
-
.mobile-tab-bar{display:flex;position:fixed;bottom:0;left:0;width:100%;background:#1a1a2e;border-top:2px solid #2d2d44;z-index:999;}
|
| 122 |
-
.mobile-tab{flex:1;padding:12px 0;text-align:center;cursor:pointer;color:#8e8ea0;font-size:11px;font-weight:600;border:none;background:transparent;}
|
| 123 |
-
.mobile-tab .icon{font-size:20px;display:block;margin-bottom:4px;}
|
| 124 |
-
.mobile-tab.active{color:#667eea;background:rgba(102,126,234,0.1);}
|
| 125 |
-
}
|
| 126 |
</style>
|
| 127 |
</head>
|
| 128 |
<body>
|
|
@@ -284,9 +270,6 @@ currentUser = loadFromLocal('user_email');
|
|
| 284 |
if(!currentUser){return;}
|
| 285 |
document.getElementById('login-page').style.display='none';
|
| 286 |
document.getElementById('main-page').style.display='flex';
|
| 287 |
-
if(window.innerWidth <= 768){
|
| 288 |
-
document.querySelector('.board-section').classList.add('mobile-active');
|
| 289 |
-
}
|
| 290 |
await loadProfile();
|
| 291 |
await loadBoards();
|
| 292 |
await loadPosts(currentBoard, currentSort);
|
|
@@ -326,12 +309,21 @@ document.getElementById('admin-panel').style.display='block';
|
|
| 326 |
async function loadBoards(){
|
| 327 |
const res = await fetch('/api/boards');
|
| 328 |
const boards = await res.json();
|
| 329 |
-
|
|
|
|
|
|
|
| 330 |
document.getElementById('board-tabs').innerHTML = html;
|
| 331 |
}
|
| 332 |
async function switchBoard(key){
|
| 333 |
currentBoard = key;
|
| 334 |
await loadBoards();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
await loadPosts(key, currentSort);
|
| 336 |
}
|
| 337 |
async function switchSort(sort){
|
|
@@ -342,6 +334,12 @@ event.target.classList.add('active');
|
|
| 342 |
await loadPosts(currentBoard, sort);
|
| 343 |
}
|
| 344 |
async function loadPosts(key, sort){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
const res = await fetch(`/api/board/${key}/posts?sort=${sort}`);
|
| 346 |
const posts = await res.json();
|
| 347 |
const html = posts.map(p=>{
|
|
@@ -363,6 +361,88 @@ ${isHot?'<span class="badge badge-hot">HOT</span>':''}
|
|
| 363 |
}).join('');
|
| 364 |
document.getElementById('posts-container').innerHTML = html || '<div class="empty-state">๊ฒ์๊ธ์ด ์์ต๋๋ค</div>';
|
| 365 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
async function viewPost(id){
|
| 367 |
const res = await fetch(`/api/post/${id}`);
|
| 368 |
const data = await res.json();
|
|
@@ -823,6 +903,203 @@ closeModal();
|
|
| 823 |
loadPosts(currentBoard, currentSort);
|
| 824 |
loadProfile();
|
| 825 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 826 |
function logout(){
|
| 827 |
if(wakeStatusInterval){
|
| 828 |
clearInterval(wakeStatusInterval);
|
|
@@ -837,28 +1114,6 @@ currentUser = user;
|
|
| 837 |
loadApp();
|
| 838 |
}
|
| 839 |
};
|
| 840 |
-
|
| 841 |
-
// ๐ฑ ๋ชจ๋ฐ์ผ ํญ ์ ํ
|
| 842 |
-
function switchMobileTab(tab){
|
| 843 |
-
if(window.innerWidth > 768) return;
|
| 844 |
-
const boardSection = document.querySelector('.board-section');
|
| 845 |
-
const mypageSection = document.querySelector('.mypage-section');
|
| 846 |
-
const tabs = document.querySelectorAll('.mobile-tab');
|
| 847 |
-
tabs.forEach(t => t.classList.remove('active'));
|
| 848 |
-
if(tab === 'board'){
|
| 849 |
-
boardSection.classList.add('mobile-active');
|
| 850 |
-
mypageSection.classList.remove('mobile-active');
|
| 851 |
-
tabs[0].classList.add('active');
|
| 852 |
-
}else{
|
| 853 |
-
boardSection.classList.remove('mobile-active');
|
| 854 |
-
mypageSection.classList.add('mobile-active');
|
| 855 |
-
tabs[1].classList.add('active');
|
| 856 |
-
}
|
| 857 |
-
}
|
| 858 |
</script>
|
| 859 |
-
<div class="mobile-tab-bar">
|
| 860 |
-
<button class="mobile-tab active" onclick="switchMobileTab('board')"><span class="icon">๐</span>๊ฒ์ํ</button>
|
| 861 |
-
<button class="mobile-tab" onclick="switchMobileTab('mypage')"><span class="icon">๐ค</span>๋ง์ด</button>
|
| 862 |
-
</div>
|
| 863 |
</body>
|
| 864 |
</html>
|
|
|
|
| 109 |
.progress-fill{height:100%;background:linear-gradient(90deg,#28a745,#20c997);transition:width 0.3s;}
|
| 110 |
.tooltip{position:relative;display:inline-block;cursor:help;}
|
| 111 |
.tooltip:hover::after{content:attr(data-tooltip);position:absolute;bottom:100%;left:50%;transform:translateX(-50%);padding:8px 12px;background:#000;color:#fff;border-radius:6px;font-size:12px;white-space:nowrap;margin-bottom:5px;z-index:1000;box-shadow:0 2px 8px rgba(0,0,0,0.5);}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
</style>
|
| 113 |
</head>
|
| 114 |
<body>
|
|
|
|
| 270 |
if(!currentUser){return;}
|
| 271 |
document.getElementById('login-page').style.display='none';
|
| 272 |
document.getElementById('main-page').style.display='flex';
|
|
|
|
|
|
|
|
|
|
| 273 |
await loadProfile();
|
| 274 |
await loadBoards();
|
| 275 |
await loadPosts(currentBoard, currentSort);
|
|
|
|
| 309 |
async function loadBoards(){
|
| 310 |
const res = await fetch('/api/boards');
|
| 311 |
const boards = await res.json();
|
| 312 |
+
let html = boards.map(b=>`<button class="board-tab ${b.key===currentBoard?'active':''}" onclick="switchBoard('${b.key}')">${b.name}</button>`).join('');
|
| 313 |
+
// ๐ฎ ๋ฐฐํ ์๋ ๋ ํญ ์ถ๊ฐ
|
| 314 |
+
html += `<button class="board-tab ${'battle'===currentBoard?'active':''}" onclick="switchBoard('battle')">๐ฎ ๋ฐฐํ ์๋ ๋</button>`;
|
| 315 |
document.getElementById('board-tabs').innerHTML = html;
|
| 316 |
}
|
| 317 |
async function switchBoard(key){
|
| 318 |
currentBoard = key;
|
| 319 |
await loadBoards();
|
| 320 |
+
|
| 321 |
+
// ๐ฎ ๋ฐฐํ ์๋ ๋์์๋ ์ ๋ ฌ ๋ฒํผ ์จ๊ธฐ๊ธฐ
|
| 322 |
+
const sortToggle = document.querySelector('.sort-toggle');
|
| 323 |
+
if(sortToggle){
|
| 324 |
+
sortToggle.style.display = (key === 'battle') ? 'none' : 'flex';
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
await loadPosts(key, currentSort);
|
| 328 |
}
|
| 329 |
async function switchSort(sort){
|
|
|
|
| 334 |
await loadPosts(currentBoard, sort);
|
| 335 |
}
|
| 336 |
async function loadPosts(key, sort){
|
| 337 |
+
// ๐ฎ ๋ฐฐํ ์๋ ๋์ธ ๊ฒฝ์ฐ
|
| 338 |
+
if(key === 'battle'){
|
| 339 |
+
await loadBattleBoard();
|
| 340 |
+
return;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
const res = await fetch(`/api/board/${key}/posts?sort=${sort}`);
|
| 344 |
const posts = await res.json();
|
| 345 |
const html = posts.map(p=>{
|
|
|
|
| 361 |
}).join('');
|
| 362 |
document.getElementById('posts-container').innerHTML = html || '<div class="empty-state">๊ฒ์๊ธ์ด ์์ต๋๋ค</div>';
|
| 363 |
}
|
| 364 |
+
|
| 365 |
+
// ๐ฎ ๋ฐฐํ ์๋ ๋ ๊ฒ์ํ ํ์
|
| 366 |
+
async function loadBattleBoard(){
|
| 367 |
+
const container = document.getElementById('posts-container');
|
| 368 |
+
container.innerHTML = '<div style="text-align:center;padding:20px;">๋ก๋ฉ ์ค...</div>';
|
| 369 |
+
|
| 370 |
+
const res = await fetch('/api/battles/active?limit=20');
|
| 371 |
+
const data = await res.json();
|
| 372 |
+
const battles = data.battles || [];
|
| 373 |
+
|
| 374 |
+
let html = `
|
| 375 |
+
<div style="background:linear-gradient(135deg,#667eea,#764ba2);color:#fff;padding:20px;border-radius:8px;margin-bottom:20px;">
|
| 376 |
+
<div style="font-size:20px;font-weight:700;margin-bottom:10px;">๐ฎ Battle Arena - Polymarket Style</div>
|
| 377 |
+
<div style="font-size:14px;opacity:0.9;">A/B ํฌํ์ ๋ฒ ํ
ํ๊ณ ์น์ ์์ธก! โข ๋ฐฉ์ฅ์์๋ฃ 2% โข 50.01% ์ด์ ๋ํ ์ ์น๋ฆฌ</div>
|
| 378 |
+
<button class="btn btn-warning" style="margin-top:15px;" onclick="showCreateBattleModal()">
|
| 379 |
+
๐ ์ ๋ฐฐํ๋ฐฉ ๋ง๋ค๊ธฐ (-50 GPU)
|
| 380 |
+
</button>
|
| 381 |
+
</div>
|
| 382 |
+
|
| 383 |
+
<div style="font-size:16px;font-weight:600;margin:20px 0;color:#e0e0e0;">
|
| 384 |
+
๐ฅ ์งํ์ค์ธ ๋ฐฐํ (${battles.length}๊ฐ)
|
| 385 |
+
</div>
|
| 386 |
+
`;
|
| 387 |
+
|
| 388 |
+
if(battles.length === 0){
|
| 389 |
+
html += '<div class="empty-state">์งํ์ค์ธ ๋ฐฐํ์ด ์์ต๋๋ค<br><br>๋ฐฐํ๋ฐฉ์ ๋ง๋ค์ด ์์ธก ์์ฅ์ ์ด์ด๋ณด์ธ์!</div>';
|
| 390 |
+
}else{
|
| 391 |
+
battles.forEach(b => {
|
| 392 |
+
const totalPool = b.total_pool || 0;
|
| 393 |
+
const aRatio = b.a_ratio || 0;
|
| 394 |
+
const bRatio = b.b_ratio || 0;
|
| 395 |
+
|
| 396 |
+
html += `
|
| 397 |
+
<div style="background:#1a1a2e;border:2px solid #2d2d44;border-radius:12px;padding:20px;margin:15px 0;transition:all 0.3s;" onmouseover="this.style.borderColor='#667eea'" onmouseout="this.style.borderColor='#2d2d44'">
|
| 398 |
+
<div style="display:flex;align-items:center;gap:8px;margin-bottom:12px;">
|
| 399 |
+
<div style="font-weight:700;font-size:16px;color:#e0e0e0;flex:1;">${b.title}</div>
|
| 400 |
+
<div style="background:${b.battle_type === 'prediction' ? '#17a2b8' : '#667eea'};color:#fff;padding:4px 10px;border-radius:20px;font-size:11px;font-weight:700;">
|
| 401 |
+
${b.battle_type === 'prediction' ? '๐ฎ ์์ธก' : '๐ฌ ๋ค์๊ฒฐ'}
|
| 402 |
+
</div>
|
| 403 |
+
</div>
|
| 404 |
+
<div style="font-size:13px;color:#8e8ea0;margin-bottom:15px;">
|
| 405 |
+
๐ค ๋ฐฉ์ฅ: ${b.creator_name} | ๐ฐ ์ด ํ: <span style="color:#ffd700;font-weight:600;">${totalPool} GPU</span> | โฐ ๋จ์์๊ฐ: <span style="color:#ff6b6b;font-weight:600;">${b.time_left}</span>
|
| 406 |
+
</div>
|
| 407 |
+
|
| 408 |
+
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-top:15px;">
|
| 409 |
+
<div style="background:#0f0f23;padding:20px;border-radius:8px;border:3px solid ${aRatio > 50 ? '#28a745' : '#2d2d44'};position:relative;">
|
| 410 |
+
<div style="position:absolute;top:10px;right:10px;background:${aRatio > 50 ? '#28a745' : '#667eea'};color:#fff;padding:4px 12px;border-radius:20px;font-size:11px;font-weight:700;">
|
| 411 |
+
${aRatio > 50 ? '๐ ์ฐ์ธ' : 'A'}
|
| 412 |
+
</div>
|
| 413 |
+
<div style="font-weight:600;font-size:14px;color:#e0e0e0;margin-bottom:8px;">${b.option_a}</div>
|
| 414 |
+
<div style="font-size:32px;font-weight:700;color:#28a745;margin:10px 0;">${aRatio.toFixed(1)}%</div>
|
| 415 |
+
<div style="font-size:12px;color:#8e8ea0;margin-bottom:12px;">๐ฐ ${b.option_a_pool} GPU</div>
|
| 416 |
+
<button class="btn btn-success" style="width:100%;font-size:13px;font-weight:600;"
|
| 417 |
+
onclick="event.stopPropagation(); placeBet(${b.id}, 'A')">
|
| 418 |
+
A ๋ฒ ํ
ํ๊ธฐ
|
| 419 |
+
</button>
|
| 420 |
+
</div>
|
| 421 |
+
|
| 422 |
+
<div style="background:#0f0f23;padding:20px;border-radius:8px;border:3px solid ${bRatio > 50 ? '#dc3545' : '#2d2d44'};position:relative;">
|
| 423 |
+
<div style="position:absolute;top:10px;right:10px;background:${bRatio > 50 ? '#dc3545' : '#667eea'};color:#fff;padding:4px 12px;border-radius:20px;font-size:11px;font-weight:700;">
|
| 424 |
+
${bRatio > 50 ? '๐ ์ฐ์ธ' : 'B'}
|
| 425 |
+
</div>
|
| 426 |
+
<div style="font-weight:600;font-size:14px;color:#e0e0e0;margin-bottom:8px;">${b.option_b}</div>
|
| 427 |
+
<div style="font-size:32px;font-weight:700;color:#dc3545;margin:10px 0;">${bRatio.toFixed(1)}%</div>
|
| 428 |
+
<div style="font-size:12px;color:#8e8ea0;margin-bottom:12px;">๐ฐ ${b.option_b_pool} GPU</div>
|
| 429 |
+
<button class="btn btn-danger" style="width:100%;font-size:13px;font-weight:600;"
|
| 430 |
+
onclick="event.stopPropagation(); placeBet(${b.id}, 'B')">
|
| 431 |
+
B ๋ฒ ํ
ํ๊ธฐ
|
| 432 |
+
</button>
|
| 433 |
+
</div>
|
| 434 |
+
</div>
|
| 435 |
+
|
| 436 |
+
<div style="margin-top:12px;padding-top:12px;border-top:1px solid #2d2d44;font-size:11px;color:#8e8ea0;">
|
| 437 |
+
๐ก ์น์ ์์ธก ์ ํ๋: ${aRatio > bRatio ? aRatio.toFixed(1) : bRatio.toFixed(1)}% | ๋ฒ ํ
์ฐธ์ฌ๋ก ๋ฐฐ๋น๊ธ ํ๋ ๊ฐ๋ฅ
|
| 438 |
+
</div>
|
| 439 |
+
</div>
|
| 440 |
+
`;
|
| 441 |
+
});
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
container.innerHTML = html;
|
| 445 |
+
}
|
| 446 |
async function viewPost(id){
|
| 447 |
const res = await fetch(`/api/post/${id}`);
|
| 448 |
const data = await res.json();
|
|
|
|
| 903 |
loadPosts(currentBoard, currentSort);
|
| 904 |
loadProfile();
|
| 905 |
}
|
| 906 |
+
// ========== ๐ฎ Battle Arena Functions ==========
|
| 907 |
+
async function loadBattleArena(){
|
| 908 |
+
const container = document.getElementById('mypage-content');
|
| 909 |
+
container.innerHTML = '<div style="text-align:center;padding:20px;">๋ก๋ฉ ์ค...</div>';
|
| 910 |
+
|
| 911 |
+
const res = await fetch('/api/battles/active?limit=20');
|
| 912 |
+
const data = await res.json();
|
| 913 |
+
const battles = data.battles || [];
|
| 914 |
+
|
| 915 |
+
let html = `
|
| 916 |
+
<div style="background:linear-gradient(135deg,#667eea,#764ba2);color:#fff;padding:15px;border-radius:8px;margin-bottom:15px;">
|
| 917 |
+
<div style="font-size:16px;font-weight:700;">๐ฎ Battle Arena - Polymarket ์คํ์ผ</div>
|
| 918 |
+
<div style="font-size:12px;margin-top:5px;">A/B ํฌํ์ ๋ฒ ํ
ํ๊ณ ์น์ ์์ธก! ๋ฐฉ์ฅ์์๋ฃ 2%</div>
|
| 919 |
+
</div>
|
| 920 |
+
|
| 921 |
+
<button class="btn btn-primary" style="width:100%;margin-bottom:15px;" onclick="showCreateBattleModal()">
|
| 922 |
+
๐ ์ ๋ฐฐํ๋ฐฉ ๋ง๋ค๊ธฐ (-50 GPU)
|
| 923 |
+
</button>
|
| 924 |
+
|
| 925 |
+
<div style="font-size:14px;font-weight:600;margin:15px 0;color:#e0e0e0;">๐ฅ ์งํ์ค์ธ ๋ฐฐํ (${battles.length}๊ฐ)</div>
|
| 926 |
+
`;
|
| 927 |
+
|
| 928 |
+
if(battles.length === 0){
|
| 929 |
+
html += '<div class="empty-state">์งํ์ค์ธ ๋ฐฐํ์ด ์์ต๋๋ค</div>';
|
| 930 |
+
}else{
|
| 931 |
+
battles.forEach(b => {
|
| 932 |
+
const totalPool = b.total_pool || 0;
|
| 933 |
+
const aRatio = b.a_ratio || 0;
|
| 934 |
+
const bRatio = b.b_ratio || 0;
|
| 935 |
+
|
| 936 |
+
html += `
|
| 937 |
+
<div style="background:#1a1a2e;border:1px solid #2d2d44;border-radius:8px;padding:15px;margin:10px 0;">
|
| 938 |
+
<div style="font-weight:600;font-size:14px;margin-bottom:10px;color:#e0e0e0;">${b.title}</div>
|
| 939 |
+
<div style="font-size:12px;color:#8e8ea0;margin-bottom:10px;">
|
| 940 |
+
๋ฐฉ์ฅ: ${b.creator_name} | ์ด ํ: ${totalPool} GPU | ๋จ์์๊ฐ: ${b.time_left}
|
| 941 |
+
</div>
|
| 942 |
+
|
| 943 |
+
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:10px;">
|
| 944 |
+
<div style="background:#0f0f23;padding:12px;border-radius:6px;border:2px solid ${aRatio > 50 ? '#28a745' : '#2d2d44'};">
|
| 945 |
+
<div style="font-weight:600;color:#e0e0e0;">${b.option_a}</div>
|
| 946 |
+
<div style="font-size:20px;font-weight:700;color:#28a745;margin:5px 0;">${aRatio}%</div>
|
| 947 |
+
<div style="font-size:11px;color:#8e8ea0;">${b.option_a_pool} GPU</div>
|
| 948 |
+
<button class="btn btn-success" style="width:100%;margin-top:8px;font-size:12px;"
|
| 949 |
+
onclick="placeBet(${b.id}, 'A')">
|
| 950 |
+
A ๋ฒ ํ
|
| 951 |
+
</button>
|
| 952 |
+
</div>
|
| 953 |
+
|
| 954 |
+
<div style="background:#0f0f23;padding:12px;border-radius:6px;border:2px solid ${bRatio > 50 ? '#dc3545' : '#2d2d44'};">
|
| 955 |
+
<div style="font-weight:600;color:#e0e0e0;">${b.option_b}</div>
|
| 956 |
+
<div style="font-size:20px;font-weight:700;color:#dc3545;margin:5px 0;">${bRatio}%</div>
|
| 957 |
+
<div style="font-size:11px;color:#8e8ea0;">${b.option_b_pool} GPU</div>
|
| 958 |
+
<button class="btn btn-danger" style="width:100%;margin-top:8px;font-size:12px;"
|
| 959 |
+
onclick="placeBet(${b.id}, 'B')">
|
| 960 |
+
B ๋ฒ ํ
|
| 961 |
+
</button>
|
| 962 |
+
</div>
|
| 963 |
+
</div>
|
| 964 |
+
</div>
|
| 965 |
+
`;
|
| 966 |
+
});
|
| 967 |
+
}
|
| 968 |
+
|
| 969 |
+
container.innerHTML = html;
|
| 970 |
+
}
|
| 971 |
+
|
| 972 |
+
function showCreateBattleModal(){
|
| 973 |
+
const modal = document.getElementById('post-modal');
|
| 974 |
+
const modalBody = document.getElementById('modal-body');
|
| 975 |
+
|
| 976 |
+
modalBody.innerHTML = `
|
| 977 |
+
<div class="modal-header">๐ ๋ฐฐํ๋ฐฉ ๋ง๋ค๊ธฐ (-50 GPU)</div>
|
| 978 |
+
<div style="padding:15px;">
|
| 979 |
+
<div class="input-group">
|
| 980 |
+
<label>๋ฐฐํ ์ ๋ชฉ (10์ ์ด์)</label>
|
| 981 |
+
<input type="text" id="battle-title" placeholder="์: ๋นํธ์ฝ์ธ 10๋ง๋ถ ๋ํํ ๊น?" maxlength="100">
|
| 982 |
+
</div>
|
| 983 |
+
<div class="input-group">
|
| 984 |
+
<label>์ ํ์ง A</label>
|
| 985 |
+
<input type="text" id="battle-option-a" placeholder="์: ๋ํํ๋ค" maxlength="50">
|
| 986 |
+
</div>
|
| 987 |
+
<div class="input-group">
|
| 988 |
+
<label>์ ํ์ง B</label>
|
| 989 |
+
<input type="text" id="battle-option-b" placeholder="์: ๋ชป ๋ํ" maxlength="50">
|
| 990 |
+
</div>
|
| 991 |
+
<div class="input-group">
|
| 992 |
+
<label>๐ฏ ๋ฐฐํ ํ์
</label>
|
| 993 |
+
<select id="battle-type" onchange="updateBattleTypeDescription()">
|
| 994 |
+
<option value="opinion">๐ฌ ๋ค์๊ฒฐ (์๊ฒฌ/๋
ผ์)</option>
|
| 995 |
+
<option value="prediction">๐ฎ ์์ธก (์ค์ ๊ฒฐ๊ณผ)</option>
|
| 996 |
+
</select>
|
| 997 |
+
<div id="battle-type-desc" style="font-size:11px;color:#8e8ea0;margin-top:5px;padding:8px;background:#0f0f23;border-radius:4px;">
|
| 998 |
+
๐ฌ <strong>๋ค์๊ฒฐ:</strong> ๋ํ์จ 50.01% ์ด์ ์น๋ฆฌ | ์: "AI ์ฐ์๋ก ", "MZ vs ๊ธฐ์ฑ์ธ๋"
|
| 999 |
+
</div>
|
| 1000 |
+
</div>
|
| 1001 |
+
<div class="input-group">
|
| 1002 |
+
<label>๋ฒ ํ
๊ธฐํ (์๊ฐ)</label>
|
| 1003 |
+
<select id="battle-duration">
|
| 1004 |
+
<option value="1">1์๊ฐ</option>
|
| 1005 |
+
<option value="3">3์๊ฐ</option>
|
| 1006 |
+
<option value="6">6์๊ฐ</option>
|
| 1007 |
+
<option value="12">12์๊ฐ</option>
|
| 1008 |
+
<option value="24" selected>24์๊ฐ</option>
|
| 1009 |
+
</select>
|
| 1010 |
+
</div>
|
| 1011 |
+
<button class="btn btn-primary" style="width:100%;margin-top:15px;" onclick="createBattle()">
|
| 1012 |
+
๐ฎ ๋ฐฐํ๋ฐฉ ์์ฑ (-50 GPU)
|
| 1013 |
+
</button>
|
| 1014 |
+
</div>
|
| 1015 |
+
`;
|
| 1016 |
+
|
| 1017 |
+
modal.classList.add('active');
|
| 1018 |
+
}
|
| 1019 |
+
|
| 1020 |
+
function updateBattleTypeDescription(){
|
| 1021 |
+
const typeSelect = document.getElementById('battle-type');
|
| 1022 |
+
const descDiv = document.getElementById('battle-type-desc');
|
| 1023 |
+
if(typeSelect.value === 'opinion'){
|
| 1024 |
+
descDiv.innerHTML = `๐ฌ <strong>๋ค์๊ฒฐ:</strong> ๋ํ์จ 50.01% ์ด์ ์น๋ฆฌ | ์: "AI ์ฐ์๋ก ", "MZ vs ๊ธฐ์ฑ์ธ๋"`;
|
| 1025 |
+
}else{
|
| 1026 |
+
descDiv.innerHTML = `๐ฎ <strong>์์ธก:</strong> ์ค์ ๊ฒฐ๊ณผ๋ก ํ์ | ์: "๋นํธ์ฝ์ธ 10๋ง๋ถ", "๋ด์ผ ์์ธ ๋น"`;
|
| 1027 |
+
}
|
| 1028 |
+
}
|
| 1029 |
+
|
| 1030 |
+
async function createBattle(){
|
| 1031 |
+
const title = document.getElementById('battle-title').value.trim();
|
| 1032 |
+
const option_a = document.getElementById('battle-option-a').value.trim();
|
| 1033 |
+
const option_b = document.getElementById('battle-option-b').value.trim();
|
| 1034 |
+
const duration_hours = parseInt(document.getElementById('battle-duration').value);
|
| 1035 |
+
const battle_type = document.getElementById('battle-type').value;
|
| 1036 |
+
|
| 1037 |
+
if(!title || title.length < 10){
|
| 1038 |
+
alert('์ ๋ชฉ 10์ ์ด์ ์
๋ ฅํ์ธ์');
|
| 1039 |
+
return;
|
| 1040 |
+
}
|
| 1041 |
+
if(!option_a || !option_b){
|
| 1042 |
+
alert('์ ํ์ง A์ B๋ฅผ ๋ชจ๋ ์
๋ ฅํ์ธ์');
|
| 1043 |
+
return;
|
| 1044 |
+
}
|
| 1045 |
+
|
| 1046 |
+
const res = await fetch('/api/battle/create', {
|
| 1047 |
+
method: 'POST',
|
| 1048 |
+
headers: {'Content-Type': 'application/json'},
|
| 1049 |
+
body: JSON.stringify({
|
| 1050 |
+
email: currentUser,
|
| 1051 |
+
title: title,
|
| 1052 |
+
option_a: option_a,
|
| 1053 |
+
option_b: option_b,
|
| 1054 |
+
duration_hours: duration_hours,
|
| 1055 |
+
battle_type: battle_type
|
| 1056 |
+
})
|
| 1057 |
+
});
|
| 1058 |
+
|
| 1059 |
+
const data = await res.json();
|
| 1060 |
+
if(data.error){
|
| 1061 |
+
alert(data.error);
|
| 1062 |
+
return;
|
| 1063 |
+
}
|
| 1064 |
+
|
| 1065 |
+
alert(data.message);
|
| 1066 |
+
closeModal();
|
| 1067 |
+
loadProfile();
|
| 1068 |
+
loadMypageContent('battle');
|
| 1069 |
+
}
|
| 1070 |
+
|
| 1071 |
+
async function placeBet(room_id, choice){
|
| 1072 |
+
const betAmount = prompt(`${choice} ์ ํ! ๋ฒ ํ
๊ธ์ก ์
๋ ฅ (1-100 GPU):`, '10');
|
| 1073 |
+
if(!betAmount) return;
|
| 1074 |
+
|
| 1075 |
+
const amount = parseInt(betAmount);
|
| 1076 |
+
if(isNaN(amount) || amount < 1 || amount > 100){
|
| 1077 |
+
alert('1~100 ์ฌ์ด ์ซ์๋ฅผ ์
๋ ฅํ์ธ์');
|
| 1078 |
+
return;
|
| 1079 |
+
}
|
| 1080 |
+
|
| 1081 |
+
const res = await fetch('/api/battle/bet', {
|
| 1082 |
+
method: 'POST',
|
| 1083 |
+
headers: {'Content-Type': 'application/json'},
|
| 1084 |
+
body: JSON.stringify({
|
| 1085 |
+
email: currentUser,
|
| 1086 |
+
room_id: room_id,
|
| 1087 |
+
choice: choice,
|
| 1088 |
+
bet_amount: amount
|
| 1089 |
+
})
|
| 1090 |
+
});
|
| 1091 |
+
|
| 1092 |
+
const data = await res.json();
|
| 1093 |
+
if(data.error){
|
| 1094 |
+
alert(data.error);
|
| 1095 |
+
return;
|
| 1096 |
+
}
|
| 1097 |
+
|
| 1098 |
+
alert(data.message);
|
| 1099 |
+
loadProfile();
|
| 1100 |
+
loadMypageContent('battle');
|
| 1101 |
+
}
|
| 1102 |
+
|
| 1103 |
function logout(){
|
| 1104 |
if(wakeStatusInterval){
|
| 1105 |
clearInterval(wakeStatusInterval);
|
|
|
|
| 1114 |
loadApp();
|
| 1115 |
}
|
| 1116 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1117 |
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1118 |
</body>
|
| 1119 |
</html>
|