Loading gists…
A Text snippet, saved for reference.
| 1 | <!DOCTYPE html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="UTF-8"> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | <title>SportStream Live - Admin Panel</title> |
| 7 | <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet"> |
| 8 | <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet"> |
| 9 | <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet"> |
| 10 | |
| 11 | <style> |
| 12 | :root { |
| 13 | --primary-color: #0d6efd; |
| 14 | --secondary-color: #282828; |
| 15 | --dark-bg: #0f0f0f; |
| 16 | --card-bg: #1a1a1a; |
| 17 | --text-primary: #ffffff; |
| 18 | --text-secondary: #aaaaaa; |
| 19 | --border-color: #303030; |
| 20 | --success-color: #00d4aa; |
| 21 | --warning-color: #ff6b35; |
| 22 | --danger-color: #dc3545; |
| 23 | --gradient-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%); |
| 24 | } |
| 25 | |
| 26 | * { |
| 27 | margin: 0; |
| 28 | padding: 0; |
| 29 | box-sizing: border-box; |
| 30 | } |
| 31 | |
| 32 | body { |
| 33 | font-family: 'Inter', sans-serif; |
| 34 | background: var(--dark-bg); |
| 35 | color: var(--text-primary); |
| 36 | min-height: 100vh; |
| 37 | } |
| 38 | |
| 39 | /* Container Styles */ |
| 40 | .admin-container { |
| 41 | display: flex; |
| 42 | min-height: 100vh; |
| 43 | background: var(--dark-bg); |
| 44 | } |
| 45 | |
| 46 | /* Sidebar Styles */ |
| 47 | .sidebar { |
| 48 | width: 280px; |
| 49 | background: var(--card-bg); |
| 50 | border-right: 1px solid var(--border-color); |
| 51 | position: fixed; |
| 52 | height: 100vh; |
| 53 | overflow-y: auto; |
| 54 | z-index: 1000; |
| 55 | } |
| 56 | |
| 57 | .sidebar-header { |
| 58 | padding: 24px; |
| 59 | border-bottom: 1px solid var(--border-color); |
| 60 | text-align: center; |
| 61 | } |
| 62 | |
| 63 | .logo { |
| 64 | width: 60px; |
| 65 | height: 60px; |
| 66 | background: var(--gradient-bg); |
| 67 | border-radius: 15px; |
| 68 | display: inline-flex; |
| 69 | align-items: center; |
| 70 | justify-content: center; |
| 71 | margin-bottom: 1rem; |
| 72 | box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3); |
| 73 | } |
| 74 | |
| 75 | .sidebar-nav { |
| 76 | padding: 16px 0; |
| 77 | } |
| 78 | |
| 79 | .nav-item { |
| 80 | margin: 8px 16px; |
| 81 | } |
| 82 | |
| 83 | .nav-link { |
| 84 | display: flex; |
| 85 | align-items: center; |
| 86 | padding: 12px 16px; |
| 87 | color: var(--text-secondary); |
| 88 | text-decoration: none; |
| 89 | border-radius: 12px; |
| 90 | transition: all 0.3s ease; |
| 91 | } |
| 92 | |
| 93 | .nav-link:hover, .nav-link.active { |
| 94 | background: rgba(13, 110, 253, 0.1); |
| 95 | color: var(--primary-color); |
| 96 | } |
| 97 | |
| 98 | .nav-link i { |
| 99 | width: 24px; |
| 100 | margin-right: 12px; |
| 101 | } |
| 102 | |
| 103 | /* Main Content */ |
| 104 | .main-content { |
| 105 | flex: 1; |
| 106 | margin-left: 280px; |
| 107 | background: var(--dark-bg); |
| 108 | } |
| 109 | |
| 110 | .top-bar { |
| 111 | background: var(--card-bg); |
| 112 | border-bottom: 1px solid var(--border-color); |
| 113 | padding: 16px 32px; |
| 114 | display: flex; |
| 115 | justify-content: space-between; |
| 116 | align-items: center; |
| 117 | position: sticky; |
| 118 | top: 0; |
| 119 | z-index: 999; |
| 120 | } |
| 121 | |
| 122 | .admin-info { |
| 123 | display: flex; |
| 124 | align-items: center; |
| 125 | } |
| 126 | |
| 127 | .admin-avatar { |
| 128 | width: 40px; |
| 129 | height: 40px; |
| 130 | background: var(--gradient-bg); |
| 131 | border-radius: 50%; |
| 132 | display: flex; |
| 133 | align-items: center; |
| 134 | justify-content: center; |
| 135 | margin-right: 12px; |
| 136 | font-weight: bold; |
| 137 | } |
| 138 | |
| 139 | .content-area { |
| 140 | padding: 32px; |
| 141 | } |
| 142 | |
| 143 | /* Card Styles */ |
| 144 | .section-card { |
| 145 | background: var(--card-bg); |
| 146 | border: 1px solid var(--border-color); |
| 147 | border-radius: 16px; |
| 148 | padding: 32px; |
| 149 | margin-bottom: 24px; |
| 150 | } |
| 151 | |
| 152 | .section-title { |
| 153 | display: flex; |
| 154 | align-items: center; |
| 155 | justify-content: space-between; |
| 156 | margin-bottom: 24px; |
| 157 | } |
| 158 | |
| 159 | /* Form Styles */ |
| 160 | .form-control-dark { |
| 161 | background: var(--secondary-color); |
| 162 | border: 1px solid var(--border-color); |
| 163 | color: var(--text-primary); |
| 164 | border-radius: 8px; |
| 165 | padding: 12px 16px; |
| 166 | } |
| 167 | |
| 168 | .form-control-dark:focus { |
| 169 | border-color: var(--primary-color); |
| 170 | box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2); |
| 171 | background: var(--secondary-color); |
| 172 | color: var(--text-primary); |
| 173 | } |
| 174 | |
| 175 | .form-control-dark::placeholder { |
| 176 | color: var(--text-secondary); |
| 177 | } |
| 178 | |
| 179 | .form-select-dark { |
| 180 | background: var(--secondary-color); |
| 181 | border: 1px solid var(--border-color); |
| 182 | color: var(--text-primary); |
| 183 | border-radius: 8px; |
| 184 | padding: 12px 16px; |
| 185 | } |
| 186 | |
| 187 | .form-select-dark:focus { |
| 188 | border-color: var(--primary-color); |
| 189 | box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2); |
| 190 | background: var(--secondary-color); |
| 191 | color: var(--text-primary); |
| 192 | } |
| 193 | |
| 194 | /* Button Styles */ |
| 195 | .btn-custom { |
| 196 | background: var(--gradient-bg); |
| 197 | border: none; |
| 198 | border-radius: 12px; |
| 199 | padding: 10px 20px; |
| 200 | color: white; |
| 201 | font-weight: 600; |
| 202 | transition: all 0.3s ease; |
| 203 | } |
| 204 | |
| 205 | .btn-custom:hover { |
| 206 | transform: translateY(-2px); |
| 207 | box-shadow: 0 10px 30px rgba(13, 110, 253, 0.3); |
| 208 | color: white; |
| 209 | } |
| 210 | |
| 211 | .btn-outline-custom { |
| 212 | background: transparent; |
| 213 | border: 1px solid var(--primary-color); |
| 214 | color: var(--primary-color); |
| 215 | border-radius: 8px; |
| 216 | padding: 8px 16px; |
| 217 | transition: all 0.3s ease; |
| 218 | } |
| 219 | |
| 220 | .btn-outline-custom:hover { |
| 221 | background: var(--primary-color); |
| 222 | color: white; |
| 223 | } |
| 224 | |
| 225 | /* Channel URL Styles */ |
| 226 | .channel-container { |
| 227 | background: var(--secondary-color); |
| 228 | border: 1px solid var(--border-color); |
| 229 | border-radius: 12px; |
| 230 | padding: 20px; |
| 231 | margin-bottom: 16px; |
| 232 | } |
| 233 | |
| 234 | .channel-item { |
| 235 | background: var(--dark-bg); |
| 236 | border: 1px solid var(--border-color); |
| 237 | border-radius: 8px; |
| 238 | padding: 12px; |
| 239 | margin-bottom: 12px; |
| 240 | display: flex; |
| 241 | justify-content: space-between; |
| 242 | align-items: center; |
| 243 | } |
| 244 | |
| 245 | .channel-url { |
| 246 | font-family: monospace; |
| 247 | font-size: 0.9rem; |
| 248 | color: var(--text-secondary); |
| 249 | flex: 1; |
| 250 | margin-right: 12px; |
| 251 | } |
| 252 | |
| 253 | .add-channel-btn { |
| 254 | background: var(--success-color); |
| 255 | border: none; |
| 256 | color: white; |
| 257 | width: 40px; |
| 258 | height: 40px; |
| 259 | border-radius: 8px; |
| 260 | display: flex; |
| 261 | align-items: center; |
| 262 | justify-content: center; |
| 263 | cursor: pointer; |
| 264 | transition: all 0.3s ease; |
| 265 | } |
| 266 | |
| 267 | .add-channel-btn:hover { |
| 268 | background: #00b894; |
| 269 | transform: scale(1.05); |
| 270 | } |
| 271 | |
| 272 | /* Stats Cards */ |
| 273 | .stats-grid { |
| 274 | display: grid; |
| 275 | grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); |
| 276 | gap: 24px; |
| 277 | margin-bottom: 32px; |
| 278 | } |
| 279 | |
| 280 | .stat-card { |
| 281 | background: var(--card-bg); |
| 282 | border: 1px solid var(--border-color); |
| 283 | border-radius: 16px; |
| 284 | padding: 24px; |
| 285 | transition: all 0.3s ease; |
| 286 | } |
| 287 | |
| 288 | .stat-card:hover { |
| 289 | transform: translateY(-4px); |
| 290 | box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); |
| 291 | } |
| 292 | |
| 293 | .stat-icon { |
| 294 | width: 60px; |
| 295 | height: 60px; |
| 296 | border-radius: 12px; |
| 297 | display: flex; |
| 298 | align-items: center; |
| 299 | justify-content: center; |
| 300 | margin-bottom: 16px; |
| 301 | font-size: 24px; |
| 302 | } |
| 303 | |
| 304 | /* Table Styles */ |
| 305 | .table-dark { |
| 306 | background: var(--card-bg); |
| 307 | border-radius: 12px; |
| 308 | overflow: hidden; |
| 309 | } |
| 310 | |
| 311 | .table-dark th { |
| 312 | background: var(--secondary-color); |
| 313 | border-color: var(--border-color); |
| 314 | padding: 16px; |
| 315 | } |
| 316 | |
| 317 | .table-dark td { |
| 318 | border-color: var(--border-color); |
| 319 | padding: 16px; |
| 320 | } |
| 321 | |
| 322 | /* Match Time Info Box */ |
| 323 | .match-time-info { |
| 324 | background: linear-gradient(135deg, rgba(13, 110, 253, 0.1), rgba(102, 126, 234, 0.1)); |
| 325 | border: 1px solid var(--border-color); |
| 326 | border-radius: 12px; |
| 327 | padding: 20px; |
| 328 | margin-bottom: 20px; |
| 329 | } |
| 330 | |
| 331 | .time-badge { |
| 332 | background: var(--primary-color); |
| 333 | color: white; |
| 334 | padding: 6px 12px; |
| 335 | border-radius: 20px; |
| 336 | font-size: 0.85rem; |
| 337 | font-weight: 600; |
| 338 | display: inline-block; |
| 339 | margin-bottom: 10px; |
| 340 | } |
| 341 | |
| 342 | /* Status Badges */ |
| 343 | .live-badge { |
| 344 | background: var(--success-color); |
| 345 | color: white; |
| 346 | padding: 4px 12px; |
| 347 | border-radius: 12px; |
| 348 | font-size: 0.75rem; |
| 349 | font-weight: 600; |
| 350 | text-transform: uppercase; |
| 351 | animation: pulse 2s infinite; |
| 352 | } |
| 353 | |
| 354 | .scheduled-badge { |
| 355 | background: var(--warning-color); |
| 356 | color: white; |
| 357 | padding: 4px 12px; |
| 358 | border-radius: 12px; |
| 359 | font-size: 0.75rem; |
| 360 | font-weight: 600; |
| 361 | text-transform: uppercase; |
| 362 | } |
| 363 | |
| 364 | .ended-badge { |
| 365 | background: var(--secondary-color); |
| 366 | color: white; |
| 367 | padding: 4px 12px; |
| 368 | border-radius: 12px; |
| 369 | font-size: 0.75rem; |
| 370 | font-weight: 600; |
| 371 | text-transform: uppercase; |
| 372 | } |
| 373 | |
| 374 | @keyframes pulse { |
| 375 | 0% { opacity: 1; } |
| 376 | 50% { opacity: 0.7; } |
| 377 | 100% { opacity: 1; } |
| 378 | } |
| 379 | |
| 380 | /* Quick Actions */ |
| 381 | .quick-actions { |
| 382 | display: flex; |
| 383 | gap: 1rem; |
| 384 | margin-bottom: 2rem; |
| 385 | flex-wrap: wrap; |
| 386 | } |
| 387 | |
| 388 | .quick-action-btn { |
| 389 | background: rgba(13, 110, 253, 0.1); |
| 390 | border: 1px solid var(--primary-color); |
| 391 | color: var(--primary-color); |
| 392 | padding: 12px 20px; |
| 393 | border-radius: 12px; |
| 394 | text-decoration: none; |
| 395 | font-weight: 500; |
| 396 | transition: all 0.3s ease; |
| 397 | display: flex; |
| 398 | align-items: center; |
| 399 | gap: 8px; |
| 400 | } |
| 401 | |
| 402 | .quick-action-btn:hover { |
| 403 | background: var(--primary-color); |
| 404 | color: white; |
| 405 | transform: translateY(-2px); |
| 406 | } |
| 407 | |
| 408 | /* Firebase Status */ |
| 409 | .firebase-status { |
| 410 | background: rgba(0, 212, 170, 0.1); |
| 411 | border: 1px solid var(--success-color); |
| 412 | border-radius: 12px; |
| 413 | padding: 12px; |
| 414 | margin-bottom: 16px; |
| 415 | display: flex; |
| 416 | align-items: center; |
| 417 | gap: 8px; |
| 418 | } |
| 419 | |
| 420 | .firebase-status.disconnected { |
| 421 | background: rgba(220, 53, 69, 0.1); |
| 422 | border-color: var(--danger-color); |
| 423 | } |
| 424 | |
| 425 | /* Responsive Design */ |
| 426 | @media (max-width: 768px) { |
| 427 | .sidebar { |
| 428 | transform: translateX(-100%); |
| 429 | transition: transform 0.3s ease; |
| 430 | } |
| 431 | |
| 432 | .sidebar.show { |
| 433 | transform: translateX(0); |
| 434 | } |
| 435 | |
| 436 | .main-content { |
| 437 | margin-left: 0; |
| 438 | } |
| 439 | |
| 440 | .stats-grid { |
| 441 | grid-template-columns: 1fr; |
| 442 | } |
| 443 | |
| 444 | .content-area { |
| 445 | padding: 16px; |
| 446 | } |
| 447 | |
| 448 | .top-bar { |
| 449 | padding: 16px; |
| 450 | } |
| 451 | |
| 452 | .quick-actions { |
| 453 | flex-direction: column; |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | /* Utility Classes */ |
| 458 | .d-none { display: none !important; } |
| 459 | .show { display: block !important; } |
| 460 | .hide { display: none !important; } |
| 461 | </style> |
| 462 | </head> |
| 463 | <body> |
| 464 | <div class="admin-container"> |
| 465 | <!-- Sidebar --> |
| 466 | <div class="sidebar" id="sidebar"> |
| 467 | <div class="sidebar-header"> |
| 468 | <div class="logo"> |
| 469 | <i class="fas fa-play-circle text-white"></i> |
| 470 | </div> |
| 471 | <h4 class="mb-0">SportStream Live</h4> |
| 472 | <small class="text-muted">Admin Panel</small> |
| 473 | </div> |
| 474 | |
| 475 | <div class="sidebar-nav"> |
| 476 | <div class="nav-item"> |
| 477 | <a href="#" class="nav-link active" onclick="showSection('dashboard')"> |
| 478 | <i class="fas fa-tachometer-alt"></i> |
| 479 | Dashboard |
| 480 | </a> |
| 481 | </div> |
| 482 | <div class="nav-item"> |
| 483 | <a href="#" class="nav-link" onclick="showSection('streams')"> |
| 484 | <i class="fas fa-video"></i> |
| 485 | Live Streams |
| 486 | </a> |
| 487 | </div> |
| 488 | <div class="nav-item"> |
| 489 | <a href="#" class="nav-link" onclick="showSection('matches')"> |
| 490 | <i class="fas fa-calendar-alt"></i> |
| 491 | Matches |
| 492 | </a> |
| 493 | </div> |
| 494 | <div class="nav-item"> |
| 495 | <a href="#" class="nav-link" onclick="showSection('analytics')"> |
| 496 | <i class="fas fa-chart-bar"></i> |
| 497 | Analytics |
| 498 | </a> |
| 499 | </div> |
| 500 | <div class="nav-item"> |
| 501 | <a href="#" class="nav-link" onclick="showSection('settings')"> |
| 502 | <i class="fas fa-cog"></i> |
| 503 | Settings |
| 504 | </a> |
| 505 | </div> |
| 506 | </div> |
| 507 | </div> |
| 508 | |
| 509 | <!-- Main Content --> |
| 510 | <div class="main-content"> |
| 511 | <!-- Top Bar --> |
| 512 | <div class="top-bar"> |
| 513 | <div class="d-flex align-items-center"> |
| 514 | <button class="btn btn-outline-custom d-md-none me-3" onclick="toggleSidebar()"> |
| 515 | <i class="fas fa-bars"></i> |
| 516 | </button> |
| 517 | <h3 class="mb-0" id="pageTitle">Dashboard</h3> |
| 518 | </div> |
| 519 | |
| 520 | <div class="admin-info"> |
| 521 | <div class="admin-avatar">A</div> |
| 522 | <div> |
| 523 | <div class="fw-bold">Admin User</div> |
| 524 | <small class="text-muted">Super Admin</small> |
| 525 | </div> |
| 526 | </div> |
| 527 | </div> |
| 528 | |
| 529 | <!-- Firebase Status --> |
| 530 | <div class="content-area"> |
| 531 | <div class="firebase-status" id="firebaseStatus"> |
| 532 | <i class="fas fa-database"></i> |
| 533 | <span id="statusText">Connecting to Firebase...</span> |
| 534 | </div> |
| 535 | </div> |
| 536 | |
| 537 | <!-- Dashboard Section --> |
| 538 | <div id="dashboardSection" class="content-area"> |
| 539 | <!-- Quick Actions --> |
| 540 | <div class="quick-actions"> |
| 541 | <a href="#" class="quick-action-btn" onclick="showSection('streams')"> |
| 542 | <i class="fas fa-plus"></i> |
| 543 | Add New Stream |
| 544 | </a> |
| 545 | <a href="#" class="quick-action-btn" onclick="showSection('matches')"> |
| 546 | <i class="fas fa-calendar-plus"></i> |
| 547 | Schedule Match |
| 548 | </a> |
| 549 | <a href="#" class="quick-action-btn" onclick="viewUserSite()"> |
| 550 | <i class="fas fa-external-link-alt"></i> |
| 551 | View Live Site |
| 552 | </a> |
| 553 | </div> |
| 554 | |
| 555 | <!-- Stats Grid --> |
| 556 | <div class="stats-grid"> |
| 557 | <div class="stat-card"> |
| 558 | <div class="stat-icon" style="background: rgba(13, 110, 253, 0.1); color: var(--primary-color);"> |
| 559 | <i class="fas fa-video"></i> |
| 560 | </div> |
| 561 | <h3 class="mb-1" id="totalStreams">0</h3> |
| 562 | <p class="text-muted mb-0">Total Streams</p> |
| 563 | </div> |
| 564 | |
| 565 | <div class="stat-card"> |
| 566 | <div class="stat-icon" style="background: rgba(0, 212, 170, 0.1); color: var(--success-color);"> |
| 567 | <i class="fas fa-play-circle"></i> |
| 568 | </div> |
| 569 | <h3 class="mb-1" id="liveStreams">0</h3> |
| 570 | <p class="text-muted mb-0">Live Now</p> |
| 571 | </div> |
| 572 | |
| 573 | <div class="stat-card"> |
| 574 | <div class="stat-icon" style="background: rgba(255, 107, 53, 0.1); color: var(--warning-color);"> |
| 575 | <i class="fas fa-calendar"></i> |
| 576 | </div> |
| 577 | <h3 class="mb-1" id="todayMatches">0</h3> |
| 578 | <p class="text-muted mb-0">Today's Matches</p> |
| 579 | </div> |
| 580 | |
| 581 | <div class="stat-card"> |
| 582 | <div class="stat-icon" style="background: rgba(102, 126, 234, 0.1); color: #667eea;"> |
| 583 | <i class="fas fa-users"></i> |
| 584 | </div> |
| 585 | <h3 class="mb-1" id="totalViewers">1.2M</h3> |
| 586 | <p class="text-muted mb-0">Total Viewers</p> |
| 587 | </div> |
| 588 | </div> |
| 589 | |
| 590 | <!-- Recent Activity --> |
| 591 | <div class="section-card"> |
| 592 | <div class="section-title"> |
| 593 | <h4><i class="fas fa-clock me-2"></i>Recent Activity</h4> |
| 594 | </div> |
| 595 | <div id="recentActivity"> |
| 596 | <!-- Recent activity will be populated here --> |
| 597 | </div> |
| 598 | </div> |
| 599 | </div> |
| 600 | |
| 601 | <!-- Live Streams Section --> |
| 602 | <div id="streamsSection" class="content-area d-none"> |
| 603 | <div class="section-card"> |
| 604 | <div class="section-title"> |
| 605 | <h4><i class="fas fa-plus me-2"></i><span id="formTitle">Add New Live Stream</span></h4> |
| 606 | </div> |
| 607 | |
| 608 | <form id="streamForm" onsubmit="addStream(event)"> |
| 609 | <div class="row mb-3"> |
| 610 | <div class="col-md-6"> |
| 611 | <label class="form-label text-white">Sport</label> |
| 612 | <select class="form-select-dark" id="sport" required> |
| 613 | <option value="">Select Sport</option> |
| 614 | <option value="football">Football</option> |
| 615 | <option value="cricket">Cricket</option> |
| 616 | <option value="basketball">Basketball</option> |
| 617 | <option value="tennis">Tennis</option> |
| 618 | <option value="hockey">Hockey</option> |
| 619 | <option value="rugby">Rugby</option> |
| 620 | </select> |
| 621 | </div> |
| 622 | <div class="col-md-6"> |
| 623 | <label class="form-label text-white">Tournament</label> |
| 624 | <input type="text" class="form-control-dark" id="tournament" |
| 625 | placeholder="e.g., Premier League, World Cup" required> |
| 626 | </div> |
| 627 | </div> |
| 628 | |
| 629 | <div class="mb-3"> |
| 630 | <label class="form-label text-white">Match</label> |
| 631 | <input type="text" class="form-control-dark" id="match" |
| 632 | placeholder="e.g., Manchester City vs Liverpool" required> |
| 633 | </div> |
| 634 | |
| 635 | <!-- Match Time Information Box --> |
| 636 | <div class="match-time-info"> |
| 637 | <div class="time-badge"> |
| 638 | <i class="fas fa-clock me-1"></i>Match Timing |
| 639 | </div> |
| 640 | <div class="row"> |
| 641 | <div class="col-md-6 mb-3"> |
| 642 | <label class="form-label text-white">Start Date</label> |
| 643 | <input type="date" class="form-control-dark" id="startDate" required> |
| 644 | </div> |
| 645 | <div class="col-md-6 mb-3"> |
| 646 | <label class="form-label text-white">Start Time</label> |
| 647 | <input type="time" class="form-control-dark" id="startTime" required> |
| 648 | </div> |
| 649 | </div> |
| 650 | <div class="row"> |
| 651 | <div class="col-md-6 mb-3"> |
| 652 | <label class="form-label text-white">Duration (minutes)</label> |
| 653 | <input type="number" class="form-control-dark" id="duration" |
| 654 | placeholder="e.g., 90, 180" value="90"> |
| 655 | </div> |
| 656 | <div class="col-md-6 mb-3"> |
| 657 | <label class="form-label text-white">Status</label> |
| 658 | <select class="form-select-dark" id="status"> |
| 659 | <option value="scheduled">Scheduled</option> |
| 660 | <option value="live">Live Now</option> |
| 661 | <option value="ended">Ended</option> |
| 662 | </select> |
| 663 | </div> |
| 664 | </div> |
| 665 | <div class="mb-3"> |
| 666 | <label class="form-label text-white">Additional Info</label> |
| 667 | <textarea class="form-control-dark" id="matchInfo" rows="2" |
| 668 | placeholder="e.g., Quarter Final, Group Stage, etc."></textarea> |
| 669 | </div> |
| 670 | </div> |
| 671 | |
| 672 | <!-- Channel URLs Section --> |
| 673 | <div class="channel-container"> |
| 674 | <div class="d-flex justify-content-between align-items-center mb-3"> |
| 675 | <h5 class="mb-0 text-white"> |
| 676 | <i class="fas fa-link me-2"></i>Channel URLs |
| 677 | </h5> |
| 678 | <button type="button" class="add-channel-btn" onclick="addChannelInput()"> |
| 679 | <i class="fas fa-plus"></i> |
| 680 | </button> |
| 681 | </div> |
| 682 | |
| 683 | <div id="channelInputs"> |
| 684 | <!-- Channel inputs will be added dynamically --> |
| 685 | </div> |
| 686 | </div> |
| 687 | |
| 688 | <div class="d-flex gap-3 mt-4"> |
| 689 | <button type="submit" class="btn-custom" id="streamFormBtn"> |
| 690 | <i class="fas fa-save me-2"></i>Save Stream |
| 691 | </button> |
| 692 | <button type="button" class="btn btn-outline-secondary" onclick="clearStreamForm()"> |
| 693 | <i class="fas fa-times me-2"></i>Cancel |
| 694 | </button> |
| 695 | <button type="button" class="btn btn-outline-warning d-none" id="cancelEditBtn" onclick="cancelEdit()"> |
| 696 | <i class="fas fa-undo me-2"></i>Cancel Edit |
| 697 | </button> |
| 698 | </div> |
| 699 | </form> |
| 700 | </div> |
| 701 | |
| 702 | <!-- Existing Streams --> |
| 703 | <div class="section-card"> |
| 704 | <div class="section-title"> |
| 705 | <h4><i class="fas fa-list me-2"></i>Live Streams</h4> |
| 706 | <span class="badge bg-primary" id="streamCount">0</span> |
| 707 | </div> |
| 708 | |
| 709 | <div id="streamsList"> |
| 710 | <!-- Streams will be displayed here --> |
| 711 | </div> |
| 712 | </div> |
| 713 | </div> |
| 714 | |
| 715 | <!-- Matches Section --> |
| 716 | <div id="matchesSection" class="content-area d-none"> |
| 717 | <div class="section-card"> |
| 718 | <div class="section-title"> |
| 719 | <h4><i class="fas fa-calendar-alt me-2"></i>Match Schedule</h4> |
| 720 | <button class="btn-custom" onclick="showSection('streams')"> |
| 721 | <i class="fas fa-plus me-1"></i>Add Match |
| 722 | </button> |
| 723 | </div> |
| 724 | <div id="matchesList"> |
| 725 | <!-- Matches will be displayed here --> |
| 726 | </div> |
| 727 | </div> |
| 728 | </div> |
| 729 | |
| 730 | <!-- Analytics Section --> |
| 731 | <div id="analyticsSection" class="content-area d-none"> |
| 732 | <div class="section-card"> |
| 733 | <h4><i class="fas fa-chart-bar me-2"></i>Analytics Dashboard</h4> |
| 734 | |
| 735 | <div class="row mt-4"> |
| 736 | <div class="col-md-6"> |
| 737 | <div class="stat-card"> |
| 738 | <h5>Popular Sports</h5> |
| 739 | <div id="popularSports"> |
| 740 | <!-- Analytics data will be shown here --> |
| 741 | </div> |
| 742 | </div> |
| 743 | </div> |
| 744 | <div class="col-md-6"> |
| 745 | <div class="stat-card"> |
| 746 | <h5>Peak Viewing Hours</h5> |
| 747 | <div id="peakHours"> |
| 748 | <!-- Analytics data will be shown here --> |
| 749 | </div> |
| 750 | </div> |
| 751 | </div> |
| 752 | </div> |
| 753 | </div> |
| 754 | </div> |
| 755 | |
| 756 | <!-- Settings Section --> |
| 757 | <div id="settingsSection" class="content-area d-none"> |
| 758 | <div class="section-card"> |
| 759 | <h4><i class="fas fa-cog me-2"></i>System Settings</h4> |
| 760 | |
| 761 | <div class="row mt-4"> |
| 762 | <div class="col-md-6"> |
| 763 | <h5>General Settings</h5> |
| 764 | <div class="mb-3"> |
| 765 | <label class="form-label text-white">Site Title</label> |
| 766 | <input type="text" class="form-control-dark" value="SportStream Live"> |
| 767 | </div> |
| 768 | <div class="mb-3"> |
| 769 | <label class="form-label text-white">Admin Email</label> |
| 770 | <input type="email" class="form-control-dark" placeholder="admin@sportstream.com"> |
| 771 | </div> |
| 772 | </div> |
| 773 | <div class="col-md-6"> |
| 774 | <h5>Streaming Settings</h5> |
| 775 | <div class="mb-3"> |
| 776 | <label class="form-label text-white">Default Stream Quality</label> |
| 777 | <select class="form-select-dark"> |
| 778 | <option>HD (720p)</option> |
| 779 | <option>Full HD (1080p)</option> |
| 780 | <option>4K (2160p)</option> |
| 781 | </select> |
| 782 | </div> |
| 783 | <div class="mb-3"> |
| 784 | <label class="form-label text-white">Buffer Time (seconds)</label> |
| 785 | <input type="number" class="form-control-dark" value="5"> |
| 786 | </div> |
| 787 | </div> |
| 788 | </div> |
| 789 | |
| 790 | <button class="btn-custom mt-3"> |
| 791 | <i class="fas fa-save me-1"></i>Save Settings |
| 792 | </button> |
| 793 | </div> |
| 794 | </div> |
| 795 | </div> |
| 796 | </div> |
| 797 | |
| 798 | <!-- Firebase SDK --> |
| 799 | <script type="module"> |
| 800 | import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js'; |
| 801 | import { getFirestore, collection, addDoc, getDocs, deleteDoc, doc, onSnapshot, updateDoc } from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-firestore.js'; |
| 802 | |
| 803 | // Firebase configuration |
| 804 | const firebaseConfig = { |
| 805 | apiKey: "AIzaSyA3gwO6KEBUg0jEaYpd-IYlbEbjtlXNBtg", |
| 806 | authDomain: "live-stream-3df4b.firebaseapp.com", |
| 807 | projectId: "live-stream-3df4b", |
| 808 | storageBucket: "live-stream-3df4b.firebasestorage.app", |
| 809 | messagingSenderId: "41369839856", |
| 810 | appId: "1:41369839856:web:e59112ad3c7352e920ba35", |
| 811 | measurementId: "G-8K3RF8KQD1" |
| 812 | }; |
| 813 | |
| 814 | // Initialize Firebase |
| 815 | const app = initializeApp(firebaseConfig); |
| 816 | const db = getFirestore(app); |
| 817 | |
| 818 | // Global variables |
| 819 | window.db = db; |
| 820 | window.collection = collection; |
| 821 | window.addDoc = addDoc; |
| 822 | window.getDocs = getDocs; |
| 823 | window.deleteDoc = deleteDoc; |
| 824 | window.doc = doc; |
| 825 | window.onSnapshot = onSnapshot; |
| 826 | window.updateDoc = updateDoc; |
| 827 | |
| 828 | let streams = []; |
| 829 | let channelCount = 1; |
| 830 | let editingStreamId = null; |
| 831 | |
| 832 | // Update Firebase status |
| 833 | function updateFirebaseStatus(connected) { |
| 834 | const statusElement = document.getElementById('firebaseStatus'); |
| 835 | const statusText = document.getElementById('statusText'); |
| 836 | |
| 837 | if (connected) { |
| 838 | statusElement.classList.remove('disconnected'); |
| 839 | statusText.textContent = 'Connected to Firebase - Real-time sync active'; |
| 840 | } else { |
| 841 | statusElement.classList.add('disconnected'); |
| 842 | statusText.textContent = 'Disconnected from Firebase - Check connection'; |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | // Initialize the application |
| 847 | document.addEventListener('DOMContentLoaded', function() { |
| 848 | initializeAppCustom(); |
| 849 | updateFirebaseStatus(true); |
| 850 | |
| 851 | // Listen for real-time updates |
| 852 | const unsubscribe = onSnapshot(collection(db, "streams"), (snapshot) => { |
| 853 | streams = []; |
| 854 | snapshot.forEach((doc) => { |
| 855 | streams.push({ id: doc.id, ...doc.data() }); |
| 856 | }); |
| 857 | updateAllDisplays(); |
| 858 | }); |
| 859 | }); |
| 860 | |
| 861 | function initializeAppCustom() { |
| 862 | addChannelInput(); |
| 863 | loadStreamsFromFirebase(); |
| 864 | } |
| 865 | |
| 866 | // Firebase functions |
| 867 | async function saveStreamToFirebase(streamData) { |
| 868 | try { |
| 869 | const docRef = await addDoc(collection(db, "streams"), streamData); |
| 870 | showNotification('Stream saved to Firebase successfully!', 'success'); |
| 871 | return docRef.id; |
| 872 | } catch (error) { |
| 873 | console.error("Error adding document: ", error); |
| 874 | showNotification('Error saving to Firebase: ' + error.message, 'error'); |
| 875 | return null; |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | async function loadStreamsFromFirebase() { |
| 880 | try { |
| 881 | const querySnapshot = await getDocs(collection(db, "streams")); |
| 882 | streams = []; |
| 883 | querySnapshot.forEach((doc) => { |
| 884 | streams.push({ id: doc.id, ...doc.data() }); |
| 885 | }); |
| 886 | updateAllDisplays(); |
| 887 | } catch (error) { |
| 888 | console.error("Error loading streams: ", error); |
| 889 | updateFirebaseStatus(false); |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | async function deleteStreamFromFirebase(streamId) { |
| 894 | try { |
| 895 | await deleteDoc(doc(db, "streams", streamId)); |
| 896 | showNotification('Stream deleted successfully!', 'success'); |
| 897 | } catch (error) { |
| 898 | console.error("Error deleting document: ", error); |
| 899 | showNotification('Error deleting stream: ' + error.message, 'error'); |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | // Navigation functions |
| 904 | window.showSection = function(section) { |
| 905 | const sections = ['dashboard', 'streams', 'matches', 'analytics', 'settings']; |
| 906 | sections.forEach(s => { |
| 907 | document.getElementById(s + 'Section').classList.add('d-none'); |
| 908 | }); |
| 909 | |
| 910 | document.getElementById(section + 'Section').classList.remove('d-none'); |
| 911 | |
| 912 | document.querySelectorAll('.nav-link').forEach(link => { |
| 913 | link.classList.remove('active'); |
| 914 | }); |
| 915 | event.target.classList.add('active'); |
| 916 | |
| 917 | const titles = { |
| 918 | dashboard: 'Dashboard', |
| 919 | streams: 'Live Streams', |
| 920 | matches: 'Matches', |
| 921 | analytics: 'Analytics', |
| 922 | settings: 'Settings' |
| 923 | }; |
| 924 | document.getElementById('pageTitle').textContent = titles[section]; |
| 925 | }; |
| 926 | |
| 927 | window.toggleSidebar = function() { |
| 928 | document.getElementById('sidebar').classList.toggle('show'); |
| 929 | }; |
| 930 | |
| 931 | window.viewUserSite = function() { |
| 932 | window.open('sportstream_live.html', '_blank'); |
| 933 | }; |
| 934 | |
| 935 | // Channel management functions |
| 936 | window.addChannelInput = function() { |
| 937 | const channelInputs = document.getElementById('channelInputs'); |
| 938 | const channelDiv = document.createElement('div'); |
| 939 | channelDiv.className = 'channel-item'; |
| 940 | channelDiv.id = `channel-${channelCount}`; |
| 941 | |
| 942 | channelDiv.innerHTML = ` |
| 943 | <div class="flex-grow-1 me-3"> |
| 944 | <input type="url" class="form-control-dark" |
| 945 | placeholder="https://example.com/stream${channelCount}" |
| 946 | id="channelUrl${channelCount}" required> |
| 947 | </div> |
| 948 | <button type="button" class="btn btn-outline-danger btn-sm" onclick="removeChannelInput(${channelCount})"> |
| 949 | <i class="fas fa-trash"></i> |
| 950 | </button> |
| 951 | `; |
| 952 | |
| 953 | channelInputs.appendChild(channelDiv); |
| 954 | channelCount++; |
| 955 | }; |
| 956 | |
| 957 | window.removeChannelInput = function(channelId) { |
| 958 | const channelDiv = document.getElementById(`channel-${channelId}`); |
| 959 | if (channelDiv && document.querySelectorAll('#channelInputs .channel-item').length > 1) { |
| 960 | channelDiv.remove(); |
| 961 | } else { |
| 962 | showNotification('At least one channel URL is required!', 'warning'); |
| 963 | } |
| 964 | }; |
| 965 | |
| 966 | // Stream management functions |
| 967 | window.addStream = async function(event) { |
| 968 | event.preventDefault(); |
| 969 | |
| 970 | const sport = document.getElementById('sport').value; |
| 971 | const tournament = document.getElementById('tournament').value; |
| 972 | const match = document.getElementById('match').value; |
| 973 | const startDate = document.getElementById('startDate').value; |
| 974 | const startTime = document.getElementById('startTime').value; |
| 975 | const duration = document.getElementById('duration').value; |
| 976 | const status = document.getElementById('status').value; |
| 977 | const matchInfo = document.getElementById('matchInfo').value; |
| 978 | |
| 979 | // Collect channel URLs |
| 980 | const servers = []; |
| 981 | const channelInputs = document.querySelectorAll('#channelInputs input[type="url"]'); |
| 982 | |
| 983 | channelInputs.forEach((input, index) => { |
| 984 | if (input.value.trim()) { |
| 985 | servers.push({ |
| 986 | name: `Server ${index + 1}`, |
| 987 | url: input.value.trim() |
| 988 | }); |
| 989 | } |
| 990 | }); |
| 991 | |
| 992 | if (servers.length === 0) { |
| 993 | showNotification('At least one channel URL is required!', 'error'); |
| 994 | return; |
| 995 | } |
| 996 | |
| 997 | // Create new stream |
| 998 | const streamData = { |
| 999 | title: match, |
| 1000 | category: sport, |
| 1001 | tournament: tournament, |
| 1002 | description: matchInfo || '', |
| 1003 | startDate: startDate, |
| 1004 | startTime: startTime, |
| 1005 | duration: parseInt(duration), |
| 1006 | status: status, |
| 1007 | servers: servers, |
| 1008 | createdAt: new Date().toISOString(), |
| 1009 | viewers: Math.floor(Math.random() * 10000) + 1000 |
| 1010 | }; |
| 1011 | |
| 1012 | if (editingStreamId) { |
| 1013 | // Update existing stream |
| 1014 | try { |
| 1015 | await updateDoc(doc(db, "streams", editingStreamId), streamData); |
| 1016 | showNotification(`Stream "${match}" updated successfully!`, 'success'); |
| 1017 | } catch (error) { |
| 1018 | showNotification('Error updating stream: ' + error.message, 'error'); |
| 1019 | } |
| 1020 | editingStreamId = null; |
| 1021 | document.getElementById('streamFormBtn').innerHTML = '<i class="fas fa-save me-2"></i>Save Stream'; |
| 1022 | document.getElementById('formTitle').textContent = 'Add New Live Stream'; |
| 1023 | document.getElementById('cancelEditBtn').classList.add('d-none'); |
| 1024 | } else { |
| 1025 | // Add new stream |
| 1026 | const streamId = await saveStreamToFirebase(streamData); |
| 1027 | if (streamId) { |
| 1028 | showNotification(`Stream "${match}" added successfully with ${servers.length} servers!`, 'success'); |
| 1029 | } |
| 1030 | } |
| 1031 | clearStreamForm(); |
| 1032 | }; |
| 1033 | |
| 1034 | window.deleteStream = async function(streamId) { |
| 1035 | if (confirm('Are you sure you want to delete this stream?')) { |
| 1036 | await deleteStreamFromFirebase(streamId); |
| 1037 | } |
| 1038 | }; |
| 1039 | |
| 1040 | window.clearStreamForm = function() { |
| 1041 | document.getElementById('streamForm').reset(); |
| 1042 | document.getElementById('channelInputs').innerHTML = ''; |
| 1043 | channelCount = 1; |
| 1044 | addChannelInput(); |
| 1045 | editingStreamId = null; |
| 1046 | document.getElementById('streamFormBtn').innerHTML = '<i class="fas fa-save me-2"></i>Save Stream'; |
| 1047 | document.getElementById('formTitle').textContent = 'Add New Live Stream'; |
| 1048 | document.getElementById('cancelEditBtn').classList.add('d-none'); |
| 1049 | }; |
| 1050 | |
| 1051 | window.cancelEdit = function() { |
| 1052 | editingStreamId = null; |
| 1053 | clearStreamForm(); |
| 1054 | document.getElementById('streamFormBtn').innerHTML = '<i class="fas fa-save me-2"></i>Save Stream'; |
| 1055 | document.getElementById('formTitle').textContent = 'Add New Live Stream'; |
| 1056 | document.getElementById('cancelEditBtn').classList.add('d-none'); |
| 1057 | }; |
| 1058 | |
| 1059 | // Display functions |
| 1060 | function updateAllDisplays() { |
| 1061 | updateStreamDisplay(); |
| 1062 | updateMatchDisplay(); |
| 1063 | updateStats(); |
| 1064 | updateRecentActivity(); |
| 1065 | updateAnalytics(); |
| 1066 | } |
| 1067 | |
| 1068 | function updateStreamDisplay() { |
| 1069 | const streamsList = document.getElementById('streamsList'); |
| 1070 | const streamCount = document.getElementById('streamCount'); |
| 1071 | |
| 1072 | streamCount.textContent = streams.length; |
| 1073 | |
| 1074 | if (streams.length === 0) { |
| 1075 | streamsList.innerHTML = ` |
| 1076 | <div class="text-center py-5"> |
| 1077 | <i class="fas fa-video fa-3x mb-3" style="color: rgba(255,255,255,0.3);"></i> |
| 1078 | <h5>No streams available</h5> |
| 1079 | <p class="text-muted">Add your first live stream using the form above.</p> |
| 1080 | </div> |
| 1081 | `; |
| 1082 | return; |
| 1083 | } |
| 1084 | |
| 1085 | const streamsHtml = ` |
| 1086 | <div class="table-responsive"> |
| 1087 | <table class="table table-dark table-hover"> |
| 1088 | <thead> |
| 1089 | <tr> |
| 1090 | <th>Match</th> |
| 1091 | <th>Sport</th> |
| 1092 | <th>Tournament</th> |
| 1093 | <th>Schedule</th> |
| 1094 | <th>Status</th> |
| 1095 | <th>Servers</th> |
| 1096 | <th>Viewers</th> |
| 1097 | <th>Actions</th> |
| 1098 | </tr> |
| 1099 | </thead> |
| 1100 | <tbody> |
| 1101 | ${streams.map(stream => ` |
| 1102 | <tr> |
| 1103 | <td> |
| 1104 | <strong>${stream.title}</strong> |
| 1105 | ${stream.description ? `<br><small class="text-muted">${stream.description}</small>` : ''} |
| 1106 | </td> |
| 1107 | <td> |
| 1108 | <span class="badge bg-secondary">${stream.category.charAt(0).toUpperCase() + stream.category.slice(1)}</span> |
| 1109 | </td> |
| 1110 | <td>${stream.tournament}</td> |
| 1111 | <td> |
| 1112 | <small class="text-muted"> |
| 1113 | ${stream.startDate}<br> |
| 1114 | ${stream.startTime} (${stream.duration}min) |
| 1115 | </small> |
| 1116 | </td> |
| 1117 | <td> |
| 1118 | ${getStatusBadge(stream.status)} |
| 1119 | </td> |
| 1120 | <td> |
| 1121 | <span class="badge bg-primary">${stream.servers.length} URLs</span> |
| 1122 | </td> |
| 1123 | <td> |
| 1124 | <i class="fas fa-users me-1"></i>${stream.viewers.toLocaleString()} |
| 1125 | </td> |
| 1126 | <td> |
| 1127 | <div class="btn-group btn-group-sm"> |
| 1128 | <button onclick="editStream('${stream.id}')" |
| 1129 | class="btn btn-outline-warning" |
| 1130 | title="Edit Stream"> |
| 1131 | <i class="fas fa-edit"></i> |
| 1132 | </button> |
| 1133 | <button onclick="deleteStream('${stream.id}')" |
| 1134 | class="btn btn-outline-danger" |
| 1135 | title="Delete Stream"> |
| 1136 | <i class="fas fa-trash"></i> |
| 1137 | </button> |
| 1138 | </div> |
| 1139 | </td> |
| 1140 | </tr> |
| 1141 | `).join('')} |
| 1142 | </tbody> |
| 1143 | </table> |
| 1144 | </div> |
| 1145 | `; |
| 1146 | |
| 1147 | streamsList.innerHTML = streamsHtml; |
| 1148 | } |
| 1149 | |
| 1150 | function updateMatchDisplay() { |
| 1151 | const matchesList = document.getElementById('matchesList'); |
| 1152 | |
| 1153 | if (streams.length === 0) { |
| 1154 | matchesList.innerHTML = ` |
| 1155 | <div class="text-center py-5"> |
| 1156 | <i class="fas fa-calendar-alt fa-3x mb-3" style="color: rgba(255,255,255,0.3);"></i> |
| 1157 | <h5>No matches scheduled</h5> |
| 1158 | <p class="text-muted">Add matches through the Live Streams section.</p> |
| 1159 | </div> |
| 1160 | `; |
| 1161 | return; |
| 1162 | } |
| 1163 | |
| 1164 | const sortedStreams = [...streams].sort((a, b) => { |
| 1165 | const dateA = new Date(`${a.startDate} ${a.startTime}`); |
| 1166 | const dateB = new Date(`${b.startDate} ${b.startTime}`); |
| 1167 | return dateA - dateB; |
| 1168 | }); |
| 1169 | |
| 1170 | const matchesHtml = sortedStreams.map(stream => ` |
| 1171 | <div class="match-time-info mb-3"> |
| 1172 | <div class="d-flex justify-content-between align-items-start"> |
| 1173 | <div> |
| 1174 | <div class="time-badge mb-2"> |
| 1175 | <i class="fas fa-clock me-1"></i>${stream.startDate} at ${stream.startTime} |
| 1176 | </div> |
| 1177 | <h5 class="mb-2">${stream.title}</h5> |
| 1178 | <p class="text-muted mb-2"> |
| 1179 | <i class="fas fa-trophy me-1"></i>${stream.tournament} • |
| 1180 | <i class="fas fa-tag me-1"></i>${stream.category.charAt(0).toUpperCase() + stream.category.slice(1)} |
| 1181 | </p> |
| 1182 | ${stream.description ? `<p class="text-secondary mb-2">${stream.description}</p>` : ''} |
| 1183 | <p class="text-muted mb-0"> |
| 1184 | <i class="fas fa-clock me-1"></i>Duration: ${stream.duration} minutes • |
| 1185 | <i class="fas fa-link me-1"></i>${stream.servers.length} streaming servers |
| 1186 | </p> |
| 1187 | </div> |
| 1188 | <div class="text-end"> |
| 1189 | ${getStatusBadge(stream.status)} |
| 1190 | <br> |
| 1191 | <div class="btn-group btn-group-sm mt-2"> |
| 1192 | <button onclick="editStream('${stream.id}')" class="btn btn-outline-warning"> |
| 1193 | <i class="fas fa-edit"></i> |
| 1194 | </button> |
| 1195 | <button onclick="deleteStream('${stream.id}')" class="btn btn-outline-danger"> |
| 1196 | <i class="fas fa-trash"></i> |
| 1197 | </button> |
| 1198 | </div> |
| 1199 | </div> |
| 1200 | </div> |
| 1201 | </div> |
| 1202 | `).join(''); |
| 1203 | |
| 1204 | matchesList.innerHTML = matchesHtml; |
| 1205 | } |
| 1206 | |
| 1207 | function updateStats() { |
| 1208 | const totalStreams = streams.length; |
| 1209 | const liveStreams = streams.filter(s => s.status === 'live').length; |
| 1210 | const today = new Date().toISOString().split('T')[0]; |
| 1211 | const todayMatches = streams.filter(s => s.startDate === today).length; |
| 1212 | |
| 1213 | document.getElementById('totalStreams').textContent = totalStreams; |
| 1214 | document.getElementById('liveStreams').textContent = liveStreams; |
| 1215 | document.getElementById('todayMatches').textContent = todayMatches; |
| 1216 | } |
| 1217 | |
| 1218 | function updateRecentActivity() { |
| 1219 | const recentActivity = document.getElementById('recentActivity'); |
| 1220 | |
| 1221 | if (streams.length === 0) { |
| 1222 | recentActivity.innerHTML = '<p class="text-muted">No recent activity</p>'; |
| 1223 | return; |
| 1224 | } |
| 1225 | |
| 1226 | const recentStreams = streams.slice(-5).reverse(); |
| 1227 | const activityHtml = recentStreams.map(stream => ` |
| 1228 | <div class="d-flex align-items-center mb-3 pb-3 border-bottom border-secondary"> |
| 1229 | <div class="me-3"> |
| 1230 | <i class="fas fa-video text-primary"></i> |
| 1231 | </div> |
| 1232 | <div class="flex-grow-1"> |
| 1233 | <div class="fw-bold">${stream.title}</div> |
| 1234 | <small class="text-muted">${stream.tournament} • ${stream.category}</small> |
| 1235 | </div> |
| 1236 | <div class="text-end"> |
| 1237 | ${getStatusBadge(stream.status)} |
| 1238 | <br> |
| 1239 | <small class="text-muted">${stream.startDate}</small> |
| 1240 | </div> |
| 1241 | </div> |
| 1242 | `).join(''); |
| 1243 | |
| 1244 | recentActivity.innerHTML = activityHtml; |
| 1245 | } |
| 1246 | |
| 1247 | function updateAnalytics() { |
| 1248 | const sportCounts = {}; |
| 1249 | streams.forEach(stream => { |
| 1250 | sportCounts[stream.category] = (sportCounts[stream.category] || 0) + 1; |
| 1251 | }); |
| 1252 | |
| 1253 | const popularSports = document.getElementById('popularSports'); |
| 1254 | if (Object.keys(sportCounts).length === 0) { |
| 1255 | popularSports.innerHTML = '<p class="text-muted">No data available</p>'; |
| 1256 | } else { |
| 1257 | const sportsHtml = Object.entries(sportCounts) |
| 1258 | .sort(([,a], [,b]) => b - a) |
| 1259 | .map(([sport, count]) => ` |
| 1260 | <div class="d-flex justify-content-between align-items-center mb-2"> |
| 1261 | <span class="text-capitalize">${sport}</span> |
| 1262 | <span class="badge bg-primary">${count}</span> |
| 1263 | </div> |
| 1264 | `).join(''); |
| 1265 | popularSports.innerHTML = sportsHtml; |
| 1266 | } |
| 1267 | |
| 1268 | const peakHours = document.getElementById('peakHours'); |
| 1269 | peakHours.innerHTML = ` |
| 1270 | <div class="d-flex justify-content-between align-items-center mb-2"> |
| 1271 | <span>18:00 - 20:00</span> |
| 1272 | <span class="badge bg-success">Peak</span> |
| 1273 | </div> |
| 1274 | <div class="d-flex justify-content-between align-items-center mb-2"> |
| 1275 | <span>20:00 - 22:00</span> |
| 1276 | <span class="badge bg-warning">High</span> |
| 1277 | </div> |
| 1278 | <div class="d-flex justify-content-between align-items-center mb-2"> |
| 1279 | <span>14:00 - 16:00</span> |
| 1280 | <span class="badge bg-info">Medium</span> |
| 1281 | </div> |
| 1282 | `; |
| 1283 | } |
| 1284 | |
| 1285 | function getStatusBadge(status) { |
| 1286 | switch(status) { |
| 1287 | case 'live': |
| 1288 | return '<span class="live-badge">LIVE</span>'; |
| 1289 | case 'scheduled': |
| 1290 | return '<span class="scheduled-badge">SCHEDULED</span>'; |
| 1291 | case 'ended': |
| 1292 | return '<span class="ended-badge">ENDED</span>'; |
| 1293 | default: |
| 1294 | return ''; |
| 1295 | } |
| 1296 | } |
| 1297 | |
| 1298 | window.editStream = function(streamId) { |
| 1299 | const stream = streams.find(s => s.id === streamId); |
| 1300 | if (!stream) return; |
| 1301 | |
| 1302 | document.getElementById('sport').value = stream.category; |
| 1303 | document.getElementById('tournament').value = stream.tournament; |
| 1304 | document.getElementById('match').value = stream.title; |
| 1305 | document.getElementById('startDate').value = stream.startDate; |
| 1306 | document.getElementById('startTime').value = stream.startTime; |
| 1307 | document.getElementById('duration').value = stream.duration; |
| 1308 | document.getElementById('status').value = stream.status; |
| 1309 | document.getElementById('matchInfo').value = stream.description || ''; |
| 1310 | |
| 1311 | document.getElementById('channelInputs').innerHTML = ''; |
| 1312 | channelCount = 1; |
| 1313 | |
| 1314 | stream.servers.forEach(server => { |
| 1315 | addChannelInput(); |
| 1316 | const lastInput = document.querySelector('#channelInputs .channel-item:last-child input'); |
| 1317 | lastInput.value = server.url; |
| 1318 | }); |
| 1319 | |
| 1320 | showSection('streams'); |
| 1321 | editingStreamId = streamId; |
| 1322 | document.getElementById('streamFormBtn').innerHTML = '<i class="fas fa-save me-2"></i>Update Stream'; |
| 1323 | document.getElementById('formTitle').textContent = 'Edit Live Stream'; |
| 1324 | document.getElementById('cancelEditBtn').classList.remove('d-none'); |
| 1325 | showNotification('Stream loaded for editing', 'info'); |
| 1326 | }; |
| 1327 | |
| 1328 | function showNotification(message, type = 'info') { |
| 1329 | const notification = document.createElement('div'); |
| 1330 | notification.className = `alert alert-${type} notification-toast`; |
| 1331 | notification.style.cssText = ` |
| 1332 | position: fixed; |
| 1333 | top: 20px; |
| 1334 | right: 20px; |
| 1335 | z-index: 9999; |
| 1336 | min-width: 300px; |
| 1337 | max-width: 500px; |
| 1338 | animation: slideInRight 0.3s ease-out; |
| 1339 | `; |
| 1340 | notification.innerHTML = ` |
| 1341 | ${message} |
| 1342 | <button type="button" class="btn-close" onclick="this.parentElement.remove()"></button> |
| 1343 | `; |
| 1344 | |
| 1345 | document.body.appendChild(notification); |
| 1346 | |
| 1347 | setTimeout(() => { |
| 1348 | if (notification.parentElement) { |
| 1349 | notification.style.animation = 'slideOutRight 0.3s ease-in'; |
| 1350 | setTimeout(() => { |
| 1351 | notification.remove(); |
| 1352 | }, 300); |
| 1353 | } |
| 1354 | }, 5000); |
| 1355 | } |
| 1356 | |
| 1357 | const style = document.createElement('style'); |
| 1358 | style.textContent = ` |
| 1359 | @keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } |
| 1360 | @keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } } |
| 1361 | .notification-toast { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); border-radius: 12px; backdrop-filter: blur(10px); } |
| 1362 | `; |
| 1363 | document.head.appendChild(style); |
| 1364 | </script> |
| 1365 | |
| 1366 | <!-- Bootstrap JS --> |
| 1367 | <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script> |
| 1368 | </body> |
| 1369 | </html> |
| 1370 |