Spaces:
Running
Running
| <html lang="fa" dir="rtl"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>داشبورد چت | Frosted Glass UI</title> | |
| <!-- Font: Vazirmatn --> | |
| <link href="https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css" rel="stylesheet" | |
| type="text/css" /> | |
| <!-- Icons: FontAwesome --> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| :root { | |
| /* Refined Color Palette - Calm & Premium */ | |
| --bg-deep: #050508; | |
| --glass-surface: rgba(255, 255, 255, 0.03); | |
| --glass-border: rgba(255, 255, 255, 0.08); | |
| --glass-hover: rgba(255, 255, 255, 0.06); | |
| /* Text */ | |
| --text-main: #ffffff; | |
| --text-muted: #94a3b8; | |
| /* Accents */ | |
| --accent-primary: #8b5cf6; /* Violet */ | |
| --accent-secondary: #3b82f6; /* Blue */ | |
| --accent-tertiary: #ec4899; /* Pink */ | |
| /* Glow Colors for Background Orbs */ | |
| --glow-1: rgba(139, 92, 246, 0.4); | |
| --glow-2: rgba(59, 130, 246, 0.4); | |
| --glow-3: rgba(236, 72, 153, 0.3); | |
| /* Radius & Spacing */ | |
| --radius-card: 24px; | |
| --radius-btn: 12px; | |
| --pad-container: 24px; | |
| --gap-grid: 28px; | |
| } | |
| * { | |
| box-sizing: border-box; | |
| margin: 0; | |
| padding: 0; | |
| outline: none; | |
| -webkit-tap-highlight-color: transparent; | |
| } | |
| body { | |
| font-family: 'Vazirmatn', sans-serif; | |
| background-color: var(--bg-deep); | |
| color: var(--text-main); | |
| min-height: 100vh; | |
| overflow-x: hidden; | |
| display: flex; | |
| flex-direction: column; | |
| position: relative; | |
| } | |
| /* --- Ambient Background Orbs (The Frosted Rounded Gradients) --- */ | |
| .ambient-container { | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| z-index: -1; | |
| overflow: hidden; | |
| pointer-events: none; | |
| } | |
| .ambient-orb { | |
| position: absolute; | |
| border-radius: 50%; | |
| filter: blur(90px); /* The heavy blur creates the frosted effect */ | |
| opacity: 0.6; | |
| animation: floatOrb 10s infinite ease-in-out alternate; | |
| } | |
| /* Orb 1: Top Left - Violet */ | |
| .orb-1 { | |
| width: 50vw; | |
| height: 50vw; | |
| background: radial-gradient(circle, var(--glow-1) 0%, rgba(0,0,0,0) 70%); | |
| top: -10%; | |
| right: -10%; /* RTL positioning */ | |
| } | |
| /* Orb 2: Center Top - Blue */ | |
| .orb-2 { | |
| width: 40vw; | |
| height: 40vw; | |
| background: radial-gradient(circle, var(--glow-2) 0%, rgba(0,0,0,0) 70%); | |
| top: 10%; | |
| left: 30%; | |
| animation-delay: -2s; | |
| } | |
| /* Orb 3: Bottom Right - Pink */ | |
| .orb-3 { | |
| width: 45vw; | |
| height: 45vw; | |
| background: radial-gradient(circle, var(--glow-3) 0%, rgba(0,0,0,0) 70%); | |
| bottom: -5%; | |
| left: -5%; | |
| animation-delay: -5s; | |
| } | |
| @keyframes floatOrb { | |
| 0% { transform: translate(0, 0) scale(1); } | |
| 100% { transform: translate(20px, -20px) scale(1.05); } | |
| } | |
| /* --- Modern Glassmorphism Class --- */ | |
| .glass-panel { | |
| background: var(--glass-surface); | |
| backdrop-filter: blur(20px); | |
| -webkit-backdrop-filter: blur(20px); | |
| border: 1px solid var(--glass-border); | |
| border-radius: var(--radius-card); | |
| box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); | |
| transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease; | |
| position: relative; | |
| z-index: 1; /* Sit above orbs */ | |
| } | |
| .glass-panel:hover { | |
| border-color: rgba(255, 255, 255, 0.15); | |
| box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); | |
| } | |
| /* --- Header --- */ | |
| header { | |
| padding: 20px 40px; | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| z-index: 10; | |
| background: rgba(5, 5, 8, 0.6); | |
| backdrop-filter: blur(12px); | |
| border-bottom: 1px solid var(--glass-border); | |
| } | |
| .brand { | |
| font-size: 1.3rem; | |
| font-weight: 700; | |
| color: var(--text-main); | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| letter-spacing: -0.5px; | |
| text-shadow: 0 0 20px rgba(255,255,255,0.1); | |
| } | |
| .brand i { | |
| color: var(--accent-primary); | |
| font-size: 1.2rem; | |
| } | |
| .user-profile { | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| } | |
| .avatar { | |
| width: 40px; | |
| height: 40px; | |
| border-radius: 50%; | |
| border: 2px solid rgba(255, 255, 255, 0.1); | |
| object-fit: cover; | |
| box-shadow: 0 0 15px rgba(139, 92, 246, 0.3); | |
| } | |
| /* --- Layout --- */ | |
| main { | |
| flex: 1; | |
| padding: 40px; | |
| display: grid; | |
| grid-template-columns: 1.1fr 0.9fr 1fr; | |
| grid-template-rows: 1fr; | |
| gap: var(--gap-grid); | |
| max-width: 1600px; | |
| margin: 0 auto; | |
| width: 100%; | |
| align-items: start; | |
| position: relative; | |
| z-index: 1; | |
| } | |
| .section-header { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| margin-bottom: 24px; | |
| padding: 0 8px; | |
| } | |
| .section-title { | |
| font-size: 1rem; | |
| font-weight: 600; | |
| color: var(--text-muted); | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| .section-title i { | |
| font-size: 0.9rem; | |
| opacity: 0.8; | |
| color: var(--accent-primary); | |
| } | |
| /* --- 1. Public Chat --- */ | |
| .section-public { | |
| grid-column: span 1; | |
| height: 600px; | |
| display: flex; | |
| flex-direction: column; | |
| } | |
| .message-list { | |
| flex: 1; | |
| overflow-y: auto; | |
| display: flex; | |
| flex-direction: column; | |
| gap: 12px; | |
| padding: 8px; | |
| } | |
| /* Minimal Scrollbar */ | |
| .message-list::-webkit-scrollbar { | |
| width: 4px; | |
| } | |
| .message-list::-webkit-scrollbar-thumb { | |
| background: rgba(255, 255, 255, 0.1); | |
| border-radius: 4px; | |
| } | |
| .message-card { | |
| padding: 16px; | |
| background: rgba(255, 255, 255, 0.02); | |
| border-radius: var(--radius-btn); | |
| border: 1px solid transparent; | |
| transition: all 0.2s ease; | |
| } | |
| .message-card:hover { | |
| background: rgba(255, 255, 255, 0.05); | |
| border-color: rgba(255, 255, 255, 0.1); | |
| transform: translateX(-4px); /* Subtle RTL movement */ | |
| } | |
| .msg-meta { | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| margin-bottom: 8px; | |
| } | |
| .msg-name { | |
| font-size: 0.95rem; | |
| font-weight: 600; | |
| color: var(--text-main); | |
| } | |
| .msg-role { | |
| font-size: 0.7rem; | |
| padding: 2px 8px; | |
| border-radius: 6px; | |
| background: rgba(139, 92, 246, 0.15); | |
| color: #c4b5fd; | |
| font-weight: 500; | |
| } | |
| .msg-preview { | |
| font-size: 0.9rem; | |
| color: var(--text-muted); | |
| line-height: 1.6; | |
| } | |
| /* --- 2. Announcement --- */ | |
| .section-announcement { | |
| grid-column: span 1; | |
| height: 600px; | |
| display: flex; | |
| flex-direction: column; | |
| justify-content: center; | |
| align-items: center; | |
| text-align: center; | |
| padding: 40px 24px; | |
| background: linear-gradient(145deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.00) 100%); | |
| border: 1px solid rgba(255, 255, 255, 0.1); | |
| } | |
| .announcement-icon { | |
| font-size: 3rem; | |
| margin-bottom: 24px; | |
| background: linear-gradient(to bottom right, var(--accent-secondary), var(--accent-primary)); | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| filter: drop-shadow(0 0 15px rgba(59, 130, 246, 0.3)); | |
| } | |
| .announcement-content h3 { | |
| font-size: 1.4rem; | |
| margin-bottom: 16px; | |
| font-weight: 700; | |
| color: var(--text-main); | |
| } | |
| .announcement-content p { | |
| font-size: 0.95rem; | |
| color: var(--text-muted); | |
| line-height: 1.8; | |
| max-width: 90%; | |
| margin: 0 auto; | |
| } | |
| .announcement-date { | |
| margin-top: 40px; | |
| font-size: 0.8rem; | |
| color: rgba(255, 255, 255, 0.3); | |
| letter-spacing: 1px; | |
| text-transform: uppercase; | |
| } | |
| /* --- 3. Private Rooms --- */ | |
| .section-rooms { | |
| grid-column: span 1; | |
| height: 600px; | |
| display: flex; | |
| flex-direction: column; | |
| } | |
| .btn-create { | |
| background: linear-gradient(135deg, var(--accent-primary), var(--accent-tertiary)); | |
| color: white; | |
| border: none; | |
| padding: 8px 16px; | |
| border-radius: var(--radius-btn); | |
| font-family: inherit; | |
| font-size: 0.85rem; | |
| font-weight: 600; | |
| cursor: pointer; | |
| transition: all 0.3s; | |
| display: flex; | |
| align-items: center; | |
| gap: 8px; | |
| box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); | |
| } | |
| .btn-create:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4); | |
| } | |
| .rooms-list { | |
| flex: 1; | |
| overflow-y: auto; | |
| display: flex; | |
| flex-direction: column; | |
| gap: 10px; | |
| margin-top: 10px; | |
| } | |
| .room-card { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| padding: 14px 18px; | |
| border-radius: var(--radius-btn); | |
| cursor: pointer; | |
| transition: all 0.2s ease; | |
| border: 1px solid transparent; | |
| } | |
| .room-card:hover { | |
| background: rgba(255, 255, 255, 0.04); | |
| border-color: rgba(255, 255, 255, 0.05); | |
| } | |
| .room-info { | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| } | |
| .room-icon { | |
| color: var(--text-muted); | |
| font-size: 1rem; | |
| opacity: 0.5; | |
| } | |
| .room-name { | |
| font-size: 0.95rem; | |
| font-weight: 500; | |
| color: var(--text-main); | |
| } | |
| .btn-copy { | |
| background: rgba(255, 255, 255, 0.05); | |
| border: none; | |
| color: var(--text-muted); | |
| cursor: pointer; | |
| padding: 8px; | |
| border-radius: 8px; | |
| opacity: 0; | |
| transition: all 0.2s; | |
| transform: translateX(10px); | |
| } | |
| .room-card:hover .btn-copy { | |
| opacity: 1; | |
| transform: translateX(0); | |
| } | |
| .btn-copy:hover { | |
| background: rgba(255, 255, 255, 0.15); | |
| color: var(--text-main); | |
| } | |
| /* --- Footer & Branding --- */ | |
| footer { | |
| text-align: center; | |
| padding: 30px; | |
| font-size: 0.8rem; | |
| color: rgba(255, 255, 255, 0.2); | |
| margin-top: auto; | |
| background: linear-gradient(to top, rgba(0,0,0,0.8), transparent); | |
| } | |
| footer a { | |
| color: var(--text-muted); | |
| text-decoration: none; | |
| transition: color 0.2s; | |
| font-weight: 500; | |
| } | |
| footer a:hover { | |
| color: var(--accent-primary); | |
| text-shadow: 0 0 10px rgba(139, 92, 246, 0.5); | |
| } | |
| /* --- Toast Notification --- */ | |
| .toast { | |
| position: fixed; | |
| bottom: 40px; | |
| left: 50%; | |
| transform: translateX(-50%) translateY(30px); | |
| background: rgba(20, 20, 25, 0.9); | |
| backdrop-filter: blur(16px); | |
| border: 1px solid rgba(255, 255, 255, 0.1); | |
| color: var(--text-main); | |
| padding: 12px 24px; | |
| border-radius: 50px; | |
| font-size: 0.9rem; | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); | |
| opacity: 0; | |
| pointer-events: none; | |
| transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); | |
| z-index: 100; | |
| } | |
| .toast.show { | |
| transform: translateX(-50%) translateY(0); | |
| opacity: 1; | |
| } | |
| .toast i { | |
| font-size: 1.1rem; | |
| } | |
| /* --- Modal --- */ | |
| .modal-overlay { | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| background: rgba(0, 0, 0, 0.7); | |
| backdrop-filter: blur(8px); | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| z-index: 50; | |
| opacity: 0; | |
| pointer-events: none; | |
| transition: opacity 0.3s ease; | |
| } | |
| .modal-overlay.active { | |
| opacity: 1; | |
| pointer-events: auto; | |
| } | |
| .modal { | |
| background: rgba(20, 20, 25, 0.95); | |
| border: 1px solid var(--glass-border); | |
| padding: 40px; | |
| border-radius: var(--radius-card); | |
| width: 90%; | |
| max-width: 400px; | |
| transform: scale(0.9) translateY(20px); | |
| transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); | |
| box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7); | |
| } | |
| .modal-overlay.active .modal { | |
| transform: scale(1) translateY(0); | |
| } | |
| .modal h3 { | |
| margin-bottom: 24px; | |
| color: var(--text-main); | |
| font-weight: 600; | |
| } | |
| .modal input { | |
| width: 100%; | |
| background: rgba(255, 255, 255, 0.05); | |
| border: 1px solid var(--glass-border); | |
| padding: 14px 18px; | |
| border-radius: var(--radius-btn); | |
| color: white; | |
| font-family: inherit; | |
| margin-bottom: 24px; | |
| transition: all 0.2s; | |
| font-size: 0.95rem; | |
| } | |
| .modal input:focus { | |
| border-color: var(--accent-primary); | |
| background: rgba(255, 255, 255, 0.08); | |
| box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1); | |
| } | |
| .modal-actions { | |
| display: flex; | |
| justify-content: flex-end; | |
| gap: 12px; | |
| } | |
| .btn-modal { | |
| padding: 10px 20px; | |
| border-radius: var(--radius-btn); | |
| border: none; | |
| font-family: inherit; | |
| cursor: pointer; | |
| font-size: 0.9rem; | |
| font-weight: 500; | |
| } | |
| .btn-cancel { | |
| background: transparent; | |
| color: var(--text-muted); | |
| } | |
| .btn-cancel:hover { | |
| color: var(--text-main); | |
| background: rgba(255,255,255,0.05); | |
| } | |
| .btn-confirm { | |
| background: var(--accent-primary); | |
| color: white; | |
| } | |
| .btn-confirm:hover { | |
| background: #7c3aed; | |
| box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3); | |
| } | |
| /* --- Responsive --- */ | |
| @media (max-width: 1200px) { | |
| main { | |
| grid-template-columns: 1fr 1fr; | |
| } | |
| .section-announcement { | |
| grid-column: span 2; | |
| height: auto; | |
| min-height: 220px; | |
| order: -1; | |
| } | |
| } | |
| @media (max-width: 768px) { | |
| header { | |
| padding: 16px 24px; | |
| } | |
| main { | |
| grid-template-columns: 1fr; | |
| padding: 24px; | |
| gap: 24px; | |
| } | |
| .section-public, | |
| .section-announcement, | |
| .section-rooms { | |
| grid-column: span 1; | |
| height: auto; | |
| min-height: 450px; | |
| } | |
| .section-announcement { | |
| min-height: 280px; | |
| } | |
| .btn-copy { | |
| opacity: 1; | |
| transform: none; | |
| } | |
| /* Adjust orbs for mobile to prevent excessive brightness */ | |
| .orb-1 { width: 80vw; height: 80vw; top: -20%; right: -20%; } | |
| .orb-3 { width: 80vw; height: 80vw; bottom: -20%; left: -20%; } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <!-- Ambient Background Container (Frosted Rounded Gradients) --> | |
| <div class="ambient-container"> | |
| <div class="ambient-orb orb-1"></div> | |
| <div class="ambient-orb orb-2"></div> | |
| <div class="ambient-orb orb-3"></div> | |
| </div> | |
| <!-- Header --> | |
| <header> | |
| <div class="brand"> | |
| <i class="fa-solid fa-layer-group"></i> | |
| <span>چتروم</span> | |
| </div> | |
| <div class="user-profile"> | |
| <img src="https://picsum.photos/seed/user123/100/100.jpg" alt="Avatar" class="avatar"> | |
| </div> | |
| </header> | |
| <!-- Main Grid --> | |
| <main> | |
| <!-- 1. Public Chat --> | |
| <section class="glass-panel section-public"> | |
| <div class="section-header"> | |
| <span class="section-title"><i class="fa-solid fa-earth-asia"></i> گفتگوی عمومی</span> | |
| </div> | |
| <div class="message-list" id="publicList"> | |
| <!-- JS Content --> | |
| </div> | |
| </section> | |
| <!-- 2. Announcement --> | |
| <section class="glass-panel section-announcement"> | |
| <div class="announcement-content"> | |
| <i class="fa-solid fa-sparkles announcement-icon"></i> | |
| <h3>بهروزرسانی سیستم</h3> | |
| <p> | |
| سیستم امنیتی چتروم به نسخه ۲.۰ ارتقا یافت. | |
| لطفاً در صورت مشاهده هرگونه مشکل فنی، موضوع را از بخش پشتیبانی به ما اطلاع دهید. | |
| </p> | |
| <div class="announcement-date">۲۰ مهر ۱۴۰۳</div> | |
| </div> | |
| </section> | |
| <!-- 3. Private Rooms --> | |
| <section class="glass-panel section-rooms"> | |
| <div class="section-header"> | |
| <span class="section-title"><i class="fa-solid fa-lock"></i> اتاقهای خصوصی</span> | |
| <button class="btn-create" onclick="openModal()"> | |
| <i class="fa-solid fa-plus"></i> جدید | |
| </button> | |
| </div> | |
| <div class="rooms-list" id="roomsList"> | |
| <!-- JS Content --> | |
| </div> | |
| </section> | |
| </main> | |
| <!-- Footer --> | |
| <footer> | |
| <p>© ۲۰۲۳ تمامی حقوق محفوظ است.</p> | |
| <p style="margin-top:10px;"> | |
| <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank"> | |
| Built with anycoder | |
| <i class="fa-solid fa-arrow-up-right-from-square" style="font-size: 0.7em; vertical-align: middle; margin-right: 4px;"></i> | |
| </a> | |
| </p> | |
| </footer> | |
| <!-- Create Room Modal --> | |
| <div class="modal-overlay" id="roomModal"> | |
| <div class="modal"> | |
| <h3>ایجاد اتاق جدید</h3> | |
| <input type="text" id="newRoomName" placeholder="نام اتاق را وارد کنید..." autocomplete="off"> | |
| <div class="modal-actions"> | |
| <button class="btn-modal btn-cancel" onclick="closeModal()">لغو</button> | |
| <button class="btn-modal btn-confirm" onclick="confirmCreateRoom()">ایجاد</button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Toast Notification --> | |
| <div class="toast" id="toast"> | |
| <i class="fa-solid fa-check-circle"></i> | |
| <span id="toastMessage">عملیات موفقیتآمیز بود</span> | |
| </div> | |
| <script> | |
| // Mock Data | |
| const publicMessages = [ | |
| { id: 1, name: 'مدیر سیستم', role: 'Admin', text: 'خوش آمدید به لابی اصلی. لطفاً قوانین را رعایت کنید.' }, | |
| { id: 2, name: 'پشتیبان فنی', role: 'Support', text: 'سرورها در ساعت ۳ بامداد بهروزرسانی میشوند.' }, | |
| { id: 3, name: 'مدیر سیستم', role: 'Admin', text: 'کاربران جدید لطفاً پروفایل خود را تکمیل کنند.' }, | |
| { id: 4, name: 'پشتیبان فنی', role: 'Support', text: 'گزارش باگها را از طریق تیکت ارسال کنید.' }, | |
| { id: 5, name: 'مدیر سیستم', role: 'Admin', text: 'چت عمومی فقط برای گفتگوی عمومی است.' }, | |
| ]; | |
| const initialRooms = [ | |
| { id: 101, name: 'گروه برنامهنویسی', link: 'https://chat.app/room/dev' }, | |
| { id: 102, name: 'گروه طراحی UI/UX', link: 'https://chat.app/room/design' }, | |
| { id: 103, name: 'اتاق گفتگوی آزاد', link: 'https://chat.app/room/general' }, | |
| ]; | |
| // DOM Elements | |
| const publicListEl = document.getElementById('publicList'); | |
| const roomsListEl = document.getElementById('roomsList'); | |
| const modalEl = document.getElementById('roomModal'); | |
| const newRoomInput = document.getElementById('newRoomName'); | |
| const toastEl = document.getElementById('toast'); | |
| const toastMsgEl = document.getElementById('toastMessage'); | |
| // Initialize App | |
| function init() { | |
| renderPublicMessages(); | |
| renderRooms(); | |
| } | |
| // Render Public Chat | |
| function renderPublicMessages() { | |
| publicListEl.innerHTML = ''; | |
| publicMessages.forEach(msg => { | |
| const item = document.createElement('div'); | |
| item.className = 'message-card'; | |
| item.innerHTML = ` | |
| <div class="msg-meta"> | |
| <span class="msg-name">${msg.name}</span> | |
| <span class="msg-role">${msg.role}</span> | |
| </div> | |
| <div class="msg-preview">${msg.text}</div> | |
| `; | |
| publicListEl.appendChild(item); | |
| }); | |
| } | |
| // Render Private Rooms | |
| function renderRooms() { | |
| roomsListEl.innerHTML = ''; | |
| initialRooms.forEach(room => { | |
| const item = document.createElement('div'); | |
| item.className = 'room-card'; | |
| item.onclick = (e) => { | |
| if(!e.target.closest('.btn-copy')) { | |
| navigateToRoom(room.name); | |
| } | |
| }; | |
| item.innerHTML = ` | |
| <div class="room-info"> | |
| <i class="fa-solid fa-hashtag room-icon"></i> | |
| <span class="room-name">${room.name}</span> | |
| </div> | |
| <button class="btn-copy" onclick="copyLink('${room.link}')" title="کپی لینک"> | |
| <i class="fa-regular fa-copy"></i> | |
| </button> | |
| `; | |
| roomsListEl.appendChild(item); | |
| }); | |
| } | |
| // Interaction: Copy Link | |
| function copyLink(link) { | |
| navigator.clipboard.writeText(link).then(() => { | |
| showToast('لینک دعوت کپی شد'); | |
| }).catch(() => { | |
| showToast('خطا در کپی لینک', true); | |
| }); | |
| } | |
| // Interaction: Navigate (Simulated) | |
| function navigateToRoom(roomName) { | |
| showToast(`در حال ورود به ${roomName}...`); | |
| } | |
| // Interaction: Modal Logic | |
| function openModal() { | |
| modalEl.classList.add('active'); | |
| newRoomInput.focus(); | |
| } | |
| function closeModal() { | |
| modalEl.classList.remove('active'); | |
| newRoomInput.value = ''; | |
| } | |
| modalEl.addEventListener('click', (e) => { | |
| if (e.target === modalEl) closeModal(); | |
| }); | |
| // Interaction: Create Room | |
| function confirmCreateRoom() { | |
| const name = newRoomInput.value.trim(); | |
| if (name) { | |
| const newRoom = { | |
| id: Date.now(), | |
| name: name, | |
| link: `https://chat.app/room/${Math.random().toString(36).substr(2, 6)}` | |
| }; | |
| initialRooms.unshift(newRoom); | |
| renderRooms(); | |
| closeModal(); | |
| showToast('اتاق جدید ایجاد شد'); | |
| } else { | |
| // Simple shake animation for error could go here | |
| newRoomInput.focus(); | |
| } | |
| } | |
| // Utility: Show Toast | |
| function showToast(message, isError = false) { | |
| toastMsgEl.textContent = message; | |
| const icon = toastEl.querySelector('i'); | |
| if (isError) { | |
| icon.className = 'fa-solid fa-circle-exclamation'; | |
| icon.style.color = '#ef4444'; | |
| } else { | |
| icon.className = 'fa-solid fa-check-circle'; | |
| icon.style.color = 'var(--accent-primary)'; | |
| } | |
| toastEl.classList.add('show'); | |
| // Clear previous timeout if exists (optional enhancement) | |
| if (window.toastTimeout) clearTimeout(window.toastTimeout); | |
| window.toastTimeout = setTimeout(() => { | |
| toastEl.classList.remove('show'); | |
| }, 3000); | |
| } | |
| // Run | |
| init(); | |
| </script> | |
| </body> | |
| </html> |