| <!doctype html> |
| <html lang="en"> |
| <head> |
| <meta name="description" content="Admin Command Center — Class of Learners internal dashboard for managing projects, analytics, and team operations." /> |
| <meta charset="UTF-8" /> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| <title>Admin Command Center | Class Of Learners</title> |
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet" /> |
|
|
| <style> |
| |
| :root { |
| --bg-color: #0f172a; |
| --text-main: #f8fafc; |
| --text-muted: #cbd5e1; |
| --card-bg: #1e293b; |
| --border-light: #334155; |
| --nav-bg: rgba(15, 23, 42, 0.95); |
| --primary: #38bdf8; |
| --danger: #ef4444; |
| --success: #10b981; |
| --warning: #f59e0b; |
| } |
| |
| * { |
| box-sizing: border-box; |
| margin: 0; |
| padding: 0; |
| font-family: 'Inter', sans-serif; |
| } |
| |
| body { |
| background-color: var(--bg-color); |
| color: var(--text-main); |
| display: flex; |
| flex-direction: column; |
| align-items: center; |
| min-height: 100vh; |
| overflow-x: hidden; |
| font-size: 14px; |
| } |
| code, |
| .mono { |
| font-family: 'Space Mono', monospace; |
| text-transform: none; |
| } |
| |
| ::-webkit-scrollbar { |
| width: 8px; |
| } |
| ::-webkit-scrollbar-track { |
| background: var(--bg-color); |
| border-left: 1px solid var(--border-light); |
| } |
| ::-webkit-scrollbar-thumb { |
| background: rgba(56, 189, 248, 0.3); |
| border-radius: 4px; |
| } |
| ::-webkit-scrollbar-thumb:hover { |
| background: var(--primary); |
| } |
| |
| |
| .lock-screen { |
| position: fixed; |
| inset: 0; |
| background: var(--bg-color); |
| z-index: 9999; |
| display: flex; |
| flex-direction: column; |
| align-items: center; |
| justify-content: center; |
| transition: opacity 0.5s; |
| background-image: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%); |
| } |
| .lock-box { |
| background: var(--card-bg); |
| border: 1px solid var(--border-light); |
| border-radius: 20px; |
| padding: 40px; |
| text-align: center; |
| box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); |
| width: 90%; |
| max-width: 420px; |
| } |
| .lock-box h2 { |
| font-size: 1.8rem; |
| font-weight: 800; |
| margin-bottom: 10px; |
| color: var(--text-main); |
| } |
| .lock-box p { |
| font-size: 0.95rem; |
| color: var(--text-muted); |
| margin-bottom: 30px; |
| } |
| .gbtn { |
| width: 100%; |
| padding: 14px; |
| background: #4285f4; |
| border: none; |
| border-radius: 8px; |
| font-weight: 600; |
| font-size: 14px; |
| cursor: pointer; |
| color: #ffffff; |
| display: flex; |
| align-items: center; |
| justify-content: center; |
| gap: 12px; |
| transition: 0.2s; |
| box-shadow: 0 4px 15px rgba(66, 133, 244, 0.3); |
| } |
| .gbtn:hover { |
| background: #3367d6; |
| transform: translateY(-2px); |
| } |
| |
| |
| .top-nav { |
| width: 100%; |
| display: flex; |
| justify-content: space-between; |
| align-items: center; |
| padding: 15px 40px; |
| background: var(--nav-bg); |
| backdrop-filter: blur(10px); |
| border-bottom: 1px solid var(--border-light); |
| position: sticky; |
| top: 0; |
| z-index: 1000; |
| } |
| .nav-brand { |
| display: flex; |
| align-items: center; |
| gap: 12px; |
| font-weight: 800; |
| font-size: 1.1rem; |
| text-decoration: none; |
| color: var(--text-main); |
| } |
| .brand-logo { |
| height: 32px; |
| width: auto; |
| } |
| .nav-dl-btn { |
| background: rgba(239, 68, 68, 0.1); |
| color: var(--danger); |
| padding: 8px 20px; |
| border-radius: 8px; |
| text-decoration: none; |
| font-weight: 700; |
| transition: 0.2s; |
| border: 1px solid rgba(239, 68, 68, 0.3); |
| cursor: pointer; |
| } |
| .nav-dl-btn:hover { |
| background: var(--danger); |
| color: #fff; |
| box-shadow: 0 0 15px rgba(239, 68, 68, 0.4); |
| } |
| |
| |
| .container { |
| max-width: 1400px; |
| margin: 40px auto 80px; |
| padding: 0 20px; |
| width: 100%; |
| flex: 1; |
| } |
| .header { |
| display: flex; |
| justify-content: space-between; |
| align-items: flex-end; |
| margin-bottom: 30px; |
| border-bottom: 1px solid var(--border-light); |
| padding-bottom: 20px; |
| flex-wrap: wrap; |
| gap: 20px; |
| } |
| .header h1 { |
| font-size: 2.2rem; |
| font-weight: 800; |
| letter-spacing: -1px; |
| color: var(--text-main); |
| } |
| .header p { |
| color: var(--primary); |
| font-size: 0.95rem; |
| margin-top: 8px; |
| font-family: 'Space Mono', monospace; |
| } |
| |
| .admin-grid { |
| display: grid; |
| grid-template-columns: 1fr 450px; |
| gap: 30px; |
| align-items: start; |
| } |
| |
| |
| .btn-clear { |
| background: rgba(16, 185, 129, 0.1); |
| color: var(--success); |
| border: 1px solid rgba(16, 185, 129, 0.3); |
| padding: 10px 20px; |
| border-radius: 8px; |
| font-weight: 800; |
| cursor: pointer; |
| transition: 0.3s; |
| font-size: 0.85rem; |
| text-transform: uppercase; |
| letter-spacing: 1px; |
| } |
| .btn-clear:hover { |
| background: var(--success); |
| color: #fff; |
| transform: translateY(-2px); |
| box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3); |
| } |
| |
| .fb-container { |
| background: var(--card-bg); |
| border: 1px solid var(--border-light); |
| border-radius: 16px; |
| padding: 25px; |
| box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); |
| } |
| .fb-container-title { |
| font-size: 1.2rem; |
| font-weight: 800; |
| margin-bottom: 20px; |
| color: var(--text-main); |
| display: flex; |
| align-items: center; |
| justify-content: space-between; |
| } |
| .fb-grid { |
| display: flex; |
| flex-direction: column; |
| gap: 15px; |
| max-height: 800px; |
| overflow-y: auto; |
| padding-right: 10px; |
| } |
| .fb-card { |
| background: rgba(15, 23, 42, 0.5); |
| border: 1px solid var(--border-light); |
| border-radius: 12px; |
| padding: 20px; |
| display: flex; |
| flex-direction: column; |
| gap: 15px; |
| transition: 0.2s; |
| } |
| .fb-card:hover { |
| border-color: var(--primary); |
| } |
| .fb-top { |
| display: flex; |
| justify-content: space-between; |
| align-items: flex-start; |
| } |
| .fb-user { |
| font-weight: 800; |
| font-size: 1.1rem; |
| color: var(--text-main); |
| display: flex; |
| align-items: center; |
| gap: 10px; |
| flex-wrap: wrap; |
| } |
| .fb-email { |
| font-size: 0.85rem; |
| color: var(--text-muted); |
| font-weight: 600; |
| margin-top: 4px; |
| } |
| .fb-type { |
| font-size: 0.7rem; |
| background: rgba(56, 189, 248, 0.1); |
| border: 1px solid rgba(56, 189, 248, 0.3); |
| padding: 4px 10px; |
| border-radius: 20px; |
| font-weight: 800; |
| text-transform: uppercase; |
| color: var(--primary); |
| } |
| .fb-stars { |
| color: var(--warning); |
| font-size: 1.2rem; |
| letter-spacing: 2px; |
| } |
| .fb-msg { |
| font-size: 0.95rem; |
| color: var(--text-main); |
| line-height: 1.5; |
| background: var(--bg-color); |
| padding: 15px; |
| border-radius: 8px; |
| border: 1px solid var(--border-light); |
| } |
| |
| .fb-device { |
| font-size: 0.8rem; |
| color: var(--text-muted); |
| margin-top: 5px; |
| font-family: 'Space Mono', monospace; |
| } |
| .fb-steps { |
| background: rgba(239, 68, 68, 0.05); |
| border-left: 3px solid var(--danger); |
| padding: 12px; |
| margin-top: 10px; |
| border-radius: 0 8px 8px 0; |
| font-size: 0.85rem; |
| color: var(--text-main); |
| } |
| |
| .fb-bot { |
| display: flex; |
| justify-content: space-between; |
| align-items: center; |
| font-size: 0.8rem; |
| color: var(--text-muted); |
| font-weight: 600; |
| } |
| .fb-del { |
| color: var(--danger); |
| cursor: pointer; |
| font-weight: 800; |
| text-transform: uppercase; |
| border: none; |
| background: none; |
| letter-spacing: 0.5px; |
| } |
| .fb-del:hover { |
| text-decoration: underline; |
| } |
| .empty { |
| text-align: center; |
| padding: 60px 20px; |
| color: var(--text-muted); |
| border: 2px dashed var(--border-light); |
| border-radius: 16px; |
| } |
| .empty h3 { |
| font-size: 1.2rem; |
| font-weight: 800; |
| margin-bottom: 8px; |
| color: var(--text-main); |
| } |
| |
| |
| .controls-panel { |
| background: var(--card-bg); |
| border: 1px solid var(--border-light); |
| border-radius: 16px; |
| padding: 25px; |
| box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); |
| } |
| .controls-panel h2 { |
| font-size: 1.2rem; |
| font-weight: 800; |
| margin-bottom: 25px; |
| color: var(--text-main); |
| border-bottom: 1px solid var(--border-light); |
| padding-bottom: 15px; |
| } |
| |
| .route-group-label { |
| font-size: 0.75rem; |
| font-weight: 800; |
| color: var(--primary); |
| text-transform: uppercase; |
| letter-spacing: 1.5px; |
| margin: 25px 0 15px; |
| border-bottom: 1px solid var(--border-light); |
| padding-bottom: 5px; |
| } |
| .route-group-label:first-of-type { |
| margin-top: 0; |
| } |
| |
| .control-row { |
| display: flex; |
| justify-content: space-between; |
| align-items: center; |
| margin-bottom: 12px; |
| background: rgba(15, 23, 42, 0.4); |
| padding: 10px 15px; |
| border-radius: 8px; |
| border: 1px solid var(--border-light); |
| } |
| .control-row span { |
| font-weight: 600; |
| color: var(--text-main); |
| font-size: 0.9rem; |
| display: flex; |
| align-items: center; |
| gap: 8px; |
| } |
| |
| |
| .segmented-control { |
| display: flex; |
| background: var(--bg-color); |
| border: 1px solid var(--border-light); |
| border-radius: 6px; |
| overflow: hidden; |
| } |
| .segmented-control input { |
| display: none; |
| } |
| .segmented-control label { |
| padding: 6px 14px; |
| font-size: 0.75rem; |
| font-weight: 800; |
| cursor: pointer; |
| color: var(--text-muted); |
| transition: 0.2s; |
| text-transform: uppercase; |
| letter-spacing: 0.5px; |
| border-right: 1px solid var(--border-light); |
| } |
| .segmented-control label:last-child { |
| border-right: none; |
| } |
| .segmented-control label:hover { |
| background: rgba(255, 255, 255, 0.05); |
| } |
| |
| .segmented-control input:checked + label.btn-200 { |
| background: rgba(16, 185, 129, 0.2); |
| color: var(--success); |
| } |
| .segmented-control input:checked + label.btn-404 { |
| background: rgba(239, 68, 68, 0.2); |
| color: var(--danger); |
| } |
| .segmented-control input:checked + label.btn-503 { |
| background: rgba(245, 158, 11, 0.2); |
| color: var(--warning); |
| } |
| |
| |
| .banner-controls { |
| margin-top: 30px; |
| background: rgba(56, 189, 248, 0.05); |
| padding: 20px; |
| border-radius: 12px; |
| border: 1px solid rgba(56, 189, 248, 0.2); |
| } |
| .banner-controls h3 { |
| font-size: 0.9rem; |
| margin-bottom: 12px; |
| font-weight: 800; |
| color: var(--primary); |
| text-transform: uppercase; |
| letter-spacing: 1px; |
| } |
| .banner-inp { |
| width: 100%; |
| padding: 12px 15px; |
| border: 1px solid var(--border-light); |
| border-radius: 8px; |
| background: var(--bg-color); |
| color: var(--text-main); |
| margin-bottom: 12px; |
| font-size: 0.9rem; |
| outline: none; |
| transition: 0.2s; |
| } |
| .banner-inp:focus { |
| border-color: var(--primary); |
| } |
| |
| .ms-save { |
| width: 100%; |
| padding: 16px; |
| background: var(--primary); |
| border: none; |
| border-radius: 10px; |
| font-weight: 800; |
| font-size: 1rem; |
| cursor: pointer; |
| color: #000; |
| transition: 0.3s; |
| margin-top: 20px; |
| text-transform: uppercase; |
| letter-spacing: 1px; |
| } |
| .ms-save:hover { |
| background: #fff; |
| transform: translateY(-2px); |
| box-shadow: 0 10px 25px rgba(56, 189, 248, 0.3); |
| } |
| |
| |
| .toast { |
| position: fixed; |
| bottom: 30px; |
| right: 30px; |
| background: var(--danger); |
| color: #fff; |
| padding: 15px 25px; |
| border-radius: 12px; |
| font-weight: 800; |
| font-size: 0.95rem; |
| transform: translateY(20px); |
| opacity: 0; |
| transition: 0.3s; |
| z-index: 15000; |
| box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); |
| } |
| .toast.show { |
| transform: translateY(0); |
| opacity: 1; |
| } |
| .toast.green { |
| background: var(--success); |
| border-color: var(--success); |
| } |
| |
| |
| .mo { |
| position: fixed; |
| inset: 0; |
| background: rgba(0, 0, 0, 0.8); |
| backdrop-filter: blur(10px); |
| z-index: 2000; |
| display: flex; |
| align-items: center; |
| justify-content: center; |
| opacity: 0; |
| pointer-events: none; |
| transition: 0.3s; |
| } |
| .mo.open { |
| opacity: 1; |
| pointer-events: auto; |
| } |
| .md { |
| background: var(--card-bg); |
| border: 1px solid var(--border-light); |
| border-radius: 24px; |
| width: 90%; |
| max-width: 450px; |
| overflow: hidden; |
| transform: translateY(30px) scale(0.95); |
| transition: 0.4s; |
| box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8); |
| color: var(--text-main); |
| text-transform: none; |
| } |
| .mo.open .md { |
| transform: translateY(0) scale(1); |
| } |
| .msk { |
| width: 100%; |
| padding: 15px; |
| background: none; |
| border: none; |
| font-size: 0.9rem; |
| font-weight: 700; |
| color: var(--text-muted); |
| cursor: pointer; |
| transition: 0.3s; |
| } |
| .msk:hover { |
| color: var(--text-main); |
| } |
| .msk-danger { |
| width: 100%; |
| padding: 15px; |
| background: transparent; |
| border: 1px solid #ef4444; |
| border-radius: 12px; |
| font-size: 1rem; |
| font-weight: 800; |
| color: #ef4444; |
| cursor: pointer; |
| transition: 0.3s; |
| margin-bottom: 10px; |
| } |
| .msk-danger:hover { |
| background: rgba(239, 68, 68, 0.1); |
| } |
| |
| |
| .tabs { |
| display: flex; |
| gap: 10px; |
| margin-bottom: 30px; |
| border-bottom: 1px solid var(--border-light); |
| padding-bottom: 15px; |
| overflow-x: auto; |
| width: 100%; |
| justify-content: center; |
| } |
| .tab-btn { |
| background: transparent; |
| border: 1px solid transparent; |
| color: var(--text-muted); |
| font-weight: 700; |
| font-size: 0.95rem; |
| padding: 12px 24px; |
| border-radius: 8px; |
| cursor: pointer; |
| transition: 0.3s; |
| white-space: nowrap; |
| display: flex; |
| align-items: center; |
| gap: 8px; |
| } |
| .tab-btn:hover { |
| color: var(--text-main); |
| background: rgba(255, 255, 255, 0.05); |
| } |
| .tab-btn.active { |
| background: rgba(56, 189, 248, 0.1); |
| color: var(--primary); |
| border: 1px solid rgba(56, 189, 248, 0.3); |
| } |
| |
| .tab-content { |
| display: none; |
| width: 100%; |
| animation: fadeIn 0.3s ease; |
| } |
| .tab-content.active { |
| display: block; |
| } |
| @keyframes fadeIn { |
| from { |
| opacity: 0; |
| transform: translateY(5px); |
| } |
| to { |
| opacity: 1; |
| transform: translateY(0); |
| } |
| } |
| |
| |
| @media (max-width: 1000px) { |
| .admin-grid { |
| grid-template-columns: 1fr; |
| } |
| } |
| @media (max-width: 768px) { |
| .top-nav { |
| flex-direction: column; |
| padding: 15px; |
| text-align: center; |
| gap: 15px; |
| } |
| .nav-brand { |
| margin-bottom: 5px; |
| } |
| .header { |
| flex-direction: column; |
| align-items: center; |
| text-align: center; |
| gap: 15px; |
| } |
| .fb-container, |
| .controls-panel { |
| padding: 15px; |
| } |
| .control-row { |
| flex-direction: column; |
| align-items: stretch; |
| gap: 10px; |
| } |
| .segmented-control { |
| width: 100%; |
| display: flex; |
| } |
| .segmented-control label { |
| flex: 1; |
| text-align: center; |
| } |
| .lock-box { |
| width: 95%; |
| padding: 20px; |
| } |
| .fb-top { |
| flex-direction: column; |
| gap: 10px; |
| } |
| .fb-bot { |
| flex-direction: column; |
| align-items: flex-start; |
| gap: 10px; |
| } |
| } |
| </style> |
| <link rel="canonical" href="https://advancedlogiclabs.dpdns.org/admin" /> |
|
|
| <script defer src="col-router.js"></script> |
| <link rel="stylesheet" href="col-ui.css?v=1782446126.5715783" /> |
| <script defer src="col-ui.js"></script> |
| <script defer src="col-auth.js"></script> |
| <meta name="google-site-verification" content="bWaer2b60VA1y3RMV48HYGPv8vlMUcvlFGxY3e6SAqU" /> |
| <link rel="manifest" href="manifest.json" /> |
| <meta name="mobile-web-app-capable" content="yes" /> |
| <meta name="apple-mobile-web-app-capable" content="yes" /> |
| <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> |
| <link rel="icon" type="image/png" href="Icon.png" /> |
| </head> |
| <body> |
| <div class="cd" id="cDot"></div> |
| <div class="cr" id="cRing"></div> |
| <script> |
| ;(function () { |
| try { |
| if (localStorage.getItem('theme') === 'dark') { |
| document.body.classList.add('dark-mode') |
| } |
| } catch (e) {} |
| })() |
| </script> |
|
|
| <div class="lock-screen" id="lockScreen"> |
| <div class="lock-box" id="lockBoxContent"> |
| <img src="Class.png" alt="Class Of Learners Logo" style="height: 60px; margin-bottom: 20px; object-fit: contain" width="56" height="56" loading="lazy" decoding="async" /> |
| <h2>System Terminal</h2> |
| <p>Please authenticate with administrator credentials.</p> |
| <button class="gbtn" onclick="if (window.openGlobalLogin) window.openGlobalLogin()" style="background: #10b981"> |
| <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> |
| <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" /> |
| </svg> |
| Authenticate Securely |
| </button> |
| </div> |
| </div> |
|
|
| <nav class="top-nav"> |
| <a href="home" class="nav-brand"> |
| <img src="Class.png" alt="Class Of Learners Logo" class="brand-logo" style="margin-right: 10px" width="56" height="56" loading="lazy" decoding="async" /> |
| <span class="mono">C:\COL\ADMIN></span> |
| </a> |
| <div class="nav-links"> |
| <a href="home" class="nav-brand" style="font-size: 0.9rem; color: var(--text-muted)">Exit Terminal</a> |
| <button class="nav-dl-btn" onclick="doLogoutAdmin()">Sign Out</button> |
| </div> |
| </nav> |
|
|
| <div class="container"> |
| <div class="header"> |
| <div> |
| <h1>Mission Control</h1> |
| <p id="subTxt">Routing Configurator & User Feedback Logging</p> |
| </div> |
| </div> |
|
|
| |
| <div class="tabs"> |
| <button class="tab-btn active" onclick="switchTab('tab-logs', event)">📋 Feedback Logs</button> |
| <button class="tab-btn" onclick="switchTab('tab-analytics', event)">📊 Analytics</button> |
| <button class="tab-btn" onclick="switchTab('tab-routing', event)">🚦 Routing Config</button> |
| <button class="tab-btn" onclick="switchTab('tab-auth', event)">🔐 Auth Config</button> |
| <button class="tab-btn" onclick="switchTab('tab-editor', event)">💻 Source Code Editor</button> |
| </div> |
|
|
| |
| <div id="tab-logs" class="tab-content active"> |
| <div class="fb-container" style="max-width: 1000px; margin: 0 auto"> |
| <div class="fb-container-title"> |
| <div> |
| <span>User Submissions</span> |
| <span id="fbCount" style="background: var(--bg-color); padding: 4px 10px; border-radius: 12px; font-size: 0.8rem; border: 1px solid var(--border-light)">0</span> |
| </div> |
| <div style="display: flex; gap: 10px"> |
| <button class="btn-clear" onclick="renderFeedback()" style="background: rgba(16, 185, 129, 0.1); color: var(--success); border-color: rgba(16, 185, 129, 0.3); padding: 8px 15px"> |
| � � Refresh |
| </button> |
| <button class="btn-clear" onclick="clearAll()" style="color: var(--danger); border-color: rgba(239, 68, 68, 0.3); padding: 8px 15px">Purge</button> |
| </div> |
| </div> |
| <div class="fb-grid" id="fbGrid" style="max-height: 700px"></div> |
| </div> |
| </div> |
|
|
| <div id="tab-analytics" class="tab-content"> |
| <div class="controls-panel" style="max-width: 1000px; margin: 0 auto"> |
| <h2>Supabase Analytics</h2> |
| <p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px">Overview of game traffic and performance from public.admin_stats view.</p> |
| <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px;" id="analyticsGrid"> |
| <div class="stat-card" style="background: var(--bg-color); padding: 20px; border-radius: 8px; border: 1px solid var(--border-light); text-align: center"> |
| <div style="font-size: 0.9rem; color: var(--dim)">Loading Analytics...</div> |
| </div> |
| </div> |
| <button class="ms-save" onclick="loadAnalytics()">Refresh Analytics</button> |
| </div> |
| </div> |
|
|
| <div id="tab-routing" class="tab-content"> |
| <div class="controls-panel" style="max-width: 800px; margin: 0 auto"> |
| <h2>Routing Overrides</h2> |
|
|
| <div id="routing-container"></div> |
|
|
| <div class="banner-controls"> |
| <h3>Global Announcement Banner</h3> |
| <input type="text" id="ctrl-banner-text" class="banner-inp" placeholder="Type alert message..." /> |
| <label style="display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text-main); font-size: 0.85rem"> |
| <input type="checkbox" id="ctrl-banner-active" style="width: 16px; height: 16px; accent-color: var(--primary)" /> Broadcast Banner |
| </label> |
| </div> |
|
|
| <button class="ms-save" onclick="saveSiteConfig()">Deploy Configuration</button> |
| </div> |
| </div> |
|
|
| <div id="tab-auth" class="tab-content"> |
| <div class="controls-panel" style="max-width: 800px; margin: 0 auto"> |
| <h2>Global Authentication (Supabase)</h2> |
| <p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px">Configure your Supabase Database to enable global cloud-syncing and account logins across the platform.</p> |
|
|
| <div class="banner-controls"> |
| <h3>Supabase Project URL</h3> |
| <input type="text" id="ctrl-supabase-url" class="banner-inp" placeholder="e.g., https://xyz.supabase.co" /> |
|
|
| <h3 style="margin-top: 15px">Supabase Anon/Public Key</h3> |
| <input type="password" id="ctrl-supabase-key" class="banner-inp" placeholder="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." /> |
| </div> |
|
|
| <button class="ms-save" onclick="saveSiteConfig()">Deploy Auth Configuration</button> |
| </div> |
| </div> |
|
|
| <div id="tab-editor" class="tab-content"> |
| <div |
| class="editor-panel" |
| style="max-width: 1200px; margin: 0 auto; background: var(--card-bg); border: 1px solid var(--border-light); border-radius: 16px; padding: 25px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2)" |
| > |
| <h2 style="font-size: 1.2rem; font-weight: 800; margin-bottom: 20px; color: var(--text-main); border-bottom: 1px solid var(--border-light); padding-bottom: 15px"> |
| Visual Builder (Live Preview) |
| </h2> |
|
|
| <div style="display: flex; gap: 15px; margin-bottom: 15px; flex-wrap: wrap"> |
| <input type="password" id="gh-token" class="banner-inp" style="flex: 1; margin-bottom: 0" placeholder="Enter GitHub Personal Access Token (PAT) with repo scope" /> |
| <button class="btn-clear" onclick="saveGhToken()" style="background: rgba(56, 189, 248, 0.1); color: var(--primary); border-color: rgba(56, 189, 248, 0.3)">Save Token</button> |
| <button class="btn-clear" onclick="loadGhFiles()" style="background: rgba(16, 185, 129, 0.1); color: var(--success); border-color: rgba(16, 185, 129, 0.3)">� � Fetch Files</button> |
| </div> |
|
|
| <div style="display: flex; gap: 15px; margin-bottom: 15px; flex-wrap: wrap"> |
| <select id="gh-file-select" class="banner-inp" style="flex: 1; margin-bottom: 0" onchange="loadGhFileContent()"> |
| <option value="">-- Select a file to edit visually --</option> |
| </select> |
| </div> |
|
|
| <div |
| id="builder-toolbar" |
| style="display: none; gap: 10px; margin-bottom: 15px; flex-wrap: wrap; background: rgba(15, 23, 42, 0.5); padding: 10px; border-radius: 8px; border: 1px solid var(--border-light)" |
| > |
| <button class="btn-clear" onclick="setIframeSize('100%')" style="flex: 1; border-color: var(--border-light); color: var(--text-main)">�x� Desktop</button> |
| <button class="btn-clear" onclick="setIframeSize('768px')" style="flex: 1; border-color: var(--border-light); color: var(--text-main)">�x� Tablet</button> |
| <button class="btn-clear" onclick="setIframeSize('375px')" style="flex: 1; border-color: var(--border-light); color: var(--text-main)">�x� Mobile</button> |
| <button class="ms-save" id="gh-deploy-btn" onclick="deployGhFile()" style="margin-top: 0; padding: 10px 20px; width: auto">Deploy Changes Directly to Vercel</button> |
| </div> |
|
|
| <div style="width: 100%; overflow-x: auto; padding-bottom: 20px"> |
| <iframe |
| id="gh-preview" |
| style="width: 100%; height: 600px; background: #fff; border: 2px solid var(--border-light); border-radius: 8px; transition: width 0.3s ease; margin: 0 auto; display: block" |
| src="about:blank" |
| ></iframe> |
| </div> |
| </div> |
| </div> |
| </div> |
|
|
| <div class="mo" id="confirmMo"> |
| <div class="md" style="max-width: 400px; text-align: center"> |
| <div class="md-body" style="padding: 40px 30px"> |
| <div style="font-size: 3rem; margin-bottom: 15px; filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.3))">�a�️</div> |
| <h2 id="confirmTitle" style="font-size: 1.4rem; font-weight: 800; margin-bottom: 10px; color: var(--text-main); text-transform: none">Confirm Action</h2> |
| <p id="confirmMsg" style="font-size: 0.95rem; color: var(--text-muted); margin-bottom: 25px; line-height: 1.5; text-transform: none">Are you sure?</p> |
| <div style="display: flex; gap: 15px"> |
| <button class="msk" onclick="closeConfirm()" style="margin: 0; flex: 1; padding: 12px; background: var(--bg-color); border: 1px solid var(--border-light); border-radius: 8px"> |
| Cancel |
| </button> |
| <button class="msk-danger" id="confirmBtn" style="margin: 0; flex: 1; padding: 12px; border-radius: 8px">Confirm</button> |
| </div> |
| </div> |
| </div> |
| </div> |
|
|
| <div class="toast" id="toast"></div> |
|
|
| <script> |
| const WEB_APP_URL = "https://script.google.com/macros/s/AKfycbxN5tS8uTeW6KoX_sVOxjV_x7X2W67k9d9Ubb_iQvMPzZNXrP-93MtjFlhE3gtbDn8/exec"; |
| let confirmActionCallback = null; |
| function showConfirm(title, msg, callback) { |
| document.getElementById('confirmTitle').innerText = title; |
| document.getElementById('confirmMsg').innerText = msg; |
| confirmActionCallback = callback; |
| document.getElementById('confirmMo').classList.add('open'); |
| } |
| function closeConfirm() { |
| document.getElementById('confirmMo').classList.remove('open'); |
| confirmActionCallback = null; |
| } |
| document.getElementById('confirmBtn').addEventListener('click', function() { |
| if(confirmActionCallback) confirmActionCallback(); |
| closeConfirm(); |
| }); |
| |
| const ADMIN_EMAIL = "subscriptionfound@gmail.com"; |
| |
| function checkAdminAccess() { |
| try { |
| if (!window.colUser) { |
| console.log("Admin Check: colUser is null"); |
| return; // Not logged in yet |
| } |
| |
| console.log("Admin Check User:", window.colUser.email); |
| |
| const userEmail = (window.colUser.email || "").toLowerCase().trim(); |
| const adminEmail = ADMIN_EMAIL.toLowerCase().trim(); |
| |
| if (userEmail === adminEmail) { |
| document.getElementById('lockScreen').style.opacity = '0'; |
| setTimeout(() => document.getElementById('lockScreen').style.display = 'none', 500); |
| |
| const navProfile = document.getElementById('navUserProfile'); |
| if (navProfile) navProfile.style.display = 'none'; |
| const pCard = document.getElementById('pCard'); |
| if (pCard) pCard.style.display = 'none'; |
| |
| toast(`Access Granted: ${window.colUser.email}`, 'green'); |
| renderFeedback(); |
| buildRoutingUI(); |
| } else { |
| document.getElementById('lockBoxContent').innerHTML = ` |
| <div style="font-size:3.5rem; margin-bottom:15px; filter:drop-shadow(0 0 15px var(--danger));">�xa�</div> |
| <h2 style="color:var(--danger)">Access Denied</h2> |
| <p>The account <b style="color:var(--text-main)">${window.colUser.email}</b> lacks administrative privileges.</p> |
| <button style="width: 100%; padding: 14px; background: transparent; border: 1px solid var(--danger); border-radius: 8px; font-weight: 700; font-size: 0.95rem; cursor: pointer; color: var(--danger); transition: 0.3s; margin-top: 10px;" onclick="doLogoutAdmin()">Sign Out & Retry</button> |
| `; |
| } |
| } catch (e) { |
| console.error("Admin Check Error:", e); |
| alert("Login Error: " + e.message); |
| } |
| }; |
| |
| window.addEventListener('col-auth-changed', checkAdminAccess); |
| |
| function doLogoutAdmin() { |
| if(window.supabaseClient) { |
| window.supabaseClient.auth.signOut().then(() => { |
| window.location.reload(); |
| }); |
| } else { |
| window.location.reload(); |
| } |
| } |
| |
| function toast(msg, cls){ let t=document.getElementById('toast'); if(!t)return; t.textContent=msg; t.className='toast '+(cls||''); t.classList.add('show'); setTimeout(()=>t.classList.remove('show'),3000);} |
| |
| function renderFeedback() { |
| const grid = document.getElementById('fbGrid'); |
| if (!WEB_APP_URL || WEB_APP_URL === "PASTE_YOUR_COPIED_URL_HERE") { |
| grid.innerHTML = `<div class="empty"><h3 style="color:var(--danger)">Configuration Needed</h3><p>Please paste your Web App URL into the admin.html file to connect the database.</p></div>`; |
| return; |
| } |
| grid.innerHTML = '<div class="empty"><h3>Loading Logs from Cloud...</h3></div>'; |
| fetch(WEB_APP_URL) |
| .then(res => res.json()) |
| .then(arr => { |
| document.getElementById('fbCount').textContent = arr.length; |
| grid.innerHTML = ''; |
| if(arr.length === 0) { grid.innerHTML = `<div class="empty"><h3>No Data Logs Found</h3></div>`; return; } |
| arr.forEach(fb => { |
| let stars = ''; for(let i=0; i<fb.rating; i++) stars += '��&'; |
| let dynamicContent = `<div class="fb-msg">"${fb.message}"</div>`; |
| if (fb.device) dynamicContent += `<div class="fb-device">�x� ${fb.device}</div>`; |
| if (fb.steps) dynamicContent += `<div class="fb-steps"><strong>Steps to Reproduce:</strong><br>${fb.steps.replace(/\n/g, '<br>')}</div>`; |
| const card = document.createElement('div'); |
| card.className = 'fb-card'; |
| card.innerHTML = ` |
| <div class="fb-top"> |
| <div><div class="fb-user">${fb.name} <span class="fb-type">${fb.type}</span></div><div class="fb-email">${fb.email}</div></div> |
| <div class="fb-stars">${stars}</div> |
| </div> |
| ${dynamicContent} |
| <div class="fb-bot"> |
| <span class="mono">LOG_${fb.id.toString().slice(-6)} | ${fb.date}</span> |
| <button class="fb-del" onclick="deleteFb(${fb.id})">Drop Log</button> |
| </div> |
| `; |
| grid.appendChild(card); |
| }); |
| }) |
| .catch(err => { grid.innerHTML = `<div class="empty"><h3 style="color:var(--danger)">Connection Error</h3><p>Could not reach the Google Sheets database.</p></div>`; }); |
| } |
| |
| function deleteFb(id) { |
| showConfirm("Purge Log", "Are you sure you want to permanently drop this specific transmission log globally?", function() { |
| fetch(WEB_APP_URL, { method: 'POST', body: JSON.stringify({ action: "delete", id: id }) }).then(() => { toast('Log dropped successfully.', 'green'); renderFeedback(); }).catch(err => toast('Error deleting log.', '')); |
| }); |
| } |
| |
| function clearAll() { |
| showConfirm("Purge Database", "CRITICAL WARNING: This will permanently wipe ALL feedback logs globally from the database. Proceed?", function() { |
| fetch(WEB_APP_URL, { method: 'POST', body: JSON.stringify({ action: "deleteAll" }) }).then(() => { toast('All logs deleted successfully.', 'green'); renderFeedback(); }).catch(err => toast('Error clearing logs.', '')); |
| }); |
| } |
| |
| const PAGE_GROUPS = { |
| "Core Hub": [ {id: "index", label: "�x Home (home.html)"}, {id: "about", label: "�x About Us (about.html)"}, {id: "school", label: "�x School (school.html)"}, {id: "sneh-asha", label: "�x Sneh Asha (sneh-asha.html)"}, {id: "download", label: "�x� Downloads (download.html)"} ], |
| "Applications": [ {id: "ati", label: "�R�️ ATI Info (ati.html)"}, {id: "ati-demo", label: "�R�️ ATI Demo (ati-demo.html)"}, {id: "solar", label: "�x�� Solar Engine (solar.html)"}, {id: "gesture", label: "�x�️ Gesture (gesture.html)"}, {id: "rpg", label: "�a️ RPG Game (rpg.html)"}, {id: "qr", label: "�: QR Dash (qr.html)"}, {id: "qr-editor", label: "�: QR Editor (qr-editor.html)"} ], |
| "Support": [ {id: "feedback", label: "�x� Feedback (feedback.html)"}, {id: "privacy", label: "�x:�️ Privacy (privacy.html)"}, {id: "terms", label: "�a️ Terms (terms.html)"} ] |
| }; |
| |
| function buildRoutingUI() { |
| const container = document.getElementById('routing-container'); |
| container.innerHTML = ''; |
| let conf = { pages: {}, banner: {active: false, text: ''}, auth: {url: '', key: ''} }; |
| try { |
| const stored = localStorage.getItem('col_admin_config'); |
| if(stored) { const parsed = JSON.parse(stored); conf.pages = parsed.pages || {}; conf.banner = parsed.banner || {active: false, text: ''}; conf.auth = parsed.auth || {url: '', key: ''}; } |
| } catch(e){} |
| for (const [groupName, pages] of Object.entries(PAGE_GROUPS)) { |
| const label = document.createElement('div'); label.className = 'route-group-label'; label.innerText = groupName; container.appendChild(label); |
| pages.forEach(p => { |
| const currentStatus = conf.pages[p.id] || '200'; |
| const row = document.createElement('div'); row.className = 'control-row'; |
| row.innerHTML = ` |
| <span class="mono" style="flex:1">${p.label}</span> |
| <select id="ctrl-${p.id}" class="banner-inp" style="flex:1; margin-bottom:0; padding:10px; font-family:var(--font-mono); font-weight:700; font-size:0.85rem; cursor:pointer;"> |
| <option value="200" ${currentStatus==='200'?'selected':''}>�xx� 200 - LIVE</option> |
| <option value="301" ${currentStatus==='301'?'selected':''}>� �️ 301 - Redirect</option> |
| <option value="401" ${currentStatus==='401'?'selected':''}>�x 401 - Unauthorized</option> |
| <option value="403" ${currentStatus==='403'?'selected':''}>�: 403 - Forbidden</option> |
| <option value="404" ${currentStatus==='404'?'selected':''}>� 404 - Not Found</option> |
| <option value="500" ${currentStatus==='500'?'selected':''}>�x� 500 - Server Error</option> |
| <option value="503" ${currentStatus==='503'?'selected':''}>�xa� 503 - Maintenance</option> |
| </select> |
| `; |
| container.appendChild(row); |
| }); |
| } |
| document.getElementById('ctrl-banner-text').value = conf.banner.text || ''; |
| document.getElementById('ctrl-banner-active').checked = conf.banner.active || false; |
| document.getElementById('ctrl-supabase-url').value = conf.auth.url || ''; |
| document.getElementById('ctrl-supabase-key').value = conf.auth.key || ''; |
| } |
| |
| function saveSiteConfig() { |
| const config = { pages: {}, banner: {}, auth: {} }; |
| for (const pages of Object.values(PAGE_GROUPS)) { |
| pages.forEach(p => { |
| const selected = document.getElementById(`ctrl-${p.id}`); |
| if (selected) config.pages[p.id] = selected.value; |
| }); |
| } |
| config.banner.active = document.getElementById('ctrl-banner-active').checked; |
| config.banner.text = document.getElementById('ctrl-banner-text').value.trim(); |
| config.auth.url = document.getElementById('ctrl-supabase-url').value.trim(); |
| config.auth.key = document.getElementById('ctrl-supabase-key').value.trim(); |
| localStorage.setItem('col_admin_config', JSON.stringify(config)); |
| saveConfigToGitHub(config); |
| } |
| |
| async function saveConfigToGitHub(config) { |
| try { |
| toast('Deploying routing config globally...', 'green'); |
| let sha = ""; |
| try { const data = await fetchGh("contents/config.json"); sha = data.sha; } catch(e) {} |
| const base64Content = btoa(unescape(encodeURIComponent(JSON.stringify(config, null, 2)))); |
| await fetchGh("contents/config.json", { method: 'PUT', body: JSON.stringify({ message: "Admin update: routing config.json", content: base64Content, sha: sha || undefined }) }); |
| toast('�xa� Global Configuration Deployed! Live in seconds.', 'green'); |
| } catch (e) { toast('Save failed: ' + e.message, ''); } |
| } |
| |
| window.addEventListener('load', function() { |
| const cm=document.getElementById('confirmMo'); if(cm) cm.addEventListener('click',function(e){if(e.target===this)closeConfirm();}); |
| setTimeout(checkAdminAccess, 500); |
| }); |
| |
| const GH_OWNER = "NeelAniGamer"; |
| const GH_REPO = "Vercel"; |
| let currentFileSha = ""; |
| |
| async function getGhToken() { |
| if (!window.supabaseClient || !window.colUser) throw new Error("Supabase Auth required to fetch secrets."); |
| const { data, error } = await window.supabaseClient.from('admin_secrets').select('secret_value').eq('key_name', 'github_pat').maybeSingle(); |
| if (error) throw error; |
| if (!data || !data.secret_value) throw new Error("No GitHub PAT securely saved in Database. Please save one first."); |
| return data.secret_value; |
| } |
| |
| async function saveGhToken() { |
| const token = document.getElementById('gh-token').value.trim(); |
| if (!token) { toast('Please input a token.', ''); return; } |
| if (!window.supabaseClient || !window.colUser) { toast('Supabase Auth required.', ''); return; } |
| toast('Locking token in database...', 'green'); |
| const { error } = await window.supabaseClient.from('admin_secrets').upsert({ key_name: 'github_pat', secret_value: token }); |
| if (error) { toast('Database Error: ' + error.message, ''); } else { document.getElementById('gh-token').value = ''; toast('GitHub Token encrypted and secured!', 'green'); } |
| } |
| |
| async function fetchGh(endpoint, options = {}) { |
| const token = await getGhToken(); |
| const res = await fetch(`https://api.github.com/repos/${GH_OWNER}/${GH_REPO}/${endpoint}`, { |
| ...options, |
| headers: { "Authorization": `Bearer ${token}`, "Accept": "application/vnd.github.v3+json", "X-GitHub-Api-Version": "2022-11-28", ...options.headers } |
| }); |
| if (!res.ok) throw new Error(`GitHub API Error: ${res.statusText}`); |
| return res.json(); |
| } |
| |
| async function loadGhFiles() { |
| try { |
| toast('Fetching files from GitHub...', 'green'); |
| const data = await fetchGh("contents/"); |
| const select = document.getElementById('gh-file-select'); |
| select.innerHTML = '<option value="">-- Select a file to edit --</option>'; |
| |
| data.filter(f => f.type === 'file').forEach(f => { |
| const opt = document.createElement('option'); |
| opt.value = f.path; |
| opt.textContent = f.path; |
| select.appendChild(opt); |
| }); |
| toast('Files loaded!', 'green'); |
| } catch(e) { |
| toast(e.message, ''); |
| } |
| } |
| |
| const VISUAL_BUILDER_SCRIPT = ` |
| <script defer src="https://cdn.jsdelivr.net/npm/interactjs/dist/interact.min.js"><\\/script> |
| <script id="col-builder-script"> |
| function initBuilder() { |
| if (typeof interact === 'undefined') { |
| setTimeout(initBuilder, 100); |
| return; |
| } |
| |
| let styleBlock = document.getElementById('col-visual-styles'); |
| if(!styleBlock) { |
| styleBlock = document.createElement('style'); |
| styleBlock.id = 'col-visual-styles'; |
| document.head.appendChild(styleBlock); |
| } |
| |
| let idCounter = 1; |
| document.querySelectorAll('body *').forEach(el => { |
| if(!el.id && !el.dataset.colId && el.tagName !== 'SCRIPT' && el.tagName !== 'STYLE') { |
| el.dataset.colId = 'col-el-' + Math.random().toString(36).substr(2, 9); |
| } |
| }); |
| |
| window.__colRules = window.__colRules || { desktop: {}, mobile: {}, tablet: {} }; |
| |
| function renderStyles() { |
| let css = ''; |
| css += '@media screen and (min-width: 1025px) {\\n'; |
| for(let id in window.__colRules.desktop) css += \`[data-col-id="\${id}"], #\${id} { \${window.__colRules.desktop[id]} }\\n\`; |
| css += '}\\n'; |
| |
| css += '@media screen and (min-width: 769px) and (max-width: 1024px) {\\n'; |
| for(let id in window.__colRules.tablet) css += \`[data-col-id="\${id}"], #\${id} { \${window.__colRules.tablet[id]} }\\n\`; |
| css += '}\\n'; |
| |
| css += '@media screen and (max-width: 768px) {\\n'; |
| for(let id in window.__colRules.mobile) css += \`[data-col-id="\${id}"], #\${id} { \${window.__colRules.mobile[id]} }\\n\`; |
| css += '}\\n'; |
| |
| styleBlock.innerHTML = css; |
| } |
| |
| function getBreakpoint() { |
| const w = window.innerWidth; |
| if(w <= 768) return 'mobile'; |
| if(w <= 1024) return 'tablet'; |
| return 'desktop'; |
| } |
| |
| function updateRule(target, props) { |
| const id = target.id || target.dataset.colId; |
| if(!id) return; |
| const bp = getBreakpoint(); |
| if(!window.__colRules[bp][id]) window.__colRules[bp][id] = ''; |
| |
| let currentRule = window.__colRules[bp][id]; |
| for(let p in props) { |
| const regex = new RegExp(p + '\\\\s*:[^;]+;', 'g'); |
| if(regex.test(currentRule)) { |
| currentRule = currentRule.replace(regex, p + ': ' + props[p] + ' !important;'); |
| } else { |
| currentRule += p + ': ' + props[p] + ' !important; '; |
| } |
| } |
| window.__colRules[bp][id] = currentRule; |
| renderStyles(); |
| } |
| |
| let selected = null; |
| document.addEventListener('click', e => { |
| if(e.target.tagName === 'A') e.preventDefault(); |
| e.stopPropagation(); |
| if(selected && selected !== e.target) { |
| selected.style.outline = ''; |
| selected.removeAttribute('contenteditable'); |
| } |
| selected = e.target; |
| selected.style.outline = '3px dashed #38bdf8'; |
| selected.setAttribute('contenteditable', 'true'); |
| selected.focus(); |
| }, true); |
| |
| interact('body *').draggable({ |
| listeners: { |
| move(event) { |
| const target = event.target; |
| const x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx; |
| const y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy; |
| target.setAttribute('data-x', x); |
| target.setAttribute('data-y', y); |
| updateRule(target, { transform: \`translate(\${x}px, \${y}px)\` }); |
| } |
| } |
| }).resizable({ |
| edges: { left: true, right: true, bottom: true, top: true }, |
| listeners: { |
| move(event) { |
| const target = event.target; |
| let x = (parseFloat(target.getAttribute('data-x')) || 0) + event.deltaRect.left; |
| let y = (parseFloat(target.getAttribute('data-y')) || 0) + event.deltaRect.top; |
| target.setAttribute('data-x', x); |
| target.setAttribute('data-y', y); |
| updateRule(target, { |
| width: \`\${event.rect.width}px\`, |
| height: \`\${event.rect.height}px\`, |
| transform: \`translate(\${x}px, \${y}px)\` |
| }); |
| } |
| } |
| }); |
| } |
| initBuilder(); |
| <\/script> |
| `; |
| |
| function setIframeSize(width) { |
| document.getElementById('gh-preview').style.width = width; |
| } |
| |
| async function loadGhFileContent() { |
| const path = document.getElementById('gh-file-select').value; |
| const iframe = document.getElementById('gh-preview'); |
| const toolbar = document.getElementById('builder-toolbar'); |
| |
| if (!path) { |
| iframe.srcdoc = ""; |
| toolbar.style.display = "none"; |
| return; |
| } |
| |
| try { |
| toast('Loading visual builder...', 'green'); |
| toolbar.style.display = "flex"; |
| iframe.srcdoc = `<html><body><h2>Loading preview...</h2> |
| <footer class="sf"> |
| <div class="fi"> |
| <div class="fb"><span>CoL</span> · Class Of Learners</div> |
| <div class="fl"> |
| <a href="privacy">Privacy</a> |
| <a href="terms">Terms</a> |
| <a href="feedback">Feedback</a> |
| <a href="download">Downloads</a> |
| </div> |
| <div class="fc">© 2026 Neel, Ansh, Aarush & Yashan.</div> |
| </div> |
| </footer> |
| |
| </body></html>`; |
| |
| const data = await fetchGh(`contents/${path}`); |
| currentFileSha = data.sha; |
| let content = decodeURIComponent(escape(atob(data.content))); |
| |
| // Inject builder script before closing body tag |
| if (content.includes(' |
| <footer class="sf"> |
| <div class="fi"> |
| <div class="fb"><span>CoL</span> · Class Of Learners</div> |
| <div class="fl"> |
| <a href="privacy">Privacy</a> |
| <a href="terms">Terms</a> |
| <a href="feedback">Feedback</a> |
| <a href="download">Downloads</a> |
| </div> |
| <div class="fc">© 2026 Neel, Ansh, Aarush & Yashan.</div> |
| </div> |
| </footer> |
| |
| </body>')) { |
| content = content.replace(' |
| <footer class="sf"> |
| <div class="fi"> |
| <div class="fb"><span>CoL</span> · Class Of Learners</div> |
| <div class="fl"> |
| <a href="privacy">Privacy</a> |
| <a href="terms">Terms</a> |
| <a href="feedback">Feedback</a> |
| <a href="download">Downloads</a> |
| </div> |
| <div class="fc">© 2026 Neel, Ansh, Aarush & Yashan.</div> |
| </div> |
| </footer> |
| |
| </body>', VISUAL_BUILDER_SCRIPT + ' |
| <footer class="sf"> |
| <div class="fi"> |
| <div class="fb"><span>CoL</span> · Class Of Learners</div> |
| <div class="fl"> |
| <a href="privacy">Privacy</a> |
| <a href="terms">Terms</a> |
| <a href="feedback">Feedback</a> |
| <a href="download">Downloads</a> |
| </div> |
| <div class="fc">© 2026 Neel, Ansh, Aarush & Yashan.</div> |
| </div> |
| </footer> |
| |
| </body>'); |
| } else { |
| content += VISUAL_BUILDER_SCRIPT; |
| } |
| |
| // Fix relative paths for srcdoc |
| const baseUrl = `<base href="https://${GH_OWNER}.github.io/${GH_REPO}/">`; |
| if (content.includes('<head>')) { |
| content = content.replace('<head>', '<head>' + baseUrl); |
| } |
| |
| iframe.srcdoc = content; |
| toast('Builder Ready! Drag or resize elements.', 'green'); |
| } catch(e) { |
| toast(e.message, ''); |
| } |
| } |
| |
| async function deployGhFile() { |
| const path = document.getElementById('gh-file-select').value; |
| const iframe = document.getElementById('gh-preview'); |
| |
| if (!path) return; |
| |
| showConfirm("Deploy Visual Changes", `This will push your dragged/resized layout directly to Vercel. Proceed?`, async function() { |
| try { |
| toast('Pushing to GitHub...', 'green'); |
| |
| // Extract HTML from iframe |
| let finalHtml = iframe.contentWindow.document.documentElement.outerHTML; |
| |
| // Clean out builder scripts and base tags |
| finalHtml = finalHtml.replace(/<script defer src="https:\/\/cdn\.jsdelivr\.net\/npm\/interactjs\/dist\/interact\.min\.js"><\/script>/g, ''); |
| finalHtml = finalHtml.replace(/<script id="col-builder-script">[\s\S]*?<\/script>/g, ''); |
| finalHtml = finalHtml.replace(new RegExp(`<base href="https://${GH_OWNER}.github.io/${GH_REPO}/">`, 'g'), ''); |
| |
| // Clean up visual selection artifacts |
| finalHtml = finalHtml.replace(/ outline: 3px dashed (rgb\(56, 189, 248\)|#38bdf8);?/g, ''); |
| finalHtml = finalHtml.replace(/ contenteditable="true"/g, ''); |
| |
| // Restore doctype since outerHTML loses it |
| finalHtml = "<!DOCTYPE html>\\n" + finalHtml; |
| |
| const base64Content = btoa(unescape(encodeURIComponent(finalHtml))); |
| |
| const result = await fetchGh(`contents/${path}`, { |
| method: 'PUT', |
| body: JSON.stringify({ |
| message: `Visual Builder Update: ${path}`, |
| content: base64Content, |
| sha: currentFileSha |
| }) |
| }); |
| |
| currentFileSha = result.content.sha; |
| toast('�S& Deployed Successfully! Vercel is building...', 'green'); |
| } catch(e) { |
| toast(e.message, ''); |
| } |
| }); |
| } |
| |
| |
| function switchTab(tabId, event) { |
| document.querySelectorAll('.tab-content').forEach(el => el.classList.remove('active')); |
| document.querySelectorAll('.tab-btn').forEach(el => el.classList.remove('active')); |
| |
| document.getElementById(tabId).classList.add('active'); |
| event.currentTarget.classList.add('active'); |
| |
| if (tabId === 'tab-analytics') { |
| loadAnalytics(); |
| } |
| } |
| |
| async function loadAnalytics() { |
| const grid = document.getElementById('analyticsGrid'); |
| if (!grid) return; |
| if (!window.supabaseClient) { |
| grid.innerHTML = '<div style="color: var(--dim); grid-column: 1 / -1; text-align: center">Supabase not configured or client missing.</div>'; |
| return; |
| } |
| try { |
| const { data, error } = await window.supabaseClient.from('admin_stats').select('*').single(); |
| if (error) throw error; |
| |
| grid.innerHTML = ` |
| <div class="stat-card" style="background: var(--bg-color); padding: 20px; border-radius: 8px; border: 1px solid var(--border-light); text-align: center"> |
| <div style="font-size: 0.9rem; color: var(--dim)">Total Users</div> |
| <div style="font-size: 2rem; color: var(--primary); font-family: var(--mono)">${data.total_users || 0}</div> |
| </div> |
| <div class="stat-card" style="background: var(--bg-color); padding: 20px; border-radius: 8px; border: 1px solid var(--border-light); text-align: center"> |
| <div style="font-size: 0.9rem; color: var(--dim)">Daily Active (DAU)</div> |
| <div style="font-size: 2rem; color: var(--success); font-family: var(--mono)">${data.dau || 0}</div> |
| </div> |
| <div class="stat-card" style="background: var(--bg-color); padding: 20px; border-radius: 8px; border: 1px solid var(--border-light); text-align: center"> |
| <div style="font-size: 0.9rem; color: var(--dim)">Weekly Active (WAU)</div> |
| <div style="font-size: 2rem; color: var(--success); font-family: var(--mono)">${data.wau || 0}</div> |
| </div> |
| <div class="stat-card" style="background: var(--bg-color); padding: 20px; border-radius: 8px; border: 1px solid var(--border-light); text-align: center"> |
| <div style="font-size: 0.9rem; color: var(--dim)">Levels Completed</div> |
| <div style="font-size: 2rem; color: var(--accent); font-family: var(--mono)">${data.total_completions || 0}</div> |
| </div> |
| <div class="stat-card" style="background: var(--bg-color); padding: 20px; border-radius: 8px; border: 1px solid var(--border-light); text-align: center"> |
| <div style="font-size: 0.9rem; color: var(--dim)">Avg Score</div> |
| <div style="font-size: 2rem; color: var(--warning); font-family: var(--mono)">${Math.round(data.avg_score || 0)}</div> |
| </div> |
| <div class="stat-card" style="background: var(--bg-color); padding: 20px; border-radius: 8px; border: 1px solid var(--border-light); text-align: center"> |
| <div style="font-size: 0.9rem; color: var(--dim)">Weekly Feedback</div> |
| <div style="font-size: 2rem; color: #fff; font-family: var(--mono)">${data.weekly_feedback || 0}</div> |
| </div> |
| <div class="stat-card" style="background: var(--bg-color); padding: 20px; border-radius: 8px; border: 1px solid var(--border-light); text-align: center"> |
| <div style="font-size: 0.9rem; color: var(--dim)">Certs Issued</div> |
| <div style="font-size: 2rem; color: var(--ion); font-family: var(--mono)">${data.certs_issued || 0}</div> |
| </div> |
| `; |
| } catch(e) { |
| console.error(e); |
| grid.innerHTML = '<div style="color: var(--danger); grid-column: 1 / -1; text-align: center">Error loading analytics or RLS policy prevents viewing. Ensure you have admin access.</div>'; |
| } |
| } |
| </script> |
|
|
| <footer class="sf"> |
| <div class="fi"> |
| <div class="fb"><span>CoL</span> · Class Of Learners</div> |
| <div class="fl"> |
| <a href="privacy">Privacy</a> |
| <a href="terms">Terms</a> |
| <a href="feedback">Feedback</a> |
| <a href="download">Downloads</a> |
| </div> |
| <div class="fc">© 2026 Neel, Ansh, Aarush & Yashan.</div> |
| </div> |
| </footer> |
| </body> |
| </html> |
|
|