Spaces:
Running
Running
| <html lang="fa" dir="rtl"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"> | |
| <title>پیام رسان مینیمال | MinimalChat</title> | |
| <style> | |
| body { | |
| font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | |
| background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%); | |
| background-attachment: fixed; | |
| -webkit-tap-highlight-color: transparent; | |
| margin: 0; | |
| padding: 0; | |
| color: white; | |
| } | |
| .glass-panel { | |
| background: rgba(255, 255, 255, 0.08); | |
| backdrop-filter: blur(12px); | |
| -webkit-backdrop-filter: blur(12px); | |
| border: 1px solid rgba(255, 255, 255, 0.1); | |
| } | |
| .input-minimal { | |
| background: transparent; | |
| border-bottom: 1px solid rgba(255, 255, 255, 0.2); | |
| transition: all 0.3s; | |
| } | |
| .input-minimal:focus { | |
| border-color: rgba(255, 255, 255, 0.6); | |
| outline: none; | |
| } | |
| .message-bubble-me { | |
| background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); | |
| border-radius: 16px 16px 4px 16px; | |
| } | |
| .message-bubble-other { | |
| background: rgba(255, 255, 255, 0.12); | |
| border-radius: 16px 16px 16px 4px; | |
| } | |
| .fade-in { | |
| animation: fadeIn 0.3s ease-out; | |
| } | |
| @keyframes fadeIn { | |
| from { | |
| opacity: 0; | |
| transform: translateY(10px); | |
| } | |
| to { | |
| opacity: 1; | |
| transform: translateY(0); | |
| } | |
| } | |
| .slide-in { | |
| animation: slideIn 0.3s ease-out; | |
| } | |
| @keyframes slideIn { | |
| from { | |
| transform: translateX(100%); | |
| } | |
| to { | |
| transform: translateX(0); | |
| } | |
| } | |
| .slide-out { | |
| animation: slideOut 0.3s ease-out; | |
| } | |
| @keyframes slideOut { | |
| from { | |
| transform: translateX(0); | |
| } | |
| to { | |
| transform: translateX(100%); | |
| } | |
| } | |
| /* Custom Scrollbar */ | |
| ::-webkit-scrollbar { | |
| width: 4px; | |
| height: 4px; | |
| } | |
| ::-webkit-scrollbar-track { | |
| background: transparent; | |
| } | |
| ::-webkit-scrollbar-thumb { | |
| background: rgba(255, 255, 255, 0.2); | |
| border-radius: 4px; | |
| } | |
| ::-webkit-scrollbar-thumb:hover { | |
| background: rgba(255, 255, 255, 0.3); | |
| } | |
| /* Mobile Optimizations */ | |
| @media (max-width: 768px) { | |
| .mobile-sidebar { | |
| position: fixed; | |
| top: 0; | |
| right: 0; | |
| height: 100vh; | |
| height: 100dvh; | |
| width: 85%; | |
| max-width: 300px; | |
| z-index: 40; | |
| transform: translateX(100%); | |
| transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); | |
| } | |
| .mobile-sidebar.open { | |
| transform: translateX(0); | |
| } | |
| .sidebar-overlay { | |
| position: fixed; | |
| inset: 0; | |
| background: rgba(0, 0, 0, 0.5); | |
| backdrop-filter: blur(4px); | |
| z-index: 35; | |
| opacity: 0; | |
| pointer-events: none; | |
| transition: opacity 0.3s; | |
| } | |
| .sidebar-overlay.active { | |
| opacity: 1; | |
| pointer-events: auto; | |
| } | |
| .chat-container { | |
| position: fixed; | |
| inset: 0; | |
| z-index: 30; | |
| } | |
| .safe-bottom { | |
| padding-bottom: env(safe-area-inset-bottom, 20px); | |
| } | |
| } | |
| /* Touch friendly buttons */ | |
| .touch-target { | |
| min-height: 44px; | |
| min-width: 44px; | |
| } | |
| /* Prevent zoom on input focus for iOS */ | |
| @media screen and (max-width: 768px) { | |
| input, | |
| textarea, | |
| select { | |
| font-size: 16px; | |
| } | |
| } | |
| /* Message animations */ | |
| .message-enter { | |
| animation: messagePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); | |
| } | |
| @keyframes messagePop { | |
| 0% { | |
| opacity: 0; | |
| transform: scale(0.8) translateY(20px); | |
| } | |
| 100% { | |
| opacity: 1; | |
| transform: scale(1) translateY(0); | |
| } | |
| } | |
| /* Loading shimmer */ | |
| .shimmer { | |
| background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 75%); | |
| background-size: 200% 100%; | |
| animation: shimmer 1.5s infinite; | |
| } | |
| @keyframes shimmer { | |
| 0% { | |
| background-position: 200% 0; | |
| } | |
| 100% { | |
| background-position: -200% 0; | |
| } | |
| } | |
| /* Sticker picker styles */ | |
| .sticker-picker { | |
| position: absolute; | |
| bottom: 70px; | |
| right: 0; | |
| width: 100%; | |
| max-height: 300px; | |
| background: rgba(30, 27, 75, 0.95); | |
| border-radius: 12px 12px 0 0; | |
| border: 1px solid rgba(255, 255, 255, 0.1); | |
| overflow-y: auto; | |
| padding: 10px; | |
| display: none; | |
| z-index: 100; | |
| } | |
| .sticker-picker.active { | |
| display: block; | |
| } | |
| .sticker-category { | |
| margin-bottom: 10px; | |
| } | |
| .sticker-category-title { | |
| font-size: 12px; | |
| color: rgba(255, 255, 255, 0.6); | |
| margin-bottom: 5px; | |
| padding-right: 5px; | |
| } | |
| .sticker-grid { | |
| display: grid; | |
| grid-template-columns: repeat(5, 1fr); | |
| gap: 5px; | |
| } | |
| .sticker-item { | |
| width: 100%; | |
| aspect-ratio: 1; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| cursor: pointer; | |
| border-radius: 8px; | |
| transition: background 0.2s; | |
| } | |
| .sticker-item:hover { | |
| background: rgba(255, 255, 255, 0.1); | |
| } | |
| .sticker-item img { | |
| max-width: 80%; | |
| max-height: 80%; | |
| } | |
| /* Profile edit modal */ | |
| .profile-edit-modal { | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| right: 0; | |
| bottom: 0; | |
| background: rgba(0, 0, 0, 0.7); | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| z-index: 100; | |
| opacity: 0; | |
| pointer-events: none; | |
| transition: opacity 0.3s; | |
| } | |
| .profile-edit-modal.active { | |
| opacity: 1; | |
| pointer-events: auto; | |
| } | |
| .profile-edit-content { | |
| background: #1e1b4b; | |
| border-radius: 16px; | |
| padding: 20px; | |
| width: 90%; | |
| max-width: 400px; | |
| border: 1px solid rgba(255, 255, 255, 0.1); | |
| } | |
| .avatar-grid { | |
| display: grid; | |
| grid-template-columns: repeat(4, 1fr); | |
| gap: 10px; | |
| margin-top: 15px; | |
| } | |
| .avatar-option { | |
| width: 100%; | |
| aspect-ratio: 1; | |
| border-radius: 50%; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| font-weight: bold; | |
| cursor: pointer; | |
| transition: transform 0.2s; | |
| } | |
| .avatar-option:hover { | |
| transform: scale(1.1); | |
| } | |
| .avatar-option.selected { | |
| border: 3px solid #3b82f6; | |
| } | |
| /* Room settings modal */ | |
| .room-settings-modal { | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| right: 0; | |
| bottom: 0; | |
| background: rgba(0, 0, 0, 0.7); | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| z-index: 100; | |
| opacity: 0; | |
| pointer-events: none; | |
| transition: opacity 0.3s; | |
| } | |
| .room-settings-modal.active { | |
| opacity: 1; | |
| pointer-events: auto; | |
| } | |
| .room-settings-content { | |
| background: #1e1b4b; | |
| border-radius: 16px; | |
| padding: 20px; | |
| width: 90%; | |
| max-width: 400px; | |
| border: 1px solid rgba(255, 255, 255, 0.1); | |
| } | |
| .danger-zone { | |
| border-top: 1px solid rgba(255, 0, 0, 0.3); | |
| padding-top: 15px; | |
| margin-top: 15px; | |
| } | |
| .danger-button { | |
| background: rgba(255, 0, 0, 0.2); | |
| color: #ff6b6b; | |
| border: 1px solid rgba(255, 0, 0, 0.3); | |
| } | |
| .danger-button:hover { | |
| background: rgba(255, 0, 0, 0.3); | |
| } | |
| </style> | |
| </head> | |
| <body class="text-white h-screen h-[100dvh] overflow-hidden selection:bg-blue-500/30 bg-slate-900"> | |
| <!-- Toast Container --> | |
| <div id="toast-container" class="fixed top-4 left-1/2 transform -translate-x-1/2 z-50 flex flex-col gap-2 w-full max-w-sm px-4 pointer-events-none"> | |
| </div> | |
| <!-- Auth View --> | |
| <div id="auth-view" class="h-full w-full flex items-center justify-center p-4 overflow-y-auto"> | |
| <div class="glass-panel p-6 md:p-8 rounded-2xl w-full max-w-md fade-in my-auto"> | |
| <div class="text-center mb-6 md:mb-8"> | |
| <div class="w-14 h-14 md:w-16 md:h-16 bg-white/10 rounded-full mx-auto flex items-center justify-center mb-4"> | |
| <span style="font-size: 24px;">💬</span> | |
| </div> | |
| <h1 class="text-xl md:text-2xl font-bold">پیام رسان مینیمال</h1> | |
| <p class="text-white/50 text-xs md:text-sm mt-1">پیام رسان مینیمال با PHP</p> | |
| </div> | |
| <!-- Tabs --> | |
| <div class="flex gap-4 mb-6 border-b border-white/10 pb-1"> | |
| <button onclick="switchAuthTab('login')" id="tab-login" class="flex-1 pb-2 text-sm font-medium border-b-2 border-white text-white transition-colors touch-target flex items-center justify-center">ورود</button> | |
| <button onclick="switchAuthTab('register')" id="tab-register" class="flex-1 pb-2 text-sm font-medium border-b-2 border-transparent text-white/50 hover:text-white transition-colors touch-target flex items-center justify-center">ثبت نام</button> | |
| </div> | |
| <!-- Login Form --> | |
| <form id="login-form" class="space-y-4 md:space-y-5" onsubmit="handleLogin(event)"> | |
| <div> | |
| <label class="block text-xs text-white/60 mb-2">شماره موبایل</label> | |
| <input type="tel" id="login-phone" placeholder="09XXXXXXXXX" inputmode="tel" class="w-full input-minimal py-3 text-white placeholder-white/30 touch-target" required> | |
| </div> | |
| <div> | |
| <label class="block text-xs text-white/60 mb-2">رمز عبور</label> | |
| <input type="password" id="login-password" placeholder="••••••••" class="w-full input-minimal py-3 text-white placeholder-white/30 touch-target" required> | |
| </div> | |
| <button type="submit" class="w-full bg-white text-slate-900 font-bold py-3 rounded-lg hover:bg-white/90 transition-colors mt-4 touch-target active:scale-95 transform transition-transform"> | |
| ورود | |
| </button> | |
| </form> | |
| <!-- Register Form --> | |
| <form id="register-form" class="space-y-4 md:space-y-5 hidden" onsubmit="handleRegister(event)"> | |
| <div> | |
| <label class="block text-xs text-white/60 mb-2">نام کامل</label> | |
| <input type="text" id="reg-name" placeholder="نام شما" class="w-full input-minimal py-3 text-white placeholder-white/30 touch-target" required> | |
| </div> | |
| <div> | |
| <label class="block text-xs text-white/60 mb-2">شماره موبایل</label> | |
| <input type="tel" id="reg-phone" placeholder="09XXXXXXXXX" inputmode="tel" class="w-full input-minimal py-3 text-white placeholder-white/30 touch-target" required> | |
| </div> | |
| <div> | |
| <label class="block text-xs text-white/60 mb-2">رمز عبور</label> | |
| <input type="password" id="reg-password" placeholder="حداقل ۴ کاراکتر" class="w-full input-minimal py-3 text-white placeholder-white/30 touch-target" required> | |
| </div> | |
| <button type="submit" class="w-full bg-white text-slate-900 font-bold py-3 rounded-lg hover:bg-white/90 transition-colors mt-4 touch-target active:scale-95 transform transition-transform"> | |
| ثبت نام | |
| </button> | |
| </form> | |
| <div class="mt-6 text-center"> | |
| <p class="text-xs text-white/40"> | |
| ساخته شده با PHP و MySQL | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Dashboard View --> | |
| <div id="dashboard-view" class="h-full w-full flex flex-col md:flex-row relative hidden"> | |
| <!-- Mobile Sidebar Overlay --> | |
| <div id="sidebar-overlay" class="sidebar-overlay md:hidden" onclick="toggleSidebar()"></div> | |
| <!-- Sidebar --> | |
| <aside id="sidebar" | |
| class="mobile-sidebar md:relative md:transform-none md:w-72 md:h-full glass-panel border-l border-white/10 flex flex-col bg-slate-900/95 md:bg-transparent"> | |
| <!-- Profile --> | |
| <div class="p-4 md:p-6 border-b border-white/10 flex items-center justify-between"> | |
| <div class="flex items-center gap-3 flex-1"> | |
| <div id="user-avatar" class="w-10 h-10 md:w-12 md:h-12 rounded-full flex items-center justify-center text-blue-300 font-bold text-lg"> | |
| <span id="user-avatar-initial">U</span> | |
| </div> | |
| <div class="flex-1 min-w-0"> | |
| <h2 id="user-name-display" class="font-bold text-sm truncate">کاربر</h2> | |
| <p id="user-phone-display" class="text-xs text-white/50 font-mono">09123456789</p> | |
| </div> | |
| </div> | |
| <button onclick="logout()" class="text-white/40 hover:text-white transition-colors p-2 touch-target mr-2"> | |
| <span style="font-size: 18px;">🚪</span> | |
| </button> | |
| </div> | |
| <!-- Create Room --> | |
| <div class="p-4 border-b border-white/10"> | |
| <div class="flex justify-between items-center mb-3"> | |
| <span class="text-xs font-medium text-white/60">اتاقهای من</span> | |
| <span id="room-count-badge" class="text-xs bg-white/10 px-2 py-0.5 rounded-full">۰/۳</span> | |
| </div> | |
| <button onclick="openCreateRoomModal()" id="btn-create-room" class="w-full py-3 border border-dashed border-white/20 rounded-lg text-sm text-white/70 hover:border-white/40 hover:text-white transition-colors touch-target"> | |
| <span style="font-size: 14px;">➕</span> اتاق جدید | |
| </button> | |
| <p id="room-limit-msg" class="text-xs text-red-400 mt-2 hidden">حداکثر ۳ اتاق مجاز است</p> | |
| </div> | |
| <!-- Room List --> | |
| <div class="flex-1 overflow-y-auto p-2 space-y-1" id="room-list-container"> | |
| <div class="text-center mt-8 text-white/30 text-sm"> | |
| <p>اتاقی وجود ندارد</p> | |
| </div> | |
| </div> | |
| <!-- Mobile Safe Area --> | |
| <div class="h-safe-bottom md:hidden"></div> | |
| </aside> | |
| <!-- Main Content --> | |
| <main class="flex-1 flex flex-col h-full relative bg-slate-900/20 w-full"> | |
| <!-- Mobile Header --> | |
| <header | |
| class="h-14 glass-panel border-b border-white/10 flex items-center justify-between px-4 md:px-6 md:hidden"> | |
| <button onclick="toggleSidebar()" class="touch-target flex items-center justify-center w-10 h-10 -mr-2 text-white/80"> | |
| <span style="font-size: 18px;">☰</span> | |
| </button> | |
| <span class="text-sm font-medium text-white/60">پیام رسان مینیمال</span> | |
| <div class="w-10"></div> <!-- Spacer for balance --> | |
| </header> | |
| <!-- Desktop Header --> | |
| <header class="hidden md:flex h-14 glass-panel border-b border-white/10 items-center justify-between px-6"> | |
| <span class="text-sm font-medium text-white/60">داشبورد</span> | |
| <div class="flex items-center gap-2 text-xs text-white/40"> | |
| <span class="w-2 h-2 bg-green-500 rounded-full animate-pulse"></span> | |
| آنلاین | |
| </div> | |
| </header> | |
| <!-- Welcome Screen --> | |
| <div id="welcome-screen" class="flex-1 flex flex-col items-center justify-center p-8 text-center"> | |
| <div class="w-16 h-16 md:w-20 md:h-20 bg-white/5 rounded-full flex items-center justify-center mb-4"> | |
| <span style="font-size: 28px;">💬</span> | |
| </div> | |
| <h2 class="text-lg md:text-xl font-bold mb-2">به پیام رسان خوش آمدید</h2> | |
| <p class="text-white/50 text-sm max-w-md">اتاق جدید بسازید یا یکی را انتخاب کنید</p> | |
| <button onclick="openCreateRoomModal()" class="mt-6 md:hidden bg-white/10 px-6 py-3 rounded-full text-sm font-medium touch-target"> | |
| <span style="font-size: 14px;">➕</span> ساخت اتاق جدید | |
| </button> | |
| </div> | |
| <!-- Chat Interface --> | |
| <div id="chat-interface" class="hidden absolute inset-0 bg-slate-900 flex flex-col fade-in z-20"> | |
| <!-- Chat Header --> | |
| <div class="h-14 glass-panel border-b border-white/10 flex items-center justify-between px-4 safe-top"> | |
| <div class="flex items-center gap-3 flex-1 min-w-0"> | |
| <button onclick="closeChat()" class="md:hidden text-white/60 hover:text-white touch-target w-10 h-10 flex items-center justify-center -mr-2"> | |
| <span style="font-size: 18px;">←</span> | |
| </button> | |
| <div | |
| class="w-9 h-9 md:w-10 md:h-10 rounded-full bg-indigo-500/20 flex items-center justify-center shrink-0"> | |
| <span style="font-size: 14px;">#</span> | |
| </div> | |
| <div class="min-w-0 flex-1"> | |
| <h3 id="chat-room-name" class="font-bold text-sm truncate">اتاق</h3> | |
| <span id="chat-user-count" class="text-xs text-white/50">۲ عضو</span> | |
| </div> | |
| </div> | |
| <button onclick="openRoomSettings()" class="text-white/40 hover:text-white text-sm touch-target w-10 h-10 flex items-center justify-center"> | |
| <span style="font-size: 18px;">⚙️</span> | |
| </button> | |
| </div> | |
| <!-- Messages --> | |
| <div id="messages-container" class="flex-1 overflow-y-auto p-4 space-y-3 pb-20 md:pb-4"> | |
| <!-- Messages injected here --> | |
| </div> | |
| <!-- Sticker Picker --> | |
| <div id="sticker-picker" class="sticker-picker"> | |
| <div class="sticker-category"> | |
| <div class="sticker-category-title">خنده</div> | |
| <div class="sticker-grid"> | |
| <div class="sticker-item" onclick="insertSticker('😂')">😂</div> | |
| <div class="sticker-item" onclick="insertSticker('😆')">😆</div> | |
| <div class="sticker-item" onclick="insertSticker('😅')">😅</div> | |
| <div class="sticker-item" onclick="insertSticker('🤣')">🤣</div> | |
| <div class="sticker-item" onclick="insertSticker('😁')">😁</div> | |
| </div> | |
| </div> | |
| <div class="sticker-category"> | |
| <div class="sticker-category-title">احساسات</div> | |
| <div class="sticker-grid"> | |
| <div class="sticker-item" onclick="insertSticker('😍')">😍</div> | |
| <div class="sticker-item" onclick="insertSticker('😘')">😘</div> | |
| <div class="sticker-item" onclick="insertSticker('🥰')">🥰</div> | |
| <div class="sticker-item" onclick="insertSticker('😊')">😊</div> | |
| <div class="sticker-item" onclick="insertSticker('😢')">😢</div> | |
| </div> | |
| </div> | |
| <div class="sticker-category"> | |
| <div class="sticker-category-title">دیگر</div> | |
| <div class="sticker-grid"> | |
| <div class="sticker-item" onclick="insertSticker('👍')">👍</div> | |
| <div class="sticker-item" onclick="insertSticker('👎')">👎</div> | |
| <div class="sticker-item" onclick="insertSticker('❤️')">❤️</div> | |
| <div class="sticker-item" onclick="insertSticker('🔥')">🔥</div> | |
| <div class="sticker-item" onclick="insertSticker('🎉')">🎉</div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Input --> | |
| <div | |
| class="absolute bottom-0 left-0 right-0 p-3 md:p-4 glass-panel border-t border-white/10 safe-bottom bg-slate-900/90 backdrop-blur-xl"> | |
| <form onsubmit="sendMessage(event)" class="flex gap-2 max-w-4xl mx-auto"> | |
| <button type="button" onclick="toggleStickerPicker()" class="bg-white/10 border border-white/10 rounded-full w-11 h-11 flex items-center justify-center transition-colors touch-target active:scale-95 transform shrink-0"> | |
| <span style="font-size: 18px;">😊</span> | |
| </button> | |
| <input type="text" id="message-input" placeholder="پیام خود را بنویسید..." | |
| class="flex-1 bg-white/10 border border-white/10 rounded-full px-4 py-3 text-sm text-white placeholder-white/30 focus:outline-none focus:border-white/30 focus:bg-white/15 transition-all touch-target" | |
| autocomplete="off"> | |
| <button type="submit" class="bg-blue-600 hover:bg-blue-500 text-white w-11 h-11 rounded-full flex items-center justify-center transition-colors touch-target active:scale-95 transform shadow-lg shadow-blue-600/30 shrink-0"> | |
| <span style="font-size: 18px;">📤</span> | |
| </button> | |
| </form> | |
| </div> | |
| </div> | |
| </main> | |
| </div> | |
| <!-- Create Room Modal --> | |
| <div id="create-room-modal" | |
| class="fixed inset-0 z-50 hidden flex items-end md:items-center justify-center p-0 md:p-4 bg-black/60 backdrop-blur-sm transition-opacity"> | |
| <div | |
| class="glass-panel w-full md:max-w-sm rounded-t-2xl md:rounded-2xl p-6 fade-in bg-slate-900 border-t md:border border-white/10"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="font-bold text-lg">اتاق جدید</h3> | |
| <button onclick="closeCreateRoomModal()" class="text-white/40 hover:text-white touch-target w-10 h-10 flex items-center justify-center"> | |
| <span style="font-size: 20px;">✕</span> | |
| </button> | |
| </div> | |
| <form onsubmit="handleCreateRoom(event)" class="space-y-4"> | |
| <div> | |
| <label class="block text-xs text-white/60 mb-2">نام اتاق</label> | |
| <input type="text" id="new-room-name" placeholder="مثلاً: گروه دوستان" | |
| class="w-full bg-white/5 border border-white/10 rounded-xl px-4 py-3 text-white placeholder-white/30 focus:outline-none focus:border-white/30 touch-target" | |
| required> | |
| </div> | |
| <div class="flex gap-3 pt-2"> | |
| <button type="button" onclick="closeCreateRoomModal()" class="flex-1 py-3 rounded-xl border border-white/10 text-sm hover:bg-white/5 transition-colors touch-target"> | |
| انصراف | |
| </button> | |
| <button type="submit" class="flex-1 py-3 rounded-xl bg-white text-slate-900 text-sm font-bold hover:bg-white/90 transition-colors touch-target active:scale-95 transform"> | |
| ساختن | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| <!-- Profile Edit Modal --> | |
| <div id="profile-edit-modal" class="profile-edit-modal"> | |
| <div class="profile-edit-content"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="font-bold text-lg">ویرایش پروفایل</h3> | |
| <button onclick="closeProfileEditModal()" class="text-white/40 hover:text-white touch-target w-10 h-10 flex items-center justify-center"> | |
| <span style="font-size: 20px;">✕</span> | |
| </button> | |
| </div> | |
| <form onsubmit="saveProfile(event)" class="space-y-4"> | |
| <div> | |
| <label class="block text-xs text-white/60 mb-2">نام کامل</label> | |
| <input type="text" id="edit-profile-name" placeholder="نام شما" | |
| class="w-full bg-white/5 border border-white/10 rounded-xl px-4 py-3 text-white placeholder-white/30 focus:outline-none focus:border-white/30 touch-target" | |
| required> | |
| </div> | |
| <div> | |
| <label class="block text-xs text-white/60 mb-2">رنگ آواتار</label> | |
| <div class="avatar-grid"> | |
| <div class="avatar-option" style="background-color: #3b82f620;" onclick="selectAvatarColor('#3b82f6')">A</div> | |
| <div class="avatar-option" style="background-color: #ef444420;" onclick="selectAvatarColor('#ef4444')">B</div> | |
| <div class="avatar-option" style="background-color: #10b98120;" onclick="selectAvatarColor('#10b981')">C</div> | |
| <div class="avatar-option" style="background-color: #f59e0b20;" onclick="selectAvatarColor('#f59e0b')">D</div> | |
| <div class="avatar-option" style="background-color: #8b5cf620;" onclick="selectAvatarColor('#8b5cf6')">E</div> | |
| <div class="avatar-option" style="background-color: #ec489920;" onclick="selectAvatarColor('#ec4899')">F</div> | |
| <div class="avatar-option" style="background-color: #14b8a620;" onclick="selectAvatarColor('#14b8a6')">G</div> | |
| <div class="avatar-option" style="background-color: #f9731620;" onclick="selectAvatarColor('#f97316')">H</div> | |
| </div> | |
| <input type="hidden" id="edit-profile-color" value="#3b82f6"> | |
| </div> | |
| <div class="flex gap-3 pt-2"> | |
| <button type="button" onclick="closeProfileEditModal()" class="flex-1 py-3 rounded-xl border border-white/10 text-sm hover:bg-white/5 transition-colors touch-target"> | |
| انصراف | |
| </button> | |
| <button type="submit" class="flex-1 py-3 rounded-xl bg-white text-slate-900 text-sm font-bold hover:bg-white/90 transition-colors touch-target active:scale-95 transform"> | |
| ذخیره | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| <!-- Room Settings Modal --> | |
| <div id="room-settings-modal" class="room-settings-modal"> | |
| <div class="room-settings-content"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="font-bold text-lg">تنظیمات اتاق</h3> | |
| <button onclick="closeRoomSettingsModal()" class="text-white/40 hover:text-white touch-target w-10 h-10 flex items-center justify-center"> | |
| <span style="font-size: 20px;">✕</span> | |
| </button> | |
| </div> | |
| <form onsubmit="updateRoomSettings(event)" class="space-y-4"> | |
| <div> | |
| <label class="block text-xs text-white/60 mb-2">نام اتاق</label> | |
| <input type="text" id="edit-room-name" placeholder="نام اتاق" | |
| class="w-full bg-white/5 border border-white/10 rounded-xl px-4 py-3 text-white placeholder-white/30 focus:outline-none focus:border-white/30 touch-target" | |
| required> | |
| </div> | |
| <div> | |
| <label class="block text-xs text-white/60 mb-2">رنگ آواتار اتاق</label> | |
| <div class="avatar-grid"> | |
| <div class="avatar-option" style="background-color: #3b82f620;" onclick="selectRoomColor('#3b82f6')">#</div> | |
| <div class="avatar-option" style="background-color: #ef444420;" onclick="selectRoomColor('#ef4444')">#</div> | |
| <div class="avatar-option" style="background-color: #10b98120;" onclick="selectRoomColor('#10b981')">#</div> | |
| <div class="avatar-option" style="background-color: #f59e0b20;" onclick="selectRoomColor('#f59e0b')">#</div> | |
| <div class="avatar-option" style="background-color: #8b5cf620;" onclick="selectRoomColor('#8b5cf6')">#</div> | |
| <div class="avatar-option" style="background-color: #ec489920;" onclick="selectRoomColor('#ec4899')">#</div> | |
| <div class="avatar-option" style="background-color: #14b8a620;" onclick="selectRoomColor('#14b8a6')">#</div> | |
| <div class="avatar-option" style="background-color: #f9731620;" onclick="selectRoomColor('#f97316')">#</div> | |
| </div> | |
| <input type="hidden" id="edit-room-color" value="#3b82f6"> | |
| </div> | |
| <div class="danger-zone"> | |
| <h4 class="text-xs font-medium text-red-400 mb-2">منطقه خطر</h4> | |
| <button type="button" onclick="confirmDeleteRoom()" class="w-full py-3 rounded-xl text-sm font-medium transition-colors touch-target danger-button"> | |
| حذف اتاق | |
| </button> | |
| </div> | |
| <div class="flex gap-3 pt-2"> | |
| <button type="button" onclick="closeRoomSettingsModal()" class="flex-1 py-3 rounded-xl border border-white/10 text-sm hover:bg-white/5 transition-colors touch-target"> | |
| انصراف | |
| </button> | |
| <button type="submit" class="flex-1 py-3 rounded-xl bg-white text-slate-900 text-sm font-bold hover:bg-white/90 transition-colors touch-target active:scale-95 transform"> | |
| ذخیره | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| <!-- Confirmation Modal --> | |
| <div id="confirm-modal" class="profile-edit-modal"> | |
| <div class="profile-edit-content"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="font-bold text-lg" id="confirm-title">تایید حذف</h3> | |
| <button onclick="closeConfirmModal()" class="text-white/40 hover:text-white touch-target w-10 h-10 flex items-center justify-center"> | |
| <span style="font-size: 20px;">✕</span> | |
| </button> | |
| </div> | |
| <p id="confirm-message" class="mb-6">آیا مطمئن هستید که میخواهید این اتاق را حذف کنید؟ این عمل قابل بازگشت نیست.</p> | |
| <div class="flex gap-3"> | |
| <button onclick="closeConfirmModal()" class="flex-1 py-3 rounded-xl border border-white/10 text-sm hover:bg-white/5 transition-colors touch-target"> | |
| انصراف | |
| </button> | |
| <button onclick="executeConfirmedAction()" class="flex-1 py-3 rounded-xl bg-red-600 text-white text-sm font-bold hover:bg-red-500 transition-colors touch-target active:scale-95 transform"> | |
| حذف | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // ========== Global Variables ========== | |
| let currentUser = { | |
| id: 1, | |
| name: "کاربر تست", | |
| phone: "09123456789", | |
| avatar_color: "#3b82f6" | |
| }; | |
| let currentRoomId = null; | |
| let isSidebarOpen = false; | |
| let messagePollInterval = null; | |
| let stickerPickerOpen = false; | |
| let pendingAction = null; | |
| // ========== Helper Functions ========== | |
| // Show toast notification | |
| function showToast(message, type = 'info') { | |
| const container = document.getElementById('toast-container'); | |
| const toast = document.createElement('div'); | |
| let bgClass = 'bg-white/10'; | |
| let icon = 'ℹ️'; | |
| if (type === 'success') { bgClass = 'bg-green-500/20 text-green-200 border border-green-500/30'; icon = '✅'; } | |
| if (type === 'error') { bgClass = 'bg-red-500/20 text-red-200 border border-red-500/30'; icon = '❌'; } | |
| toast.className = `${bgClass} px-4 py-3 rounded-xl flex items-center gap-3 text-sm backdrop-blur-md fade-in shadow-lg`; | |
| toast.innerHTML = `<span>${icon}</span><span class="font-medium">${message}</span>`; | |
| container.appendChild(toast); | |
| setTimeout(() => { | |
| toast.style.opacity = '0'; | |
| toast.style.transform = 'translateY(-10px)'; | |
| setTimeout(() => toast.remove(), 300); | |
| }, 3000); | |
| } | |
| // Simulate API call | |
| async function apiCall(endpoint, data = null, method = 'POST') { | |
| // Simulate network delay | |
| await new Promise(resolve => setTimeout(resolve, 300)); | |
| // Mock responses for demo purposes | |
| if (endpoint.includes('auth.php?action=login')) { | |
| return { | |
| success: true, | |
| message: "ورود موفقیتآمیز بود", | |
| data: { | |
| id: 1, | |
| name: data.phone === "09123456789" ? "کاربر تست" : "کاربر جدید", | |
| phone: data.phone, | |
| avatar_color: "#3b82f6" | |
| } | |
| }; | |
| } | |
| if (endpoint.includes('auth.php?action=register')) { | |
| return { | |
| success: true, | |
| message: "ثبتنام موفقیتآمیز بود", | |
| data: { | |
| id: 2, | |
| name: data.name, | |
| phone: data.phone, | |
| avatar_color: "#" + Math.floor(Math.random()*16777215).toString(16) | |
| } | |
| }; | |
| } | |
| if (endpoint.includes('rooms.php?action=list')) { | |
| return { | |
| success: true, | |
| data: { | |
| created_rooms: [ | |
| { id: 1, name: "گروه دوستان", creator_id: 1, member_count: 3 }, | |
| { id: 2, name: "گروه خانواده", creator_id: 1, member_count: 5 } | |
| ], | |
| member_rooms: [ | |
| { id: 3, name: "گروه کاری", creator_id: 2, member_count: 8 } | |
| ], | |
| created_count: 2 | |
| } | |
| }; | |
| } | |
| if (endpoint.includes('rooms.php?action=create')) { | |
| return { | |
| success: true, | |
| message: "اتاق با موفقیت ایجاد شد", | |
| data: { | |
| id: Math.floor(Math.random() * 1000) + 3, | |
| name: data.name, | |
| creator_id: currentUser.id, | |
| member_count: 1 | |
| } | |
| }; | |
| } | |
| if (endpoint.includes('rooms.php?action=get')) { | |
| return { | |
| success: true, | |
| data: { | |
| id: parseInt(endpoint.split('=')[1]), | |
| name: "اتاق تست", | |
| creator_id: currentUser.id, | |
| member_count: 3, | |
| avatar_color: "#3b82f6" | |
| } | |
| }; | |
| } | |
| if (endpoint.includes('messages.php?action=get')) { | |
| return { | |
| success: true, | |
| data: [ | |
| { id: 1, room_id: 1, user_id: 1, sender_name: "کاربر تست", message: "سلام به همه!", created_at: "2023-05-15 10:30:00" }, | |
| { id: 2, room_id: 1, user_id: 2, sender_name: "کاربر دیگر", message: "سلام! چطوری؟", created_at: "2023-05-15 10:32:00" }, | |
| { id: 3, room_id: 1, user_id: 1, sender_name: "کاربر تست", message: "خوبم ممنون! 😊", created_at: "2023-05-15 10:33:00" } | |
| ] | |
| }; | |
| } | |
| if (endpoint.includes('messages.php?action=send')) { | |
| return { | |
| success: true, | |
| data: { | |
| id: Math.floor(Math.random() * 1000) + 10, | |
| room_id: data.room_id, | |
| user_id: currentUser.id, | |
| sender_name: currentUser.name, | |
| message: data.message, | |
| created_at: new Date().toISOString() | |
| } | |
| }; | |
| } | |
| if (endpoint.includes('auth.php?action=logout')) { | |
| return { success: true }; | |
| } | |
| if (endpoint.includes('rooms.php?action=delete')) { | |
| return { success: true, message: "اتاق با موفقیت حذف شد" }; | |
| } | |
| if (endpoint.includes('rooms.php?action=update')) { | |
| return { success: true, message: "اتاق با موفقیت بهروزرسانی شد" }; | |
| } | |
| if (endpoint.includes('profile.php?action=update')) { | |
| return { success: true, message: "پروفایل با موفقیت بهروزرسانی شد" }; | |
| } | |
| return { success: false, message: "خطا در ارتباط با سرور" }; | |
| } | |
| // Escape HTML | |
| function escapeHtml(text) { | |
| const div = document.createElement('div'); | |
| div.textContent = text; | |
| return div.innerHTML; | |
| } | |
| // Scroll to bottom of messages | |
| function scrollToBottom() { | |
| const container = document.getElementById('messages-container'); | |
| if (container) { | |
| container.scrollTop = container.scrollHeight; | |
| } | |
| } | |
| // Check if user is near bottom of messages | |
| function isUserNearBottom() { | |
| const container = document.getElementById('messages-container'); | |
| if (!container) return false; | |
| const threshold = 100; | |
| return container.scrollHeight - container.scrollTop - container.clientHeight < threshold; | |
| } | |
| // ========== Auth Functions ========== | |
| async function handleRegister(e) { | |
| e.preventDefault(); | |
| const name = document.getElementById('reg-name').value.trim(); | |
| const phone = document.getElementById('reg-phone').value.trim(); | |
| const password = document.getElementById('reg-password').value; | |
| if (phone.length < 11) { | |
| showToast('شماره موبایل صحیح نیست', 'error'); | |
| return; | |
| } | |
| try { | |
| const result = await apiCall('auth.php?action=register', { | |
| name: name, | |
| phone: phone, | |
| password: password | |
| }); | |
| showToast(result.message, 'success'); | |
| // Simulate login after registration | |
| currentUser = result.data; | |
| document.getElementById('auth-view').classList.add('hidden'); | |
| document.getElementById('dashboard-view').classList.remove('hidden'); | |
| updateUserProfile(); | |
| await renderRoomList(); | |
| } catch (error) { | |
| showToast(error.message || 'خطا در ثبتنام', 'error'); | |
| } | |
| } | |
| async function handleLogin(e) { | |
| e.preventDefault(); | |
| const phone = document.getElementById('login-phone').value.trim(); | |
| const password = document.getElementById('login-password').value; | |
| try { | |
| const result = await apiCall('auth.php?action=login', { | |
| phone: phone, | |
| password: password | |
| }); | |
| currentUser = result.data; | |
| document.getElementById('auth-view').classList.add('hidden'); | |
| document.getElementById('dashboard-view').classList.remove('hidden'); | |
| updateUserProfile(); | |
| await renderRoomList(); | |
| showToast(`خوش آمدید ${result.data.name}`, 'success'); | |
| } catch (error) { | |
| showToast(error.message || 'خطا در ورود', 'error'); | |
| } | |
| } | |
| async function logout() { | |
| try { | |
| await apiCall('auth.php?action=logout'); | |
| document.getElementById('dashboard-view').classList.add(' |