Spaces:
Running
Running
Download script.js from Matejsw/covert-ops-dashboard: direct link, hf CLI and curl.
- Browser
- Download file 18.4 kB
-
https://huggingface.co/spaces/Matejsw/covert-ops-dashboard/resolve/main/script.js
- Command line
-
hf download hf://spaces/Matejsw/covert-ops-dashboard/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Matejsw/covert-ops-dashboard/resolve/main/script.js
18.4 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| // Load missions from localStorage | |
| let missions = JSON.parse(localStorage.getItem('missions')) || []; | |
| let completedMissions = JSON.parse(localStorage.getItem('completedMissions')) || []; | |
| let projects = JSON.parse(localStorage.getItem('projects')) || []; | |
| let xp = parseInt(localStorage.getItem('xp')) || 0; | |
| let level = parseInt(localStorage.getItem('level')) || 1; | |
| // Project form handling | |
| const projectForm = document.getElementById('project-form'); | |
| if (projectForm) { | |
| projectForm.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| const projectName = document.getElementById('project-name').value; | |
| if (!projectName) { | |
| alert('Please enter a project name'); | |
| return; | |
| } | |
| const newProject = { | |
| id: Date.now(), | |
| name: projectName, | |
| createdAt: new Date().toISOString() | |
| }; | |
| projects.push(newProject); | |
| localStorage.setItem('projects', JSON.stringify(projects)); | |
| if (window.location.pathname.includes('projects.html')) { | |
| loadProjects(); | |
| } | |
| projectForm.reset(); | |
| }); | |
| } | |
| function loadProjects() { | |
| // Update project dropdown in mission form | |
| const projectSelect = document.getElementById('project'); | |
| if (projectSelect) { | |
| // Clear existing options except the default | |
| while (projectSelect.options.length > 1) { | |
| projectSelect.remove(1); | |
| } | |
| // Add current projects | |
| projects.forEach(project => { | |
| const option = document.createElement('option'); | |
| option.value = project.id; | |
| option.textContent = project.name; | |
| projectSelect.appendChild(option); | |
| }); | |
| } | |
| const projectsContainer = document.getElementById('projects-container'); | |
| if (!projectsContainer) return; | |
| if (projects.length === 0) { | |
| projectsContainer.innerHTML = '<p class="text-gray-500">NO PROJECTS CREATED</p>'; | |
| return; | |
| } | |
| projectsContainer.innerHTML = ''; | |
| projects.forEach(project => { | |
| const projectEl = document.createElement('div'); | |
| projectEl.className = 'glass-panel p-4'; | |
| projectEl.innerHTML = ` | |
| <h3 class="text-xl text-purple-400 mb-2">${project.name}</h3> | |
| <p class="text-xs text-gray-400 mb-3">Created: ${new Date(project.createdAt).toLocaleString()}</p> | |
| <div class="project-missions" data-project-id="${project.id}"> | |
| <p class="text-sm text-gray-500">Loading missions...</p> | |
| </div> | |
| `; | |
| projectsContainer.appendChild(projectEl); | |
| }); | |
| // Load missions for each project | |
| projects.forEach(project => { | |
| const projectMissions = missions.filter(m => m.project === project.name); | |
| const projectEl = document.querySelector(`.project-missions[data-project-id="${project.id}"]`); | |
| if (projectMissions.length === 0) { | |
| projectEl.innerHTML = '<p class="text-sm text-gray-500">No missions assigned to this project</p>'; | |
| return; | |
| } | |
| let html = '<ul class="space-y-2">'; | |
| projectMissions.forEach(mission => { | |
| html += ` | |
| <li class="flex justify-between items-center"> | |
| <span>${mission.codename}</span> | |
| <span class="text-xs ${mission.completed ? 'text-green-400' : 'text-yellow-400'}"> | |
| ${mission.completed ? 'COMPLETED' : 'ACTIVE'} | |
| </span> | |
| </li> | |
| `; | |
| }); | |
| html += '</ul>'; | |
| projectEl.innerHTML = html; | |
| }); | |
| } | |
| // Load projects if on projects page | |
| if (window.location.pathname.includes('projects.html')) { | |
| loadProjects(); | |
| } | |
| // Update dashboard stats | |
| updateDashboard(); | |
| // Mission form submission | |
| const missionForm = document.getElementById('mission-form'); | |
| missionForm.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| const codename = document.getElementById('codename').value; | |
| const details = document.getElementById('details').value; | |
| const threatLevel = document.querySelector('input[name="threat"]:checked').value; | |
| const stealthMode = document.getElementById('stealth').checked; | |
| const projectSelect = document.getElementById('project'); | |
| const project = projectSelect.value ? projectSelect.options[projectSelect.selectedIndex].text : null; | |
| if (!codename || !details) { | |
| alert('Please fill in all required fields'); | |
| return; | |
| } | |
| const newMission = { | |
| id: Date.now(), | |
| codename, | |
| details, | |
| threatLevel, | |
| stealthMode, | |
| createdAt: new Date().toISOString(), | |
| completed: false, | |
| project: project || null | |
| }; | |
| missions.push(newMission); | |
| saveMissions(); | |
| updateDashboard(); | |
| // Reset form | |
| missionForm.reset(); | |
| }); | |
| function saveMissions() { | |
| localStorage.setItem('missions', JSON.stringify(missions)); | |
| localStorage.setItem('completedMissions', JSON.stringify(completedMissions)); | |
| localStorage.setItem('xp', xp); | |
| localStorage.setItem('level', level); | |
| } | |
| function updateDashboard() { | |
| // Update active ops count | |
| document.getElementById('active-ops-count').textContent = missions.length; | |
| // Calculate threat level (average of all active missions) | |
| let totalThreat = missions.reduce((sum, mission) => sum + parseFloat(mission.threatLevel), 0); | |
| let avgThreat = missions.length > 0 ? (totalThreat / missions.length) * 25 : 0; | |
| document.getElementById('threat-meter').style.width = `${avgThreat}%`; | |
| document.getElementById('threat-percent').textContent = `${Math.round(avgThreat)}%`; | |
| // Update XP and level | |
| updateXpBar(); | |
| // Update recent completed missions | |
| updateRecentCompleted(); | |
| } | |
| function updateXpBar() { | |
| const xpNeeded = level * 100; | |
| const xpPercentage = (xp / xpNeeded) * 100; | |
| document.getElementById('xp-bar').style.width = `${xpPercentage}%`; | |
| let levelName = "ROOKIE"; | |
| if (level >= 5) levelName = "VETERAN"; | |
| if (level >= 10) levelName = "ELITE"; | |
| if (level >= 20) levelName = "LEGEND"; | |
| document.getElementById('xp-text').textContent = | |
| `LEVEL ${level} (${levelName}) - ${xp}/${xpNeeded} XP`; | |
| } | |
| function updateRecentCompleted() { | |
| const recentList = document.getElementById('recent-completed'); | |
| recentList.innerHTML = ''; | |
| const recent = completedMissions.slice(-3).reverse(); | |
| if (recent.length === 0) { | |
| recentList.innerHTML = '<li class="text-gray-500">NO RECENT EXTRACTIONS</li>'; | |
| return; | |
| } | |
| recent.forEach(mission => { | |
| const li = document.createElement('li'); | |
| li.textContent = `${mission.codename} (+${mission.xpEarned} XP)`; | |
| recentList.appendChild(li); | |
| }); | |
| } | |
| }); | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>OPERATION BLACKOUT [CLASSIFIED]</title> | |
| <link rel="stylesheet" href="style.css"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet"> | |
| <script src="components/navbar.js"></script> | |
| <script src="components/mission-card.js"></script> | |
| </head> | |
| <body class="bg-black font-mono text-purple-400 overflow-x-hidden"> | |
| <div id="plasma-bg" class="fixed inset-0 z-0"></div> | |
| <div id="particles-js" class="fixed inset-0 z-0"></div> | |
| <div class="relative z-10 min-h-screen"> | |
| <custom-navbar></custom-navbar> | |
| <main class="container mx-auto px-4 py-8"> | |
| <!-- Dashboard Section --> | |
| <section id="dashboard" class="mb-12"> | |
| <div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-8"> | |
| <div class="glass-panel p-4"> | |
| <h3 class="text-cyan-400 mb-2">ACTIVE OPS</h3> | |
| <p id="active-ops-count" class="text-2xl">0</p> | |
| </div> | |
| <div class="glass-panel p-4"> | |
| <h3 class="text-cyan-400 mb-2">THREAT METER</h3> | |
| <div class="w-full bg-black h-4 mb-1"> | |
| <div id="threat-meter" class="h-full bg-red-500" style="width: 0%"></div> | |
| </div> | |
| <span id="threat-percent" class="text-xs">0%</span> | |
| </div> | |
| <div class="glass-panel p-4"> | |
| <h3 class="text-cyan-400 mb-2">EXTRACTION LOG</h3> | |
| <ul id="recent-completed" class="text-xs space-y-1"></ul> | |
| </div> | |
| <div class="glass-panel p-4"> | |
| <h3 class="text-cyan-400 mb-2">CLEARANCE STATUS</h3> | |
| <div class="w-full bg-black h-4 mb-1"> | |
| <div id="xp-bar" class="h-full bg-purple-500" style="width: 0%"></div> | |
| </div> | |
| <p id="xp-text" class="text-xs">LEVEL 1 (ROOKIE) - 0/100 XP</p> | |
| </div> | |
| </div> | |
| <div class="glass-panel p-4 mb-8"> | |
| <h2 class="text-xl text-purple-400 mb-4">PERFORMANCE GRAPH</h2> | |
| <canvas id="missions-graph" class="w-full h-64"></canvas> | |
| </div> | |
| </section> | |
| <!-- Mission Briefing Section --> | |
| <section id="mission-briefing" class="mb-12"> | |
| <div class="glass-panel p-6"> | |
| <h2 class="text-xl text-purple-400 mb-4">UPLOAD DOSSIER</h2> | |
| <form id="mission-form" class="space-y-4"> | |
| <div> | |
| <label for="codename" class="block text-cyan-400 mb-1">CODE NAME</label> | |
| <input type="text" id="codename" required | |
| class="w-full bg-black bg-opacity-70 border border-purple-500 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-purple-500"> | |
| </div> | |
| <div> | |
| <label for="details" class="block text-cyan-400 mb-1">OBJECTIVE DETAILS</label> | |
| <textarea id="details" rows="3" | |
| class="w-full bg-black bg-opacity-70 border border-purple-500 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-purple-500"></textarea> | |
| </div> | |
| <div> | |
| <label class="block text-cyan-400 mb-1">THREAT LEVEL</label> | |
| <div class="flex space-x-2"> | |
| <label class="flex items-center"> | |
| <input type="radio" name="threat" value="1" checked class="mr-1"> | |
| <span>LOW (1x)</span> | |
| </label> | |
| <label class="flex items-center"> | |
| <input type="radio" name="threat" value="1.5" class="mr-1"> | |
| <span>MEDIUM (1.5x)</span> | |
| </label> | |
| <label class="flex items-center"> | |
| <input type="radio" name="threat" value="2" class="mr-1"> | |
| <span>HIGH (2x)</span> | |
| </label> | |
| <label class="flex items-center"> | |
| <input type="radio" name="threat" value="3" class="mr-1"> | |
| <span>CRITICAL (3x)</span> | |
| </label> | |
| </div> | |
| </div> | |
| <div> | |
| <label for="deadline" class="block text-cyan-400 mb-1">EXTRACTION DEADLINE</label> | |
| <input type="datetime-local" id="deadline" | |
| class="bg-black bg-opacity-70 border border-purple-500 px-3 py-2"> | |
| </div> | |
| <div> | |
| <label class="flex items-center"> | |
| <input type="checkbox" id="stealth" class="mr-2"> | |
| <span class="text-cyan-400">STEALTH MODE (+20% XP)</span> | |
| </label> | |
| </div> | |
| <button type="submit" class="btn-primary"> | |
| ENCRYPT & DEPLOY | |
| </button> | |
| </form> | |
| </div> | |
| </section> | |
| <!-- Active Missions Section --> | |
| <section id="active-missions" class="mb-12"> | |
| <h2 class="text-2xl text-purple-400 mb-4">ACTIVE MISSIONS</h2> | |
| <div id="missions-container" class="space-y-4"> | |
| <p id="no-missions" class="text-gray-500">NO ACTIVE OPERATIONS</p> | |
| </div> | |
| </section> | |
| <!-- The Vault Section --> | |
| <section id="the-vault" class="mb-12"> | |
| <div class="glass-panel p-6"> | |
| <h2 class="text-2xl text-purple-400 mb-4">THE VAULT</h2> | |
| <div class="flex space-x-2 mb-4"> | |
| <button class="vault-filter" data-filter="24h">24H</button> | |
| <button class="vault-filter" data-filter="7d">7D</button> | |
| <button class="vault-filter" data-filter="30d">30D</button> | |
| <button class="vault-filter" data-filter="all">ALL</button> | |
| </div> | |
| <div class="overflow-x-auto"> | |
| <table class="w-full"> | |
| <thead> | |
| <tr class="text-left border-b border-purple-500"> | |
| <th class="pb-2">FILE #</th> | |
| <th class="pb-2">CODE NAME</th> | |
| <th class="pb-2">TIME SPENT</th> | |
| <th class="pb-2">XP EARNED</th> | |
| <th class="pb-2">COMPLETION</th> | |
| </tr> | |
| </thead> | |
| <tbody id="vault-entries" class="divide-y divide-purple-900"> | |
| <tr> | |
| <td colspan="5" class="py-4 text-center text-gray-500">NO DECLASSIFIED FILES</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </section> | |
| </main> | |
| </div> | |
| <!-- Settings Modal --> | |
| <div id="settings-modal" class="fixed inset-0 bg-black bg-opacity-80 z-50 hidden items-center justify-center p-4"> | |
| <div class="glass-panel max-w-2xl w-full p-6 relative"> | |
| <button id="close-settings" class="absolute top-4 right-4"> | |
| <i data-feather="x"></i> | |
| </button> | |
| <h2 class="text-2xl text-purple-400 mb-6">SETTINGS</h2> | |
| <div class="space-y-6"> | |
| <div> | |
| <h3 class="text-xl text-cyan-400 mb-3">DISPLAY</h3> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-4"> | |
| <button class="wallpaper-btn" data-wallpaper="blackout"> | |
| <div class="wallpaper-preview bg-black h-24"></div> | |
| <span>BLACKOUT</span> | |
| </button> | |
| <button class="wallpaper-btn" data-wallpaper="night-vision"> | |
| <div class="wallpaper-preview bg-green-900 h-24"></div> | |
| <span>NIGHT VISION</span> | |
| </button> | |
| <button class="wallpaper-btn" data-wallpaper="thermal"> | |
| <div class="wallpaper-preview bg-orange-900 h-24"></div> | |
| <span>THERMAL</span> | |
| </button> | |
| </div> | |
| </div> | |
| <div> | |
| <h3 class="text-xl text-cyan-400 mb-3">AUDIO</h3> | |
| <label class="flex items-center"> | |
| <input type="checkbox" id="sound-toggle" class="mr-2" checked> | |
| <span>ENABLE SOUND EFFECTS</span> | |
| </label> | |
| </div> | |
| <div> | |
| <h3 class="text-xl text-cyan-400 mb-3">DATA</h3> | |
| <button id="purge-btn" class="btn-danger"> | |
| PURGE ALL DATA | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Confirmation Modal --> | |
| <div id="confirm-modal" class="fixed inset-0 bg-black bg-opacity-80 z-50 hidden items-center justify-center p-4"> | |
| <div class="glass-panel max-w-md w-full p-6 text-center"> | |
| <h3 class="text-xl text-red-400 mb-4">CONFIRM PURGE</h3> | |
| <p class="mb-6">This will erase all mission data. Operation cannot be undone.</p> | |
| <div class="flex justify-center space-x-4"> | |
| <button id="confirm-purge" class="btn-danger">CONFIRM</button> | |
| <button id="cancel-purge" class="btn-secondary">ABORT</button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Explosion Animation --> | |
| <div id="explosion" class="fixed inset-0 z-50 hidden items-center justify-center"> | |
| <div class="explosion"></div> | |
| </div> | |
| <script src="script.js"></script> | |
| <script> | |
| feather.replace(); | |
| </script> | |
| </body> | |
| </html> |