chess / templates /index.html
smodusermc's picture
Create templates/index.html
f30e28a verified
Raw History Blame Contribute Delete
16.1 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chess Arena - Play Chess Online</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Playfair+Display:wght@700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body class="theme-dark">
<!-- Loading Screen -->
<div id="loading-screen" class="loading-screen">
<div class="loader">
<div class="chess-piece-loader">β™”</div>
<p>Loading Chess Arena...</p>
</div>
</div>
<!-- Main Container -->
<div id="app" class="app-container hidden">
<!-- Header -->
<header class="header">
<div class="logo">
<span class="logo-icon">β™”</span>
<span class="logo-text">Chess Arena</span>
</div>
<div class="header-controls">
<div class="theme-selector">
<button class="theme-btn" id="theme-toggle">
<i class="fas fa-palette"></i>
<span>Theme</span>
</button>
<div class="theme-dropdown hidden" id="theme-dropdown">
<div class="theme-option" data-theme="dark">
<span class="theme-preview dark-preview"></span>
<span>Dark</span>
</div>
<div class="theme-option" data-theme="light">
<span class="theme-preview light-preview"></span>
<span>Light</span>
</div>
<div class="theme-option" data-theme="forest">
<span class="theme-preview forest-preview"></span>
<span>Forest</span>
</div>
<div class="theme-option" data-theme="ocean">
<span class="theme-preview ocean-preview"></span>
<span>Ocean</span>
</div>
<div class="theme-option" data-theme="sunset">
<span class="theme-preview sunset-preview"></span>
<span>Sunset</span>
</div>
<div class="theme-option" data-theme="midnight">
<span class="theme-preview midnight-preview"></span>
<span>Midnight</span>
</div>
<div class="theme-option" data-theme="cream">
<span class="theme-preview cream-preview"></span>
<span>Cream</span>
</div>
<div class="theme-option" data-theme="lavender">
<span class="theme-preview lavender-preview"></span>
<span>Lavender</span>
</div>
<div class="theme-option" data-theme="mint">
<span class="theme-preview mint-preview"></span>
<span>Mint</span>
</div>
<div class="theme-option" data-theme="slate">
<span class="theme-preview slate-preview"></span>
<span>Slate</span>
</div>
<div class="theme-option special" data-theme="rainbow">
<span class="theme-preview rainbow-preview"></span>
<span>Color changing</span>
</div>
</div>
</div>
<button class="sound-btn" id="sound-toggle">
<i class="fas fa-volume-up"></i>
</button>
</div>
</header>
<!-- Lobby Screen -->
<div id="lobby-screen" class="screen lobby-screen">
<div class="lobby-container">
<h1 class="lobby-title">Welcome to Chess Arena</h1>
<p class="lobby-subtitle">Play chess with friends or strangers from around the world</p>
<div class="username-section">
<label for="username-input">Your Username</label>
<input type="text" id="username-input" placeholder="Enter your username" maxlength="20">
</div>
<div class="lobby-options">
<div class="option-card create-game">
<div class="option-icon">
<i class="fas fa-plus-circle"></i>
</div>
<h3>Create Game</h3>
<p>Start a new game and invite a friend</p>
<div class="time-control-section">
<label>Time Control</label>
<div class="time-options">
<button class="time-btn active" data-time="null">No Limit</button>
<button class="time-btn" data-time="3">3 min</button>
<button class="time-btn" data-time="5">5 min</button>
<button class="time-btn" data-time="10">10 min</button>
</div>
</div>
<button class="btn btn-primary" id="create-game-btn">
<i class="fas fa-chess-board"></i>
Create Room
</button>
</div>
<div class="option-card join-game">
<div class="option-icon">
<i class="fas fa-sign-in-alt"></i>
</div>
<h3>Join Game</h3>
<p>Enter a room code to join</p>
<div class="room-code-section">
<input type="text" id="room-code-input" placeholder="Enter Room Code" maxlength="8">
</div>
<button class="btn btn-secondary" id="join-game-btn">
<i class="fas fa-arrow-right"></i>
Join Room
</button>
</div>
</div>
<div class="available-rooms">
<h3><i class="fas fa-door-open"></i> Available Rooms</h3>
<div id="rooms-list" class="rooms-list">
<p class="no-rooms">No rooms available. Create one!</p>
</div>
<button class="btn btn-text" id="refresh-rooms">
<i class="fas fa-sync-alt"></i> Refresh
</button>
</div>
</div>
</div>
<!-- Waiting Room Screen -->
<div id="waiting-screen" class="screen waiting-screen hidden">
<div class="waiting-container">
<div class="waiting-animation">
<div class="chess-pieces-animation">
<span>β™”</span>
<span>β™•</span>
<span>β™–</span>
<span>β™—</span>
<span>β™˜</span>
<span>β™™</span>
</div>
</div>
<h2>Waiting for Opponent</h2>
<p>Share this room code with your friend:</p>
<div class="room-code-display">
<span id="display-room-code">XXXXXXXX</span>
<button class="copy-btn" id="copy-code-btn">
<i class="fas fa-copy"></i>
</button>
</div>
<p class="waiting-info">
<i class="fas fa-clock"></i>
<span>Time Control: <span id="waiting-time-control">No Limit</span></span>
</p>
<button class="btn btn-text" id="cancel-waiting">
<i class="fas fa-times"></i> Cancel
</button>
</div>
</div>
<!-- Game Screen -->
<div id="game-screen" class="screen game-screen hidden">
<div class="game-container">
<!-- Opponent Info -->
<div class="player-info opponent-info">
<div class="player-avatar opponent-avatar">
<i class="fas fa-user"></i>
</div>
<div class="player-details">
<span class="player-name" id="opponent-name">Opponent</span>
<span class="player-color" id="opponent-color">Black</span>
</div>
<div class="player-timer" id="opponent-timer">
<i class="fas fa-clock"></i>
<span id="opponent-time">10:00</span>
</div>
</div>
<!-- Chess Board -->
<div class="board-wrapper">
<div class="captured-pieces" id="opponent-captured"></div>
<div class="board-container">
<div id="chessboard" class="chessboard"></div>
<!-- Move highlights overlay -->
<div id="highlights-overlay" class="highlights-overlay"></div>
<!-- Check indicator overlay -->
<div id="check-overlay" class="check-overlay"></div>
</div>
<div class="captured-pieces" id="player-captured"></div>
</div>
<!-- Player Info -->
<div class="player-info player-self-info">
<div class="player-avatar self-avatar">
<i class="fas fa-user"></i>
</div>
<div class="player-details">
<span class="player-name" id="player-name">You</span>
<span class="player-color" id="player-color">White</span>
</div>
<div class="player-timer" id="player-timer">
<i class="fas fa-clock"></i>
<span id="player-time">10:00</span>
</div>
</div>
<!-- Game Controls -->
<div class="game-controls">
<button class="control-btn" id="resign-btn" title="Resign">
<i class="fas fa-flag"></i>
</button>
<button class="control-btn" id="draw-btn" title="Offer Draw">
<i class="fas fa-handshake"></i>
</button>
<button class="control-btn" id="flip-board-btn" title="Flip Board">
<i class="fas fa-sync-alt"></i>
</button>
<button class="control-btn" id="chat-toggle-btn" title="Toggle Chat">
<i class="fas fa-comment"></i>
<span class="chat-badge hidden" id="chat-badge">0</span>
</button>
</div>
</div>
<!-- Side Panel -->
<div class="side-panel">
<!-- Move History -->
<div class="move-history-panel">
<h3><i class="fas fa-list-ol"></i> Moves</h3>
<div id="move-history" class="move-history"></div>
</div>
<!-- Chat -->
<div class="chat-panel" id="chat-panel">
<h3><i class="fas fa-comments"></i> Chat</h3>
<div id="chat-messages" class="chat-messages"></div>
<div class="chat-input-container">
<input type="text" id="chat-input" placeholder="Type a message..." maxlength="500">
<button class="send-btn" id="send-chat-btn">
<i class="fas fa-paper-plane"></i>
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Modals -->
<!-- Game Over Modal -->
<div id="game-over-modal" class="modal hidden">
<div class="modal-content game-over-content">
<div class="game-over-icon" id="game-over-icon">
<i class="fas fa-trophy"></i>
</div>
<h2 id="game-over-title">Game Over</h2>
<p id="game-over-message">Checkmate!</p>
<div class="game-over-actions">
<button class="btn btn-primary" id="play-again-btn">
<i class="fas fa-redo"></i> Play Again
</button>
<button class="btn btn-secondary" id="back-to-lobby-btn">
<i class="fas fa-home"></i> Lobby
</button>
</div>
</div>
</div>
<!-- Draw Offer Modal -->
<div id="draw-offer-modal" class="modal hidden">
<div class="modal-content">
<h2><i class="fas fa-handshake"></i> Draw Offer</h2>
<p id="draw-offer-message">Opponent offers a draw</p>
<div class="modal-actions">
<button class="btn btn-primary" id="accept-draw-btn">Accept</button>
<button class="btn btn-secondary" id="decline-draw-btn">Decline</button>
</div>
</div>
</div>
<!-- Resign Confirm Modal -->
<div id="resign-modal" class="modal hidden">
<div class="modal-content">
<h2><i class="fas fa-flag"></i> Resign Game?</h2>
<p>Are you sure you want to resign? This will count as a loss.</p>
<div class="modal-actions">
<button class="btn btn-danger" id="confirm-resign-btn">Resign</button>
<button class="btn btn-secondary" id="cancel-resign-btn">Cancel</button>
</div>
</div>
</div>
<!-- Promotion Modal -->
<div id="promotion-modal" class="modal hidden">
<div class="modal-content promotion-content">
<h2>Promote Pawn</h2>
<div class="promotion-pieces" id="promotion-pieces">
<button class="promotion-piece" data-piece="q">β™›</button>
<button class="promotion-piece" data-piece="r">β™œ</button>
<button class="promotion-piece" data-piece="b">♝</button>
<button class="promotion-piece" data-piece="n">β™ž</button>
</div>
</div>
</div>
<!-- Disconnection Modal -->
<div id="disconnect-modal" class="modal hidden">
<div class="modal-content">
<h2><i class="fas fa-wifi"></i> Opponent Disconnected</h2>
<p id="disconnect-message">Waiting for opponent to reconnect...</p>
<div class="disconnect-timer">
<span id="disconnect-countdown">10:00</span>
</div>
<p class="disconnect-info">You will win if they don't reconnect in time.</p>
</div>
</div>
<!-- Toast Container -->
<div id="toast-container" class="toast-container"></div>
<!-- Scripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.6.0/socket.io.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.10.3/chess.min.js"></script>
<script src="{{ url_for('static', filename='js/game.js') }}"></script>
</body>
</html>