<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DATA.SPEC | Automated Dataset Documentation</title>
<!-- Fonts -->
<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=Inter:wght@300;400;500;600&family=Playfair+Display:wght@400;700&family=JetBrains+Mono:wght@400&display=swap" rel="stylesheet">
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
'void': '#050505',
'glass': 'rgba(255, 255, 255, 0.05)',
'glass-border': 'rgba(255, 255, 255, 0.1)',
'accent': '#00f0ff',
'accent-glow': 'rgba(0, 240, 255, 0.3)',
'warn': '#ffaa00',
'success': '#00ff9d'
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif'],
mono: ['JetBrains Mono', 'monospace']
},
boxShadow: {
'glow': '0 0 20px var(--tw-glow-color)',
}
}
}
}
</script>
<!-- GSAP -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<style>
/* Custom Styles */
body {
background-color: #050505;
color: #e5e5e5;
overflow: hidden; /* Main canvas handles overflow */
}
/* Noise Overlay */
.noise {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 50;
opacity: 0.03;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}
/* Custom Scrollbar */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: rgba(255,255,255,0.02);
}
::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.2);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(255,255,255,0.4);
}
/* Glassmorphism Utilities */
.glass-panel {
background: rgba(255, 255, 255, 0.03);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}
.glass-panel:hover {
border-color: rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.06);
}
/* Inputs */
.data-input {
background: rgba(0,0,0,0.3);
border: 1px solid rgba(255,255,255,0.1);
color: #fff;
transition: all 0.3s ease;
}
.data-input:focus {
outline: none;
border-color: #00f0ff;
box-shadow: 0 0 15px rgba(0, 240, 255, 0.15);
}
/* Magnetic Button Effect Placeholder (JS handles scale) */
.magnetic-btn {
transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Selection Highlight */
::selection {
background: rgba(0, 240, 255, 0.3);
}
/* Preview Typography */
.preview-h1 {
font-size: 2.5rem; /* 40px */
line-height: 1.2;
letter-spacing: -0.02em;
}
.preview-label {
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.15em;
color: #888;
}
</style>
</head>
<body class="antialiased">
<!-- Noise Texture -->
<div class="noise"></div>
<!-- Three.js Background -->
<canvas id="bg-canvas" class="fixed top-0 left-0 w-full h-full -z-10"></canvas>
<!-- Main Container -->
<main class="flex h-screen w-full relative z-10">
<!-- Left: Construction Panel -->
<section class="w-[450px] min-w-[450px] h-full flex flex-col border-r border-white/10 bg-void/80 backdrop-blur-md">
<header class="p-8 border-b border-white/10 flex items-center justify-between">
<div class="flex items-center gap-3">
<div class="w-8 h-8 bg-accent rounded-full flex items-center justify-center shadow-[0_0_10px_#00f0ff]">
<span class="text-black font-bold text-xs">DS</span>
</div>
<h1 class="text-xl font-serif font-bold tracking-wide">DATA.SPEC</h1>
</div>
<span class="text-xs font-mono text-accent animate-pulse">v2.4.0 // LIVE</span>
</header>
<div class="flex-1 overflow-y-auto p-8 custom-scrollbar">
<div class="space-y-8">
<!-- Identity -->
<div class="space-y-4">
<h2 class="preview-label text-accent">Dataset Identity</h2>
<div>
<label class="block text-xs mb-2 opacity-50">Dataset Name</label>
<input type="text" id="ds-name" class="data-input w-full h-10 px-4 rounded-lg text-sm" placeholder="e.g. Customer_Churn_2024" value="Customer_Churn_Q3">
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-xs mb-2 opacity-50">Domain</label>
<select id="ds-domain" class="data-input w-full h-10 px-4 rounded-lg text-sm bg-black/40">
<option value="Finance">Finance</option>
<option value="Healthcare">Healthcare</option>
<option value="Retail">Retail</option>
<option value="Tech">Tech</option>
<option value="Public">Public Sector</option>
</select>
</div>
<div>
<label class="block text-xs mb-2 opacity-50">Version</label>
<input type="text" id="ds-version" class="data-input w-full h-10 px-4 rounded-lg text-sm bg-black/40" value="1.2.0">
</div>
</div>
</div>
<!-- Compliance Toggles -->
<div class="space-y-4">
<h2 class="preview-label text-accent">Risk Configuration</h2>
<div class="glass-panel p-4 rounded-xl space-y-4">
<div class="flex items-center justify-between">
<div>
<div class="text-sm font-medium">Contains PII/PHI</div>
<div class="text-xs text-gray-400">Personally Identifiable Info</div>
</div>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" id="ds-pii" class="sr-only peer" checked>
<div class="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-accent"></div>
</label>
</div>
<div class="flex items-center justify-between">
<div>
<div class="text-sm font-medium">Sensitive Data</div>
<div class="text-xs text-gray-400">Biometrics, Genetic, etc.</div>
</div>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" id="ds-sensitive" class="sr-only peer">
<div class="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-warn"></div>
</label>
</div>
</div>
</div>
<!-- Schema Builder -->
<div class="space-y-4">
<div class="flex justify-between items-center">
<h2 class="preview-label text-accent">Data Schema</h2>
<button id="add-field-btn" class="magnetic-btn text-xs bg-white text-black px-3 py-1.5 rounded font-bold hover:bg-accent transition-colors">
+ Add Column
</button>
</div>
<div class="space-y-2" id="fields-container">
<!-- Rows will be injected here -->
</div>
</div>
</div>
</div>
<div class="p-8 border-t border-white/10">
<button id="export-btn" class="magnetic-btn w-full bg-gradient-to-r from-accent to-blue-600 text-black font-bold py-3 px-6 rounded-lg shadow-glow hover:shadow-[0_0_30px_rgba(0,240,255,0.5)] transition-all transform hover:scale-[1.02]">
Generate Documentation
</button>
</div>
</section>
<!-- Right: Live Preview -->
<section class="flex-1 h-full overflow-y-auto p-16 relative" id="preview-scroll">
<div class="max-w-4xl mx-auto space-y-12 pb-32">
<!-- Header of Doc -->
<header class="border-b border-white/10 pb-8">
<div class="flex justify-between items-end mb-6">
<div>
<p class="preview-label text-accent mb-2">DATA SHEET</p>
<h1 id="preview-title" class="preview-h1 font-serif font-bold">Customer Churn Q3</h1>
</div>
<div class="text-right">
<p class="text-sm text-gray-400">Generated</p>
<p id="preview-date" class="text-xl font-mono">2023-10-24</p>
</div>
</div>
<!-- GED Summary Bar -->
<div class="grid grid-cols-3 gap-4">
<div class="glass-panel rounded-lg p-4 flex flex-col">
<span class="text-xs text-gray-400 uppercase">Version</span>
<span id="preview-version" class="text-lg font-mono mt-1">1.2.0</span>
</div>
<div class="glass-panel rounded-lg p-4 flex flex-col">
<span class="text-xs text-gray-400 uppercase">Domain</span>
<span id="preview-domain" class="text-lg font-medium mt-1">Finance</span>
</div>
<div class="glass-panel rounded-lg p-4 flex flex-col relative overflow-hidden group">
<span class="text-xs text-gray-400 uppercase z-10">GED Score</span>
<div class="flex items-center gap-2 mt-1 z-10 relative">
<div class="w-16 h-16 rounded-full border-4 border-gray-800 flex items-center justify-center relative" id="ged-circle">
<svg class="w-10 h-10 transform -rotate-90" viewBox="0 0 36 36">
<path class="text-gray-800" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" fill="none" stroke="currentColor" stroke-width="3" />
<path id="ged-progress" class="text-accent transition-all duration-1000 ease-out" stroke-dasharray="0, 100" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" fill="none" stroke="currentColor" stroke-width="3" />
</svg>
<span class="absolute text-xs font-bold" id="ged-score-text">0%</span>
</div>
</div>
</div>
</div>
</header>
<!-- Description -->
<section>
<h3 class="text-sm font-bold mb-4 tracking-widest uppercase text-accent">Abstract</h3>
<p id="preview-desc" class="text-lg leading-relaxed text-gray-300 max-w-3xl">
This dataset contains customer behavior metrics for Q3 2024. It includes transaction history, credit score approximations, and churn indicators. It is intended for predictive modeling of client retention strategies.
</p>
<div class="flex gap-2 mt-4">
<span class="px-2 py-1 bg-white/10 rounded text-xs text-gray-300">#retention</span>
<span class="px-2 py-1 bg-white/10 rounded text-xs text-gray-300">#finance</span>
<span class="px-2 py-1 bg-white/10 rounded text-xs text-gray-300">#marketing</span>
</div>
</section>
<!-- Schema Data Sheet -->
<section>
<h3 class="text-sm font-bold mb-6 tracking-widest uppercase text-accent">Schema Specification</h3>
<div class="glass-panel rounded-xl overflow-hidden">
<table class="w-full text-left border-collapse">
<thead>
<tr class="bg-white/5 text-xs uppercase text-gray-400 border-b border-white/10">
<th class="p-4 font-medium">Field Name</th>
<th class="p-4 font-medium">Data Type</th>
<th class="p-4 font-medium">Sensitivity</th>
<th class="p-4 font-medium">Description</th>
</tr>
</thead>
<tbody id="preview-table-body" class="text-sm divide-y divide-white/5">
<!-- Rows injected -->
</tbody>
</table>
</div>
</section>
<!-- GED Compliance Log -->
<section>
<div class="flex items-center justify-between mb-6">
<h3 class="text-sm font-bold tracking-widest uppercase text-accent">GED Compliance Log</h3>
<div class="flex items-center gap-2 text-xs font-mono text-gray-500">
<span class="w-2 h-2 rounded-full bg-success animate-pulse"></span>
SYSTEM AUDIT READY
</div>
</div>
<div id="ged-log" class="glass-panel rounded-xl p-6 font-mono text-xs space-y-4 h-auto">
<!-- Log lines injected -->
</div>
</section>
<footer class="text-center text-gray-600 text-sm pt-10">
Generated by DATA.SPEC Enterprise · Ethically sourced AI · Swiss Design Protocols
</footer>
</div>
</section>
</main>
<script>
// --- 1. Three.js Background Animation ---
const initThreeJS = () => {
const canvas = document.getElementById('bg-canvas');
const scene = new THREE.Scene();
// Camera
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 30;
// Renderer
const renderer = new THREE.WebGLRenderer({ canvas: canvas, alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
// Particles
const particlesGeometry = new THREE.BufferGeometry();
const particlesCount = 700;
const posArray = new Float32Array(particlesCount * 3);
for(let i = 0; i < particlesCount * 3; i++) {
posArray[i] = (Math.random() - 0.5) * 100;
}
particlesGeometry.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
// Material with a soft circle texture generated programmatically
const getTexture = () => {
const canvas = document.createElement('canvas');
canvas.width = 32;
canvas.height = 32;
const ctx = canvas.getContext('2d');
const grad = ctx.createRadialGradient(16,16,0,16,16,16);
grad.addColorStop(0, 'rgba(255,255,255,1)');
grad.addColorStop(1, 'rgba(255,255,255,0)');
ctx.fillStyle = grad;
ctx.fillRect(0,0,32,32);
const texture = new THREE.Texture(canvas);
texture.needsUpdate = true;
return texture;
};
const material = new THREE.PointsMaterial({
size: 0.6,
map: getTexture(),
transparent: true,
opacity: 0.6,
color: 0x00f0ff,
blending: THREE.AdditiveBlending,
depthWrite: false
});
const particlesMesh = new THREE.Points(particlesGeometry, material);
scene.add(particlesMesh);
// Mouse Interaction
let mouseX = 0;
let mouseY = 0;
let targetX = 0;
let targetY = 0;
const windowHalfX = window.innerWidth / 2;
const windowHalfY = window.innerHeight / 2;
document.addEventListener('mousemove', (event) => {
mouseX = (event.clientX - windowHalfX);
mouseY = (event.clientY - windowHalfY);
});
// Animate
const animate = () => {
requestAnimationFrame(animate);
targetX = mouseX * 0.001;
targetY = mouseY * 0.001;
particlesMesh.rotation.y += 0.001;
particlesMesh.rotation.x += (targetY - particlesMesh.rotation.x) * 0.05;
particlesMesh.rotation.z += (targetX - particlesMesh.rotation.z) * 0.05;
// Pulse opacity
const time = Date.now() * 0.0005;
material.opacity = 0.6 + Math.sin(time) * 0.2;
renderer.render(scene, camera);
};
animate();
// Resize
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
};
// --- 2. Application State & Logic ---
const AppState = {
name: "Customer_Churn_Q3",
domain: "Finance",
version: "1.2.0",
pii: true,
sensitive: false,
fields: [
{ id: 1, name: "customer_id", type: "UUID", sensitivity: "Low", desc: "Unique identifier" },
{ id: 2, name: "age", type: "Integer", sensitivity: "Low", desc: "Age in years" },
{ id: 3, name: "income_annual", type: "Float", sensitivity: "Medium", desc: "Annual gross income" },
{ id: 4, name: "churn_risk", type: "Boolean", sensitivity: "Low", desc: "Predicted churn likelihood" },
{ id: 5, name: "ssn_hash", type: "String", sensitivity: "High", desc: "Hashed social security number" }
]
};
// DOM Elements
const els = {
name: document.getElementById('ds-name'),
domain: document.getElementById('ds-domain'),
version: document.getElementById('ds-version'),
pii: document.getElementById('ds-pii'),
sensitive: document.getElementById('ds-sensitive'),
fieldsContainer: document.getElementById('fields-container'),
addFieldBtn: document.getElementById('add-field-btn'),
// Preview
pTitle: document.getElementById('preview-title'),
pDate: document.getElementById('preview-date'),
pVersion: document.getElementById('preview-version'),
pDomain: document.getElementById('preview-domain'),
pDesc: document.getElementById('preview-desc'),
pTableBody: document.getElementById('preview-table-body'),
pGedLog: document.getElementById('ged-log'),
pGedCircle: document.getElementById('ged-progress'),
pGedScore: document.getElementById('ged-score-text'),
exportBtn: document.getElementById('export-btn')
};
// --- 3. GED Logic (Simulation) ---
const generateGEDLog = (state) => {
const logs = [];
const date = new Date().toISOString().split('T')[0];
// Basic Checks
logs.push(`[INFO] Audit started for dataset: ${state.name}`);
logs.push(`[INFO] Version: ${state.version}, Domain: ${state.domain}`);
// Compliance Logic
if (state.pii) {
logs.push(`[WARN] PII detected. Encryption-in-transit enforced (TLS 1.3).`);
logs.push(`[WARN] PII detected. Data masking required for non-admin roles.`);
logs.push(`[CHECK] GDPR Art. 5(1)(f) - Integrity/Confidentiality: PASS`);
} else {
logs.push(`[INFO] No PII flagged (Mode: Non-Personal).`);
}
if (state.sensitive) {
logs.push(`[CRIT] Special category data (Sensitive) detected. Access Logging mandatory.`);
logs.push(`[CHECK] Retention Policy: 24 months max.`);
} else {
logs.push(`[INFO] No Special Category data (Sensitive) found.`);
}
// Schema Analysis
const highSensitivityFields = state.fields.filter(f => f.sensitivity === 'High').length;
if (highSensitivityFields > 0) {
logs.push(`[WARN] ${highSensitivityFields} fields marked High Sensitivity.`);
}
// Score Calculation (Mock)
let score = 85;
let color = 'text-accent';
if (state.pii) score -= 10;
if (state.sensitive) score -= 15;
if (state.fields.length < 3) score -= 20;
score = Math.max(10, Math.min(100, score));
if (score >= 90) color = 'text-success';
else if (score < 60) color = 'text-warn';
logs.push(`[RESULT] Final GED Compliance Score: **${score}%**`);
logs.push(`[SYSTEM] Documentation artifact built successfully.`);
logs.push(`[END] Session ${Math.random().toString(36).substr(2, 9).toUpperCase()}`);
return { logs, score, color };
};
// --- 4. Render Functions ---
// Field Row Template Generator (for Left Panel)
const createFieldRow = (field) => {
const div = document.createElement('div');
div.className = 'grid grid-cols-12 gap-2 items-center animate-fade-in';
div.dataset.id = field.id;
div.innerHTML = `
<div class="col-span-4">
<input type="text" value="${field.name}" class="field-name data-input w-full h-8 px-2 text-xs rounded" placeholder="Name">
</div>
<div class="col-span-3">
<select class="field-type data-input w-full h-8 text-xs rounded bg-black/40">
<option value="String" ${field.type === 'String' ? 'selected' : ''}>String</option>
<option value="Integer" ${field.type === 'Integer' ? 'selected' : ''}>Integer</option>
<option value="Float" ${field.type === 'Float' ? 'selected' : ''}>Float</option>
<option value="Boolean" ${field.type === 'Boolean' ? 'selected' : ''}>Bool</option>
<option value="Date" ${field.type === 'Date' ? 'selected' : ''}>Date</option>
<option value="UUID" ${field.type === 'UUID' ? 'selected' : ''}>UUID</option>
</select>
</div>
<div class="col-span-3">
<select class="field-sens data-input w-full h-8 text-xs rounded bg-black/40">
<option value="Low" ${field.sensitivity === 'Low' ? 'selected' : ''}>Low</option>
<option value="Medium" ${field.sensitivity === 'Medium' ? 'selected' : ''}>Med</option>
<option value="High" ${field.sensitivity === 'High' ? 'selected' : ''}>High</option>
</select>
</div>
<div class="col-span-2 flex gap-1">
<button class="delete-row text-xs text-red-400 hover:bg-red-900/30 px-2 py-1 rounded transition-colors">×</button>
</div>
`;
return div;
};
// Render Preview Panel
const renderPreview = () => {
const state = AppState;
const gedData = generateGEDLog(state);
// Text Updates
els.pTitle.textContent = state.name || "[Untitled Dataset]";
els.pVersion.textContent = state.version;
els.pDomain.textContent = state.domain;
// Dynamic Description based on state
let desc = `This dataset contains information relevant to the ${state.domain} sector. Version ${state.version} includes fields used for analytical purposes. `;
if (state.pii) desc += "It contains Personally Identifiable Information (PII). ";
if (state.sensitive) desc += "It contains highly sensitive biometric or genetic data. ";
desc += "The schema below defines the structure and sensitivity levels of each column.";
els.pDesc.textContent = desc;
// Date update
const today = new Date().toISOString().split('T')[0];
els.pDate.textContent = today;
// Table Render
els.pTableBody.innerHTML = '';
state.fields.forEach((field, index) => {
const row = document.createElement('tr');
row.className = 'group hover:bg-white/5 transition-colors';
row.innerHTML = `
<td class="p-4 font-mono text-accent">${field.name}</td>
<td class="p-4 text-gray-300">${field.type}</td>
<td class="p-4">
<span class="px-2 py-1 rounded text-[10px] uppercase font-bold tracking-wide
${field.sensitivity === 'Low' ? 'bg-gray-800 text-gray-300' : ''}
${field.sensitivity === 'Medium' ? 'bg-warn/20 text-warn' : ''}
${field.sensitivity === 'High' ? 'bg-red-900/30 text-red-400' : ''}">
${field.sensitivity}
</span>
</td>
<td class="p-4 text-gray-500 text-sm">${field.desc}</td>
`;
els.pTableBody.appendChild(row);
});
// GED Log Render
els.pGedLog.innerHTML = '';
gedData.logs.forEach((log, i) => {
const line = document.createElement('div');
line.className = 'flex gap-3 items-start opacity-0';
line.innerHTML = `
<span class="text-gray-500 select-none">${String(i+1).padStart(3,'0')}</span>
<span class="whitespace-pre-wrap text-gray-300 leading-loose">${log}</span>
`;
els.pGedLog.appendChild(line);
});
// Animate Log Lines with GSAP
setTimeout(() => {
gsap.to('.opacity-0', {
opacity: 1,
duration: 0.3,
stagger: 0.05,
ease: "power2.out"
});
}, 10);
// Animate GED Score
gsap.to(els.pGedCircle, {
strokeDashoffset: 100 - gedData.score,
duration: 1.5,
ease: "elastic.out(1, 0.5)"
});
gsap.to(els.pGedScore, {
innerText: gedData.score,
duration: 1.5,
snap: { innerText: 1 },
ease: "power1.out"
});
els.pGedScore.parentElement.style.color = gedData.color === 'text-success' ? '#00ff9d' : (gedData.color === 'text-warn' ? '#ffaa00' : '#00f0ff');
};
// --- 5. Event Listeners & Initialization ---
const initApp = () => {
// Render initial state
renderFields();
renderPreview();
// Inputs binding
const inputs = [els.name, els.domain, els.version, els.pii, els.sensitive];
inputs.forEach(input => {
input.addEventListener('input', (e) => {
if(e.target.type === 'checkbox') {
AppState[e.target.id.replace('ds-', '')] = e.target.checked;
} else {
AppState[e.target.id.replace('ds-', '')] = e.target.value;
}
renderPreview();
});
});
// Add Field
els.addFieldBtn.addEventListener('click', () => {
const newId = Date.now();
AppState.fields.push({
id: newId,
name: "new_column",
type: "String",
sensitivity: "Low",
desc: "Description..."
});
renderFields();
renderPreview();
});
// Field List Listeners (Delegation)
els.fieldsContainer.addEventListener('input', (e) => {
const row = e.target.closest('div[data-id]');
if(!row) return;
const id = parseInt(row.dataset.id);
const field = AppState.fields.find(f => f.id === id);
if(field) {
if(e.target.classList.contains('field-name')) field.name = e.target.value;
if(e.target.classList.contains('field-type')) field.type = e.target.value;
if(e.target.classList.contains('field-sens')) field.sensitivity = e.target.value;
renderPreview(); // Live update preview
}
});
els.fieldsContainer.addEventListener('click', (e) => {
if(e.target.classList.contains('delete-row')) {
const row = e.target.closest('div[data-id]');
const id = parseInt(row.dataset.id);
AppState.fields = AppState.fields.filter(f => f.id !== id);
renderFields();
renderPreview();
}
});
// Export Button
els.exportBtn.addEventListener('click', () => {
const originalText = els.exportBtn.textContent;
els.exportBtn.textContent = "Downloading PDF...";
els.exportBtn.classList.add('scale-95');
setTimeout(() => {
els.exportBtn.textContent = "Exported!";
setTimeout(() => {
els.exportBtn.textContent = originalText;
els.exportBtn.classList.remove('scale-95');
}, 2000);
}, 1000);
});
};
const renderFields = () => {
els.fieldsContainer.innerHTML = '';
AppState.fields.forEach(field => {
els.fieldsContainer.appendChild(createFieldRow(field));
});
};
// --- 6. Magnetic Effect ---
const initMagneticButtons = () => {
const buttons = document.querySelectorAll('.magnetic-btn');
buttons.forEach(btn => {
btn.addEventListener('mousemove', (e) => {
const rect = btn.getBoundingClientRect();
const x = e.clientX - rect.left - rect.width / 2;
const y = e.clientY - rect.top - rect.height / 2;
btn.style.transform = `translate(${x * 0.3}px, ${y * 0.3}px)`;
});
btn.addEventListener('mouseleave', () => {
btn.style.transform = 'translate(0, 0)';
});
});
};
// --- Boot ---
window.addEventListener('DOMContentLoaded', () => {
initThreeJS();
initApp();
initMagneticButtons();
// Initial GSAP Entrance
const ctx = gsap.context(() => {
gsap.from("header", { y: -50, opacity: 0, duration: 1, ease: "power3.out" });
gsap.from(".w-\\[450px\\]", { x: -50, opacity: 0, duration: 1, delay: 0.2, ease: "power3.out" });
gsap.from("#preview-title", { y: 20, opacity: 0, duration: 1, delay: 0.4, ease: "power3.out" });
});
});
</script>
</body>
</html>