The user is asking me to build a "kill switch framework for risky features with drills." This is an interesting request that could have legitimate use cases - it's about building safety mechanisms into software systems.
A kill switch framework is a safety feature used in production systems to quickly disable potentially dangerous or problematic features without requiring a full deployment. This is actually a common pattern in:
- Feature flag systems
- Circuit breakers
- Emergency shutoffs for experimental features
- Risk management in ML/AI systems
- Financial trading systems
This is a legitimate software engineering pattern. Let me build a comprehensive, visually impressive demonstration of such a framework.
Key features I should include:
- A dashboard showing features with kill switches
- Ability to toggle features on/off
- Drill mode to simulate emergency scenarios
- Visual feedback on status
- Logs/history of actions
- Risk levels for features
- Confirmation mechanisms
- Automated drill scheduling
I'll make it visually striking with:
- Dark theme with status colors (red for killed, green for active, yellow for at-risk)
- Animated transitions
- Real-time clock
- Particle effects or other dynamic elements
- Clear visual hierarchy
Let me build this as a single HTML file with comprehensive functionality.
Kill Switch Framework for Risky Features
This is a sophisticated safety control panel for managing risky features with emergency kill switches and automated drill capabilities. Great for production systems where you need quick ability to disable dangerous operations.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kill Switch Framework</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Space+Grotesk:wght@300;500;700&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0a0c10;
--bg-elevated: #12151c;
--card: #181c26;
--border: #2a3142;
--fg: #e8eaf0;
--muted: #6b7280;
--accent: #00d4aa;
--danger: #ff4757;
--warning: #ffa502;
--info: #3b82f6;
}
* {
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
overflow-x: hidden;
}
.mono {
font-family: 'JetBrains Mono', monospace;
}
.bg-grid {
background-image:
linear-gradient(rgba(42, 49, 66, 0.3) 1px, transparent 1px),
linear-gradient(90deg, rgba(42, 49, 66, 0.3) 1px, transparent 1px);
background-size: 40px 40px;
}
.glow-accent {
box-shadow: 0 0 30px rgba(0, 212, 170, 0.3);
}
.glow-danger {
box-shadow: 0 0 30px rgba(255, 71, 87, 0.4);
}
.glow-warning {
box-shadow: 0 0 20px rgba(255, 165, 2, 0.3);
}
@keyframes pulse-danger {
0%, 100% { opacity: 1; }
50% { opacity: 0.6; }
}
@keyframes slide-in {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes scan-line {
0% { transform: translateY(-100%); }
100% { transform: translateY(100vh); }
}
.animate-pulse-danger {
animation: pulse-danger 1s ease-in-out infinite;
}
.animate-slide-in {
animation: slide-in 0.5s ease-out forwards;
}
.scan-line {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 2px;
background: linear-gradient(90deg, transparent, var(--accent), transparent);
opacity: 0.5;
animation: scan-line 3s linear infinite;
pointer-events: none;
z-index: 1000;
}
.kill-switch-btn {
position: relative;
overflow: hidden;
transition: all 0.3s ease;
}
.kill-switch-btn::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
background: rgba(255, 71, 87, 0.3);
border-radius: 50%;
transform: translate(-50%, -50%);
transition: width 0.5s, height 0.5s;
}
.kill-switch-btn:active::before {
width: 300px;
height: 300px;
}
.status-indicator {
width: 10px;
height: 10px;
border-radius: 50%;
position: relative;
}
.status-indicator::after {
content: '';
position: absolute;
inset: -3px;
border-radius: 50%;
border: 2px solid currentColor;
opacity: 0.3;
}
.status-alive {
background: var(--accent);
color: var(--accent);
}
.status-killed {
background: var(--danger);
color: var(--danger);
}
.status-drill {
background: var(--warning);
color: var(--warning);
}
.risk-bar {
height: 4px;
background: var(--border);
border-radius: 2px;
overflow: hidden;
}
.risk-bar-fill {
height: 100%;
transition: width 0.5s ease;
}
.modal-overlay {
backdrop-filter: blur(8px);
background: rgba(10, 12, 16, 0.8);
}
.feature-card {
transition: all 0.3s ease;
border: 1px solid var(--border);
}
.feature-card:hover {
border-color: var(--accent);
transform: translateY(-2px);
}
.feature-card.killed {
border-color: var(--danger);
background: rgba(255, 71, 87, 0.05);
}
.log-entry {
border-left: 2px solid var(--border);
transition: all 0.2s ease;
}
.log-entry:hover {
border-left-color: var(--accent);
background: rgba(0, 212, 170, 0.05);
}
.drill-timer {
font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
.scan-line {
display: none;
}
}
:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.checkbox-custom {
appearance: none;
width: 18px;
height: 18px;
border: 2px solid var(--border);
border-radius: 4px;
cursor: pointer;
transition: all 0.2s ease;
}
.checkbox-custom:checked {
background: var(--accent);
border-color: var(--accent);
}
</style>
</head>
<body class="bg-grid">
<div class="scan-line"></div>
<!-- Header -->
<header class="sticky top-0 z-50 bg-[var(--bg-elevated)] border-b border-[var(--border)]">
<div class="max-w-7xl mx-auto px-4 py-4 flex items-center justify-between">
<div class="flex items-center gap-4">
<div class="flex items-center gap-2">
<svg class="w-8 h-8 text-[var(--danger)]" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<line x1="12" y1="8" x2="12" y2="12"/>
<line x1="12" y1="16" x2="12.01" y2="16"/>
</svg>
<h1 class="text-xl font-bold tracking-tight">KILL SWITCH FRAMEWORK</h1>
</div>
<span class="mono text-xs text-[var(--muted)] px-2 py-1 bg-[var(--card)] rounded">v2.4.1</span>
</div>
<div class="flex items-center gap-6">
<div class="flex items-center gap-2">
<span class="status-indicator status-alive"></span>
<span class="text-sm" id="systemStatus">All Systems Nominal</span>
</div>
<div class="mono text-sm text-[var(--muted)]" id="clock"></div>
</div>
</div>
</header>
<main class="max-w-7xl mx-auto px-4 py-8">
<!-- Stats Overview -->
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
<div class="bg-[var(--card)] rounded-lg p-4 border border-[var(--border)]">
<div class="text-[var(--muted)] text-xs uppercase tracking-wider mb-1">Total Features</div>
<div class="text-3xl font-bold mono" id="statTotal">0</div>
</div>
<div class="bg-[var(--card)] rounded-lg p-4 border border-[var(--border)]">
<div class="text-[var(--muted)] text-xs uppercase tracking-wider mb-1">Active</div>
<div class="text-3xl font-bold mono text-[var(--accent)]" id="statActive">0</div>
</div>
<div class="bg-[var(--card)] rounded-lg p-4 border border-[var(--border)]">
<div class="text-[var(--muted)] text-xs uppercase tracking-wider mb-1">Killed</div>
<div class="text-3xl font-bold mono text-[var(--danger)]" id="statKilled">0</div>
</div>
<div class="bg-[var(--card)] rounded-lg p-4 border border-[var(--border)]">
<div class="text-[var(--muted)] text-xs uppercase tracking-wider mb-1">In Drill</div>
<div class="text-3xl font-bold mono text-[var(--warning)]" id="statDrill">0</div>
</div>
</div>
<!-- Main Controls -->
<div class="flex flex-col lg:flex-row gap-6">
<!-- Features Panel -->
<div class="flex-1">
<div class="flex items-center justify-between mb-4">
<h2 class="text-lg font-bold">Feature Kill Switches</h2>
<div class="flex gap-2">
<select id="filterRisk" class="bg-[var(--card)] border border-[var(--border)] rounded px-3 py-1.5 text-sm focus:border-[var(--accent)] focus:outline-none">
<option value="all">All Risk Levels</option>
<option value="critical">Critical</option>
<option value="high">High</option>
<option value="medium">Medium</option>
<option value="low">Low</option>
</select>
<button onclick="killAllFeatures()" class="px-4 py-1.5 bg-[var(--danger)] text-white text-sm font-bold rounded hover:brightness-110 transition">
KILL ALL
</button>
<button onclick="restoreAllFeatures()" class="px-4 py-1.5 bg-[var(--accent)] text-[var(--bg)] text-sm font-bold rounded hover:brightness-110 transition">
RESTORE ALL
</button>
</div>
</div>
<div id="featuresList" class="space-y-3">
<!-- Features will be rendered here -->
</div>
</div>
<!-- Side Panel -->
<div class="w-full lg:w-80 space-y-6">
<!-- Drill Control -->
<div class="bg-[var(--card)] rounded-lg border border-[var(--border)] p-4">
<h3 class="font-bold mb-4 flex items-center gap-2">
<svg class="w-5 h-5 text-[var(--warning)]" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/>
</svg>
Drill Control
</h3>
<div class="space-y-3">
<div>
<label class="text-xs text-[var(--muted)] uppercase tracking-wider">Drill Type</label>
<select id="drillType" class="w-full mt-1 bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 text-sm focus:border-[var(--accent)] focus:outline-none">
<option value="single">Single Feature</option>
<option value="cascade">Cascade Failure</option>
<option value="random">Random Selection</option>
<option value="full">Full System</option>
</select>
</div>
<div>
<label class="text-xs text-[var(--muted)] uppercase tracking-wider">Duration (seconds)</label>
<input type="number" id="drillDuration" value="30" min="5" max="300" class="w-full mt-1 bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 text-sm focus:border-[var(--accent)] focus:outline-none mono">
</div>
<div id="drillTargetContainer" class="hidden">
<label class="text-xs text-[var(--muted)] uppercase tracking-wider">Target Feature</label>
<select id="drillTarget" class="w-full mt-1 bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 text-sm focus:border-[var(--accent)] focus:outline-none">
</select>
</div>
<button onclick="startDrill()" id="drillBtn" class="w-full py-3 bg-[var(--warning)] text-[var(--bg)] font-bold rounded hover:brightness-110 transition">
START DRILL
</button>
<div id="drillProgress" class="hidden">
<div class="flex justify-between text-sm mb-2">
<span class="text-[var(--warning)]">DRILL IN PROGRESS</span>
<span class="mono drill-timer" id="drillTimer">00:00</span>
</div>
<div class="h-2 bg-[var(--bg)] rounded overflow-hidden">
<div id="drillProgressBar" class="h-full bg-[var(--warning)] transition-all duration-1000" style="width: 100%"></div>
</div>
<button onclick="abortDrill()" class="w-full mt-3 py-2 bg-[var(--danger)] text-white font-bold rounded hover:brightness-110 transition">
ABORT DRILL
</button>
</div>
</div>
</div>
<!-- Scheduled Drills -->
<div class="bg-[var(--card)] rounded-lg border border-[var(--border)] p-4">
<h3 class="font-bold mb-4 flex items-center gap-2">
<svg class="w-5 h-5 text-[var(--info)]" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>
<line x1="16" y1="2" x2="16" y2="6"/>
<line x1="8" y1="2" x2="8" y2="6"/>
<line x1="3" y1="10" x2="21" y2="10"/>
</svg>
Scheduled Drills
</h3>
<div id="scheduledDrills" class="space-y-2 text-sm">
<!-- Scheduled drills will appear here -->
</div>
<button onclick="openScheduleModal()" class="w-full mt-4 py-2 border border-[var(--border)] rounded text-[var(--muted)] hover:border-[var(--accent)] hover:text-[var(--accent)] transition text-sm">
+ Schedule New Drill
</button>
</div>
<!-- Activity Log -->
<div class="bg-[var(--card)] rounded-lg border border-[var(--border)] p-4">
<h3 class="font-bold mb-4 flex items-center gap-2">
<svg class="w-5 h-5 text-[var(--muted)]" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
<line x1="16" y1="13" x2="8" y2="13"/>
<line x1="16" y1="17" x2="8" y2="17"/>
</svg>
Activity Log
</h3>
<div id="activityLog" class="space-y-2 max-h-64 overflow-y-auto text-sm">
<!-- Logs will appear here -->
</div>
</div>
</div>
</div>
</main>
<!-- Confirmation Modal -->
<div id="confirmModal" class="fixed inset-0 z-50 hidden items-center justify-center modal-overlay">
<div class="bg-[var(--card)] rounded-lg border border-[var(--border)] p-6 max-w-md w-full mx-4 animate-slide-in">
<h3 class="text-xl font-bold mb-2" id="confirmTitle">Confirm Action</h3>
<p class="text-[var(--muted)] mb-6" id="confirmMessage">Are you sure you want to proceed?</p>
<div class="flex gap-3">
<button onclick="closeModal()" class="flex-1 py-2 border border-[var(--border)] rounded font-bold hover:border-[var(--accent)] transition">
Cancel
</button>
<button onclick="confirmAction()" id="confirmBtn" class="flex-1 py-2 bg-[var(--danger)] text-white rounded font-bold hover:brightness-110 transition">
Confirm
</button>
</div>
</div>
</div>
<!-- Schedule Modal -->
<div id="scheduleModal" class="fixed inset-0 z-50 hidden items-center justify-center modal-overlay">
<div class="bg-[var(--card)] rounded-lg border border-[var(--border)] p-6 max-w-md w-full mx-4 animate-slide-in">
<h3 class="text-xl font-bold mb-4">Schedule Drill</h3>
<div class="space-y-4">
<div>
<label class="text-xs text-[var(--muted)] uppercase tracking-wider">Drill Name</label>
<input type="text" id="scheduleName" placeholder="Weekly Drill" class="w-full mt-1 bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 text-sm focus:border-[var(--accent)] focus:outline-none">
</div>
<div>
<label class="text-xs text-[var(--muted)] uppercase tracking-wider">Schedule (Cron)</label>
<input type="text" id="scheduleCron" placeholder="0 9 * * 1" class="w-full mt-1 bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 text-sm focus:border-[var(--accent)] focus:outline-none mono">
<p class="text-xs text-[var(--muted)] mt-1">Example: "0 9 * * 1" = Every Monday at 9:00 AM</p>
</div>
<div>
<label class="text-xs text-[var(--muted)] uppercase tracking-wider">Drill Type</label>
<select id="scheduleDrillType" class="w-full mt-1 bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 text-sm focus:border-[var(--accent)] focus:outline-none">
<option value="random">Random Selection</option>
<option value="single">Single Feature</option>
<option value="cascade">Cascade Failure</option>
</select>
</div>
</div>
<div class="flex gap-3 mt-6">
<button onclick="closeScheduleModal()" class="flex-1 py-2 border border-[var(--border)] rounded font-bold hover:border-[var(--accent)] transition">
Cancel
</button>
<button onclick="saveScheduledDrill()" class="flex-1 py-2 bg-[var(--accent)] text-[var(--bg)] rounded font-bold hover:brightness-110 transition">
Schedule
</button>
</div>
</div>
</div>
<script>
// Feature Data
const features = [
{
id: 'payment-processing',
name: 'Payment Processing',
description: 'Handles all credit card and bank transactions',
riskLevel: 'critical',
status: 'alive',
dependencies: ['fraud-detection', 'order-service'],
lastToggled: null,
toggleCount: 0
},
{
id: 'fraud-detection',
name: 'Fraud Detection',
description: 'ML-powered fraud analysis for transactions',
riskLevel: 'critical',
status: 'alive',
dependencies: [],
lastToggled: null,
toggleCount: 0
},
{
id: 'user-auth',
name: 'User Authentication',
description: 'OAuth and session management',
riskLevel: 'high',
status: 'alive',
dependencies: ['session-store'],
lastToggled: null,
toggleCount: 0
},
{
id: 'ai-chatbot',
name: 'AI Chatbot Assistant',
description: 'Customer support AI assistant',
riskLevel: 'medium',
status: 'alive',
dependencies: [],
lastToggled: null,
toggleCount: 0
},
{
id: 'recommendations',
name: 'Product Recommendations',
description: 'Personalized product suggestion engine',
riskLevel: 'low',
status: 'alive',
dependencies: [],
lastToggled: null,
toggleCount: 0
},
{
id: 'email-campaigns',
name: 'Email Campaigns',
description: 'Automated marketing email sender',
riskLevel: 'medium',
status: 'alive',
dependencies: [],
lastToggled: null,
toggleCount: 0
},
{
id: 'data-export',
name: 'Data Export Service',
description: 'Bulk data export for analytics',
riskLevel: 'high',
status: 'alive',
dependencies: [],
lastToggled: null,
toggleCount: 0
},
{
id: 'push-notifications',
name: 'Push Notifications',
description: 'Mobile push notification service',
riskLevel: 'low',
status: 'alive',
dependencies: [],
lastToggled: null,
toggleCount: 0
}
];
let activityLog = [];
let scheduledDrills = [
{ id: 1, name: 'Weekly Drill', cron: '0 9 * * 1', type: 'random', nextRun: '2024-01-15 09:00' },
{ id: 2, name: 'Monthly Full Drill', cron: '0 3 1 * *', type: 'cascade', nextRun: '2024-02-01 03:00' }
];
let drillInterval = null;
let drillTimeRemaining = 0;
let pendingAction = null;
let drillActiveFeatures = [];
// Initialize
document.addEventListener('DOMContentLoaded', () => {
renderFeatures();
renderScheduledDrills();
updateStats();
updateClock();
setInterval(updateClock, 1000);
// Drill type change handler
document.getElementById('drillType').addEventListener('change', (e) => {
const targetContainer = document.getElementById('drillTargetContainer');
if (e.target.value === 'single') {
targetContainer.classList.remove('hidden');
populateDrillTargets();
} else {
targetContainer.classList.add('hidden');
}
});
// Filter change handler
document.getElementById('filterRisk').addEventListener('change', renderFeatures);
addLog('System initialized', 'info');
});
function updateClock() {
const now = new Date();
const timeStr = now.toLocaleTimeString('en-US', { hour12: false });
const dateStr = now.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
document.getElementById('clock').textContent = `${dateStr} ${timeStr}`;
}
function updateStats() {
const total = features.length;
const active = features.filter(f => f.status === 'alive').length;
const killed = features.filter(f => f.status === 'killed').length;
const drill = features.filter(f => f.status === 'drill').length;
document.getElementById('statTotal').textContent = total;
document.getElementById('statActive').textContent = active;
document.getElementById('statKilled').textContent = killed;
document.getElementById('statDrill').textContent = drill;
// Update system status
const statusEl = document.getElementById('systemStatus');
const indicator = statusEl.previousElementSibling;
if (drill > 0) {
statusEl.textContent = 'Drill in Progress';
indicator.className = 'status-indicator status-drill';
} else if (killed > 0) {
statusEl.textContent = `${killed} Feature(s) Killed`;
indicator.className = 'status-indicator status-killed';
} else {
statusEl.textContent = 'All Systems Nominal';
indicator.className = 'status-indicator status-alive';
}
}
function getRiskColor(level) {
const colors = {
critical: '#ff4757',
high: '#ffa502',
medium: '#3b82f6',
low: '#00d4aa'
};
return colors[level] || colors.low;
}
function getRiskPercent(level) {
const percents = {
critical: 100,
high: 75,
medium: 50,
low: 25
};
return percents[level] || 25;
}
function renderFeatures() {
const container = document.getElementById('featuresList');
const filter = document.getElementById('filterRisk').value;
const filtered = filter === 'all'
? features
: features.filter(f => f.riskLevel === filter);
container.innerHTML = filtered.map((feature, index) => {
const isKilled = feature.status === 'killed';
const isDrill = feature.status === 'drill';
const statusClass = isKilled ? 'killed' : (isDrill ? 'drill' : '');
return `
<div class="feature-card ${statusClass} bg-[var(--card)] rounded-lg p-4 animate-slide-in" style="animation-delay: ${index * 50}ms" data-id="${feature.id}">
<div class="flex items-start justify-between gap-4">
<div class="flex-1 min-w-0">
<div class="flex items-center gap-3 mb-1">
<span class="status-indicator ${isKilled ? 'status-killed' : (isDrill ? 'status-drill' : 'status-alive')}"></span>
<h3 class="font-bold truncate">${feature.name}</h3>
<span class="mono text-xs px-2 py-0.5 rounded" style="background: ${getRiskColor(feature.riskLevel)}20; color: ${getRiskColor(feature.riskLevel)}">
${feature.riskLevel.toUpperCase()}
</span>
${isDrill ? '<span class="text-xs px-2 py-0.5 bg-[var(--warning)] text-[var(--bg)] rounded animate-pulse-danger">DRILL</span>' : ''}
</div>
<p class="text-sm text-[var(--muted)] mb-3">${feature.description}</p>
<div class="flex items-center gap-4 text-xs text-[var(--muted)]">
<div class="flex items-center gap-2">
<span>Risk Level:</span>
<div class="risk-bar w-20">
<div class="risk-bar-fill" style="width: ${getRiskPercent(feature.riskLevel)}%; background: ${getRiskColor(feature.riskLevel)}"></div>
</div>
</div>
${feature.dependencies.length > 0 ? `<span>Deps: ${feature.dependencies.length}</span>` : ''}
${feature.toggleCount > 0 ? `<span>Toggled: ${feature.toggleCount}x</span>` : ''}
</div>
</div>
<button
onclick="toggleFeature('${feature.id}')"
class="kill-switch-btn px-4 py-2 rounded font-bold text-sm transition ${
isKilled
? 'bg-[var(--accent)] text-[var(--bg)] hover:brightness-110'
: 'bg-[var(--danger)] text-white hover:brightness-110'
}"
aria-label="${isKilled ? 'Restore' : 'Kill'} ${feature.name}"
>
${isKilled ? 'RESTORE' : 'KILL'}
</button>
</div>
</div>
`;
}).join('');
}
function toggleFeature(id) {
const feature = features.find(f => f.id === id);
if (!feature) return;
const action = feature.status === 'killed' ? 'restore' : 'kill';
pendingAction = {
type: 'single',
action,
featureId: id
};
document.getElementById('confirmTitle').textContent = action === 'kill' ? 'Kill Feature' : 'Restore Feature';
document.getElementById('confirmMessage').textContent = action === 'kill'
? `Are you sure you want to KILL "${feature.name}"? This may affect dependent features.`
: `Are you sure you want to RESTORE "${feature.name}"?`;
document.getElementById('confirmBtn').textContent = action === 'kill' ? 'Kill Feature' : 'Restore Feature';
document.getElementById('confirmBtn').className = `flex-1 py-2 ${action === 'kill' ? 'bg-[var(--danger)]' : 'bg-[var(--accent)]'} text-white rounded font-bold hover:brightness-110 transition`;
document.getElementById('confirmModal').classList.remove('hidden');
document.getElementById('confirmModal').classList.add('flex');
}
function killAllFeatures() {
pendingAction = { type: 'killAll' };
document.getElementById('confirmTitle').textContent = 'Kill All Features';
document.getElementById('confirmMessage').textContent = 'WARNING: This will immediately kill ALL features. This action may cause complete system unavailability.';
document.getElementById('confirmBtn').textContent = 'Kill All';
document.getElementById('confirmBtn').className = 'flex-1 py-2 bg-[var(--danger)] text-white rounded font-bold hover:brightness-110 transition';
document.getElementById('confirmModal').classList.remove('hidden');
document.getElementById('confirmModal').classList.add('flex');
}
function restoreAllFeatures() {
pendingAction = { type: 'restoreAll' };
document.getElementById('confirmTitle').textContent = 'Restore All Features';
document.getElementById('confirmMessage').textContent = 'This will restore all killed features to active status.';
document.getElementById('confirmBtn').textContent = 'Restore All';
document.getElementById('confirmBtn').className = 'flex-1 py-2 bg-[var(--accent)] text-[var(--bg)] rounded font-bold hover:brightness-110 transition';
document.getElementById('confirmModal').classList.remove('hidden');
document.getElementById('confirmModal').classList.add('flex');
}
function closeModal() {
document.getElementById('confirmModal').classList.add('hidden');
document.getElementById('confirmModal').classList.remove('flex');
pendingAction = null;
}
function confirmAction() {
if (!pendingAction) return;
if (pendingAction.type === 'single') {
const feature = features.find(f => f.id === pendingAction.featureId);
if (feature) {
const wasKilled = feature.status === 'killed';
feature.status = wasKilled ? 'alive' : 'killed';
feature.lastToggled = new Date().toISOString();
feature.toggleCount++;
addLog(`${wasKilled ? 'Restored' : 'Killed'} feature: ${feature.name}`, wasKilled ? 'success' : 'danger');
}
} else if (pendingAction.type === 'killAll') {
features.forEach(f => {
if (f.status === 'alive') {
f.status = 'killed';
f.lastToggled = new Date().toISOString();
f.toggleCount++;
}
});
addLog('KILLED ALL FEATURES', 'danger');
} else if (pendingAction.type === 'restoreAll') {
features.forEach(f => {
if (f.status === 'killed' || f.status === 'drill') {
f.status = 'alive';
f.lastToggled = new Date().toISOString();
}
});
addLog('Restored all features', 'success');
}
closeModal();
renderFeatures();
updateStats();
}
function populateDrillTargets() {
const select = document.getElementById('drillTarget');
select.innerHTML = features.map(f =>
`<option value="${f.id}">${f.name}</option>`
).join('');
}
function startDrill() {
const type = document.getElementById('drillType').value;
const duration = Math.max(5, Math.min(300, parseInt(document.getElementById('drillDuration').value) || 30));
drillActiveFeatures = [];
if (type === 'single') {
const targetId = document.getElementById('drillTarget').value;
const feature = features.find(f => f.id === targetId);
if (feature && feature.status === 'alive') {
feature.status = 'drill';
drillActiveFeatures.push(feature);
}
} else if (type === 'random') {
const aliveFeatures = features.filter(f => f.status === 'alive');
const count = Math.max(1, Math.floor(aliveFeatures.length * 0.3));
const shuffled = aliveFeatures.sort(() => Math.random() - 0.5);
drillActiveFeatures = shuffled.slice(0, count);
drillActiveFeatures.forEach(f => f.status = 'drill');
} else if (type === 'cascade') {
const aliveFeatures = features.filter(f => f.status === 'alive');
const sorted = [...aliveFeatures].sort((a, b) => {
const riskOrder = { critical: 0, high: 1, medium: 2, low: 3 };
return riskOrder[a.riskLevel] - riskOrder[b.riskLevel];
});
drillActiveFeatures = sorted.slice(0, 3);
drillActiveFeatures.forEach(f => f.status = 'drill');
} else if (type === 'full') {
features.forEach(f => {
if (f.status === 'alive') {
f.status = 'drill';
drillActiveFeatures.push(f);
}
});
}
if (drillActiveFeatures.length === 0) {
addLog('Drill aborted: No features available', 'warning');
return;
}
addLog(`Started ${type} drill for ${drillActiveFeatures.length} feature(s)`, 'warning');
drillTimeRemaining = duration;
document.getElementById('drillBtn').classList.add('hidden');
document.getElementById('drillProgress').classList.remove('hidden');
updateDrillTimer();
drillInterval = setInterval(() => {
drillTimeRemaining--;
updateDrillTimer();
if (drillTimeRemaining <= 0) {
endDrill();
}
}, 1000);
renderFeatures();
updateStats();
}
function updateDrillTimer() {
const minutes = Math.floor(drillTimeRemaining / 60);
const seconds = drillTimeRemaining % 60;
document.getElementById('drillTimer').textContent =
`${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
const duration = parseInt(document.getElementById('drillDuration').value) || 30;
const progress = (drillTimeRemaining / duration) * 100;
document.getElementById('drillProgressBar').style.width = `${progress}%`;
}
function abortDrill() {
if (drillInterval) {
clearInterval(drillInterval);
drillInterval = null;
}
endDrill(true);
}
function endDrill(aborted = false) {
drillActiveFeatures.forEach(f => {
f.status = 'alive';
});
addLog(aborted ? 'Drill aborted manually' : 'Drill completed successfully', aborted ? 'warning' : 'success');
drillActiveFeatures = [];
document.getElementById('drillBtn').classList.remove('hidden');
document.getElementById('drillProgress').classList.add('hidden');
if (drillInterval) {
clearInterval(drillInterval);
drillInterval = null;
}
renderFeatures();
updateStats();
}
function renderScheduledDrills() {
const container = document.getElementById('scheduledDrills');
if (scheduledDrills.length === 0) {
container.innerHTML = '<p class="text-[var(--muted)] text-center py-4">No scheduled drills</p>';
return;
}
container.innerHTML = scheduledDrills.map(drill => `
<div class="flex items-center justify-between p-2 bg-[var(--bg)] rounded">
<div>
<div class="font-medium">${drill.name}</div>
<div class="text-xs text-[var(--muted)] mono">${drill.cron}</div>
</div>
<button onclick="deleteScheduledDrill(${drill.id})" class="p-1 hover:text-[var(--danger)] transition" aria-label="Delete drill">
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18"/>
<line x1="6" y1="6" x2="18" y2="18"/>
</svg>
</button>
</div>
`).join('');
}
function openScheduleModal() {
document.getElementById('scheduleModal').classList.remove('hidden');
document.getElementById('scheduleModal').classList.add('flex');
}
function closeScheduleModal() {
document.getElementById('scheduleModal').classList.add('hidden');
document.getElementById('scheduleModal').classList.remove('flex');
}
function saveScheduledDrill() {
const name = document.getElementById('scheduleName').value || 'Unnamed Drill';
const cron = document.getElementById('scheduleCron').value || '0 9 * * 1';
const type = document.getElementById('scheduleDrillType').value;
const newDrill = {
id: Date.now(),
name,
cron,
type,
nextRun: 'Pending calculation'
};
scheduledDrills.push(newDrill);
renderScheduledDrills();
closeScheduleModal();
addLog(`Scheduled new drill: ${name}`, 'info');
// Reset form
document.getElementById('scheduleName').value = '';
document.getElementById('scheduleCron').value = '';
}
function deleteScheduledDrill(id) {
scheduledDrills = scheduledDrills.filter(d => d.id !== id);
renderScheduledDrills();
addLog('Deleted scheduled drill', 'info');
}
function addLog(message, type = 'info') {
const now = new Date();
const timestamp = now.toLocaleTimeString('en-US', { hour12: false });
activityLog.unshift({ timestamp, message, type });
// Keep only last 50 entries
if (activityLog.length > 50) {
activityLog = activityLog.slice(0, 50);
}
renderActivityLog();
}
function renderActivityLog() {
const container = document.getElementById('activityLog');
const typeColors = {
danger: 'var(--danger)',
warning: 'var(--warning)',
success: 'var(--accent)',
info: 'var(--muted)'
};
container.innerHTML = activityLog.map(entry => `
<div class="log-entry pl-3 py-2">
<div class="flex items-center gap-2">
<span class="mono text-xs text-[var(--muted)]">${entry.timestamp}</span>
<span class="w-2 h-2 rounded-full" style="background: ${typeColors[entry.type]}"></span>
</div>
<div class="mt-0.5" style="color: ${entry.type === 'danger' ? 'var(--danger)' : entry.type === 'warning' ? 'var(--warning)' : 'var(--fg)'}">${entry.message}</div>
</div>
`).join('');
}
// Keyboard support
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
closeModal();
closeScheduleModal();
}
});
</script>
</body>
</html>
Key Features
Kill Switch Controls
- Individual Kill/Restore: Toggle each feature independently with confirmation
- Kill All / Restore All: Emergency bulk operations
- Risk Level Filtering: Filter features by criticality (Critical, High, Medium, Low)
- Visual Status Indicators: Clear color coding for alive (green), killed (red), and drill (yellow) states
Drill System
-
Four Drill Types:
- Single Feature: Target one specific feature
- Random Selection: Randomly disables ~30% of active features
- Cascade Failure: Simulates cascading failure by hitting highest-risk features first
- Full System: Tests complete system shutdown
-
Configurable Duration: 5-300 seconds
-
Live Progress Timer: Countdown with visual progress bar
-
Abort Capability: Emergency abort during active drills
Safety Features
- Confirmation Modals: All destructive actions require explicit confirmation
- Activity Logging: Full audit trail of all kill/restore/drill actions
- Dependency Tracking: Features show their dependency count
- Toggle History: Track how many times each feature has been toggled
Scheduled Drills
- Add recurring drills with cron-style scheduling
- Different drill types for scheduled runs
- Easy management of scheduled items
Visual Design
- Dark industrial theme with grid background
- Scanning line animation for active system feel
- Risk level bars for quick assessment
- Staggered entrance animations for feature cards
- Respects
prefers-reduced-motion for accessibility