Here's a thinking process that leads to the suggested human annotation feedback UI:
-
Understand the Goal: The user wants a "human annotation feedback UI for LLM responses capturing rating rubrics, notes, and active learning." This is a specialized tool for data labeling/curation, often used to fine-tune LLMs or evaluate their performance. It needs to be functional, not just a "showcase," but the system prompt demands top-tier design (Swiss/International style, micro-interactions, GSAP, 3D/shading, etc.). It's a tool, so usability is paramount, but it must look incredible.
-
Analyze the Requirements:
- Core Functionality:
- Display an LLM prompt and its generated response.
- Allow rating/annotation based on rubrics (e.g., correctness, relevance, tone, safety).
- Capture free-text notes.
- Incorporate "active learning" (e.g., showing a confidence score, flagging uncertain items, or maybe a "batch" view).
- Design/Aesthetic: Swiss Design, minimalist, deep typography, negative space, high-quality interactions (magnetic buttons, parallax, glassmorphism, noise textures), high contrast (often dark mode with neon accents or very clean light). "Top-tier front-end engineer" persona.
- Tech Stack: Single HTML file. Tailwind CSS (for styling). GSAP (for animations). No external frameworks (React/Vue). Vanilla JS.
-
Conceptualize the Layout:
- Background: Deep, rich dark (#050505) with a subtle mesh gradient or noise texture. Maybe a 3D particle effect or a WebGL shader in the background for "depth" without distraction. Since it's a tool, the background should remain unobtrusive but evocative.
- Structure: A split view or centered view. Given the complexity of annotations, a two-column layout works best:
- Left: The prompt ("User Query") and the model output ("LLM Response"). This is the content being judged.
- Right: The annotation interface (Rubric sliders/buttons, text area for notes, submit/next).
- Header: Minimal. Title, maybe a progress bar.
- Active Learning Element: Show the model's "confidence" or "entropy" score. Use a gauge or a distinct visual indicator. If the AI is "confident" vs "uncertain," maybe the background tint changes slightly.
-
Step-by-Step Implementation Plan:
-
Refining the Design (Swiss Style):
- Heavy use of grid lines? Maybe.
- Big, bold numbers for scores.
- High contrast: White text on black.
- Functional: Key information (prompt, response) must be instantly readable.
-
Drafting the Code (Mental or Scratchpad):
- Setup: CDN links for Tailwind, GSAP, Three.js.
- Background: Three.js boilerplate. Scene, Camera, Renderer. Create 1000 particles (PointsMaterial). Animate loop.
- State Management: Simple JS object
currentIndex, ratings = {}.
- Rubric Rubric: Let's define 3-4 categories:
Helpfulness, Accuracy, Clarity, Safety.
- Canvas: Responsive.
-
Adding "Wow" Factors:
- Noise Texture: A CSS
::before with a base64 noise image and mix-blend-mode: overlay. Essential for that "premium" feel.
- Glassmorphism:
backdrop-blur-md bg-white/10 border border-white/20.
- Magnetic Button: Logic: calculate distance from button center to mouse, translate button slightly.
- Rubric Sliders: These need to be custom. Standard HTML range input is ugly. I'll style the track and thumb heavily using Tailwind
appearance-none. I'll use GSAP to animate the fill width based on value.
-
Addressing "Active Learning":
- "Active Learning" in annotation tools usually means "show the annotator examples where the model is most uncertain to maximize label information."
- I will add a card that shows "Model Confidence: 32%" and visualizes it as a liquid fill or a progress bar. I'll also add a toggle "Flag for Hard Example".
-
Writing the actual code (Iterative refinement):
-
Final Polish:
- Ensure the background 3D scene is smooth.
- Fix the noise overlay positioning (
fixed inset-0 pointer-events-none).
- Make sure the "Active Learning" part looks distinct—maybe a small circular gauge using SVG
stroke-dashoffset.
- Verify mobile responsiveness: Stack columns.
-
Self-Correction/Review against Prompt:
- Swiss/International Style? Yes, clear hierarchy, sans-serif, grid-based.
- Negative space? Using
gap-8 and padding.
- Curiosity/GSAP? Yes, transitions and magnetic button.
- Active Learning? Added confidence score visualization.
- Single file? Yes.
- No native alerts? Using a custom toast notification.
- Functional? Yes, can rate, submit, move to next.
-
Generating the Code: (Proceeding to write the actual HTML/CSS/JS with the thought-out structure). I will ensure the code includes comments explaining the logic. I will use a simple particle system for the 3D background to keep file size manageable but effective. I'll implement a "Confetti" or "Success" animation upon submission using GSAP for reward feedback.
- Rubric Implementation: Instead of just 1-5, let's make it a "Quality Scale" where moving the slider fills a bar.
- Micro-interaction: When the user types in notes, the "Submit" button lights up.
- Active Learning: I'll add a "Model Certainty" widget that pulsates subtly if confidence is low.
-
Final Code Assembly: (Merging into the provided output). Ensure all CDNs are correct. Tailwind script CDN. GSAP CDN. Three.js CDN.
(Self-Correction during coding): I initially thought of 3D models, but for a UI, a subtle 3D particle flow is better than heavy geometry. I'll create a "Warp Speed" or "Floating Dust" effect that reacts to mouse movement slightly to satisfy the "interactive 3D" requirement without obstructing the UI. I'll also add a grain overlay for texture.
Let's write the code.
Here is a complete, single-file HTML solution. It implements a premium Human-in-the-Loop (HITL) annotation interface that combines Swiss Design typography, a Three.js background, micro-interactions via GSAP, and a functional annotation pipeline including rubric ratings and "Active Learning" signals (confidence scores).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LLM Annotation Interface | Active Learning Dashboard</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
brand: {
dark: '#050505',
card: '#121214',
accent: '#3b82f6', // Cyber Blue
glow: 'rgba(59, 130, 246, 0.15)'
}
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif']
},
backgroundImage: {
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
}
}
}
}
</script>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:wght@700&display=swap" rel="stylesheet">
<!-- 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>
<!-- Lucide Icons -->
<script src="https://unpkg.com/lucide@latest"></script>
<style>
body {
background-color: #050505;
color: #e5e5e5;
overflow-x: hidden;
font-family: 'Inter', sans-serif;
}
/* Noise Texture Overlay */
.noise-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 0;
opacity: 0.05;
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 Range Slider Styling */
input[type=range] {
-webkit-appearance: none;
background: transparent;
width: 100%;
cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
height: 6px;
background: #333;
border-radius: 999px;
width: 100%;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
height: 24px;
width: 24px;
border-radius: 50%;
background: #fff;
margin-top: -9px;
box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
transition: transform 0.1s, box-shadow 0.2s;
}
input[type=range]:hover::-webkit-slider-thumb {
transform: scale(1.2);
box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
}
input[type=range]:active::-webkit-slider-thumb {
background: #3b82f6;
}
/* Progress bar fill */
.range-fill {
position: absolute;
top: 50%;
left: 0;
height: 6px;
background: linear-gradient(90deg, #3b82f6, #8b5cf6);
border-radius: 999px;
transform: translateY(-50%);
pointer-events: none;
width: 0%; /* JS will update */
}
/* Glassmorphism Card */
.glass-card {
background: rgba(18, 18, 20, 0.6);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}
/* Scrollbar */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: #000;
}
::-webkit-scrollbar-thumb {
background: #333;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Magnetic Button positioning container */
.magnetic-wrap {
position: relative;
}
.magnetic-btn {
transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Animated Gradient Text */
.gradient-text {
background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
/* Active Learning Pulse */
.pulse-ring {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
border-radius: 999px;
border: 2px solid currentColor;
opacity: 0;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); opacity: 0.8; }
100% { transform: scale(1.6); opacity: 0; }
}
</style>
</head>
<body class="antialiased min-h-screen relative">
<!-- Background Noise -->
<div class="noise-overlay"></div>
<!-- Three.js Canvas Container -->
<div id="canvas-container" class="fixed inset-0 z-0 pointer-events-none"></div>
<!-- UI Container -->
<div class="relative z-10 w-full min-h-screen flex flex-col p-6 md:p-10 max-w-[1920px] mx-auto">
<!-- Header -->
<header class="flex justify-between items-center mb-10 opacity-0" id="header">
<div class="flex flex-col">
<span class="text-xs uppercase tracking-[0.2em] text-gray-500 font-semibold mb-1">Annotation System</span>
<h1 class="text-3xl md:text-4xl font-serif text-white">Vetting <span class="text-brand-accent">V2.4</span></h1>
</div>
<div class="flex items-center gap-6">
<div class="hidden md:flex flex-col items-end">
<span class="text-xs text-gray-400">Batch Remaining</span>
<span class="text-2xl font-light text-white" id="batch-count">14</span>
</div>
<div class="h-10 w-10 rounded-full glass-card flex items-center justify-center cursor-pointer hover:bg-white/10 transition">
<i data-lucide="settings" class="w-5 h-5 text-gray-300"></i>
</div>
<div class="h-10 w-10 rounded-full bg-gradient-to-tr from-blue-500 to-purple-600 flex items-center justify-center shadow-lg shadow-brand-accent/40 cursor-pointer">
<i data-lucide="user" class="w-5 h-5 text-white"></i>
</div>
</div>
</header>
<!-- Main Content Grid -->
<main class="grid grid-cols-1 lg:grid-cols-12 gap-8 flex-1 mb-20">
<!-- Left Column: Content (Target) -->
<section class="lg:col-span-7 flex flex-col gap-6">
<!-- Conversation Container -->
<div class="flex-1 flex flex-col gap-6 relative">
<!-- User Prompt -->
<div class="glass-card p-6 rounded-2xl rounded-tl-none relative group">
<div class="absolute top-4 right-4 opacity-20 group-hover:opacity-100 transition-opacity">
<i data-lucide="user-circle" class="w-6 h-6 text-brand-accent"></i>
</div>
<span class="text-xs font-bold text-brand-accent uppercase tracking-widest mb-3 block">User Prompt</span>
<div id="prompt-text" class="text-gray-200 text-lg leading-relaxed font-light">
<!-- Dynamic Content -->
</div>
</div>
<!-- LLM Response -->
<div class="glass-card p-6 rounded-2xl rounded-tr-none relative border-brand-accent/20 flex-1">
<div class="absolute top-4 right-4 opacity-20 group-hover:opacity-100 transition-opacity">
<i data-lucide="bot" class="w-6 h-6 text-purple-400"></i>
</div>
<span class="text-xs font-bold text-purple-400 uppercase tracking-widest mb-3 block">Model Output</span>
<div id="response-text" class="text-gray-200 text-lg leading-relaxed font-light">
<!-- Dynamic Content -->
</div>
</div>
</div>
</section>
<!-- Right Column: Annotation Dashboard -->
<aside class="lg:col-span-5 flex flex-col gap-6 h-full">
<!-- Active Learning Widget -->
<div class="glass-card p-5 rounded-2xl bg-gradient-to-br from-[#121214] to-[#1e1e24] border-l-4 border-yellow-500 relative overflow-hidden">
<div class="absolute top-0 right-0 p-3 opacity-10">
<i data-lucide="activity" class="w-16 h-16 text-white"></i>
</div>
<h3 class="text-sm font-bold text-gray-300 uppercase mb-4 flex items-center gap-2">
<i data-lucide="brain-circuit" class="w-4 h-4 text-yellow-500"></i>
Model Uncertainty
</h3>
<div class="flex items-center gap-6">
<!-- Gauge Visualization -->
<div class="relative h-20 w-20 flex items-center justify-center">
<svg class="w-full h-full transform -rotate-90" viewBox="0 0 36 36">
<path class="text-gray-800" d="M18 2.1 a 15.9 15.9 0 0 1 0 31.8" fill="none" stroke="currentColor" stroke-width="3" />
<path id="certainty-arc" stroke="url(#gradient)" stroke="currentColor" stroke-width="3" stroke-dasharray="0, 100" fill="none" d="M18 2.1 a 15.9 15.9 0 0 1 0 31.8" />
<defs>
<linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="#f59e0b" />
<stop offset="100%" stop-color="#ef4444" />
</linearGradient>
</defs>
</svg>
<span class="absolute text-sm font-bold" id="certainty-text">32%</span>
</div>
<div class="flex-1">
<p class="text-sm text-gray-400 leading-relaxed">
This response has <span class="text-yellow-500 font-semibold" id="certainty-label">low confidence</span>. The model is uncertain about factual accuracy.
</p>
</div>
</div>
<div class="mt-4 h-1 bg-gray-800 rounded-full overflow-hidden">
<div id="certainty-bar" class="h-full bg-gradient-to-r from-yellow-500 to-red-500 w-0 transition-all duration-1000 ease-out"></div>
</div>
</div>
<!-- Rubrics -->
<div class="glass-card p-6 rounded-2xl flex-1 flex flex-col">
<h3 class="text-sm font-bold text-gray-300 uppercase mb-6 border-b border-gray-800 pb-3">
Quality Rubric
</h3>
<div class="flex-1 space-y-8">
<!-- Rubric 1: Helpfulness -->
<div class="relative group">
<div class="flex justify-between mb-2">
<label class="text-sm font-medium text-gray-400 group-hover:text-white transition-colors">Helpfulness</label>
<span class="text-sm font-bold text-brand-accent" id="val-helpfulness">3</span>
</div>
<div class="relative w-full h-6 flex items-center">
<div class="range-fill" id="fill-helpfulness"></div>
<input type="range" min="1" max="5" step="1" value="3" class="w-full"
oninput="updateSlider(this, 'helpfulness')">
</div>
<div class="flex justify-between text-[10px] text-gray-600 mt-1">
<span>Poor</span>
<span>Excellent</span>
</div>
</div>
<!-- Rubric 2: Accuracy -->
<div class="relative group">
<div class="flex justify-between mb-2">
<label class="text-sm font-medium text-gray-400 group-hover:text-white transition-colors">Accuracy</label>
<span class="text-sm font-bold text-brand-accent" id="val-accuracy">4</span>
</div>
<div class="relative w-full h-6 flex items-center">
<div class="range-fill" id="fill-accuracy"></div>
<input type="range" min="1" max="5" step="1" value="4" class="w-full"
oninput="updateSlider(this, 'accuracy')">
</div>
</div>
<!-- Rubric 3: Clarity -->
<div class="relative group">
<div class="flex justify-between mb-2">
<label class="text-sm font-medium text-gray-400 group-hover:text-white transition-colors">Clarity</label>
<span class="text-sm font-bold text-brand-accent" id="val-clarity">5</span>
</div>
<div class="relative w-full h-6 flex items-center">
<div class="range-fill" id="fill-clarity"></div>
<input type="range" min="1" max="5" step="1" value="5" class="w-full"
oninput="updateSlider(this, 'clarity')">
</div>
</div>
<!-- Checkbox flags -->
<div class="flex gap-4 mt-4">
<label class="flex items-center space-x-2 cursor-pointer group">
<input type="checkbox" class="w-4 h-4 rounded border-gray-600 text-brand-accent focus:ring-brand-accent bg-gray-700/50 accent-brand-accent">
<span class="text-xs text-gray-400 group-hover:text-white transition-colors">Flag Toxicity</span>
</label>
<label class="flex items-center space-x-2 cursor-pointer group">
<input type="checkbox" class="w-4 h-4 rounded border-gray-600 text-purple-400 focus:ring-purple-400 bg-gray-700/50 accent-purple-400">
<span class="text-xs text-gray-400 group-hover:text-white transition-colors">Hallucination</span>
</label>
</div>
</div>
</div>
<!-- Notes Section -->
<div class="glass-card p-0 rounded-2xl overflow-hidden flex flex-col relative">
<div class="p-4 border-b border-gray-800 bg-white/5 flex justify-between items-center">
<span class="text-xs font-bold text-gray-400 uppercase">Notes (Optional)</span>
<span class="text-[10px] text-brand-accent animate-pulse" id="char-count">0</span>
</div>
<textarea id="notes-area" rows="4" class="w-full bg-transparent p-4 text-sm text-gray-200 focus:ring-0 resize-none placeholder-gray-600 focus:bg-white/5 transition-colors" placeholder="Describe reasoning for score adjustments..."></textarea>
</div>
<!-- Action Buttons -->
<div class="grid grid-cols-2 gap-4">
<button type="button" id="btn-skip" class="magnetic-wrap flex justify-center items-center py-4 bg-gray-900 border border-gray-700 rounded-xl text-gray-400 font-medium hover:text-white hover:border-gray-500 transition-all">
<span class="magnetic-content">Skip</span>
</button>
<button type="button" id="btn-submit" class="magnetic-wrap flex justify-center items-center py-4 bg-gradient-to-r from-blue-600 to-purple-600 rounded-xl text-white font-bold shadow-lg shadow-brand-accent/30 hover:shadow-brand-accent/50 hover:scale-[1.02] active:scale-[0.98] transition-all relative overflow-hidden">
<span class="magnetic-content flex items-center gap-2">
Next Task <i data-lucide="arrow-right" class="w-4 h-4"></i>
</span>
</button>
</div>
</aside>
</main>
<!-- Footer / Progress -->
<footer class="mt-auto pt-6 border-t border-gray-800 text-xs text-gray-600 flex justify-between items-center z-10 relative">
<div class="flex items-center gap-2">
<i data-lucide="database" class="w-3 h-3"></i>
<span>Dataset: <span class="text-gray-400">LLM-Human-Feedback-2024</span></span>
</div>
<div class="flex items-center gap-4">
<span>Synchronized</span>
<div class="w-2 h-2 rounded-full bg-green-500 shadow-[0_0_8px_rgba(34,197,94,0.6)] animate-pulse"></div>
</div>
</footer>
</div>
<!-- Toast Notification -->
<div id="toast" class="fixed bottom-10 left-1/2 transform -translate-x-1/2 bg-white text-black px-6 py-3 rounded-full shadow-2xl translate-y-20 opacity-0 z-50 flex items-center gap-3 transition-all duration-500">
<i data-lucide="check-circle" class="text-green-600 w-5 h-5"></i>
<span class="text-sm font-medium">Annotation saved successfully</span>
</div>
<script>
// --- 1. Initialization & Dependencies ---
document.addEventListener('DOMContentLoaded', () => {
lucide.createIcons();
});
// --- 2. Mock Data ---
const tasks = [
{
prompt: "Explain the concept of quantum entanglement in simple terms.",
response: "Entanglement is like having two coins that always land on the same side, even if flipped on opposite sides of the galaxy. When you look at one, you instantly know the state of the other. This 'spooky action at a distance' is how quantum particles behave when linked together.",
confidence: 0.22,
certaintyLabel: "Low Confidence",
meta: { reason: "Analogy might be oversimplified." }
},
{
prompt: "Write a Python function to calculate the factorial of a number.",
response: "def factorial(n):\n return 1 if n <= 1 else n * factorial(n-1)",
confidence: 0.95,
certaintyLabel: "High Confidence",
meta: { reason: "Standard recursion, correct." }
},
{
prompt: "What are the main causes of the French Revolution?",
response: "The French Revolution was primarily caused by financial crisis, social inequality between the Estates, Enlightenment ideals challenging royal authority, and widespread famine which fueled popular unrest.",
confidence: 0.68,
certaintyLabel: "Medium Confidence",
meta: { reason: "Concise but might need more economic detail." }
},
{
prompt: "Give me a recipe for banana bread.",
response: "Ingredients: 3 ripe bananas, 1/3 cup butter, 3/4 cup sugar, egg, tsp vanilla, 1 cup flour, tsp baking soda. Mash bananas, mix with butter and sugar. Add egg and vanilla. Sift flour and baking soda, fold in. Bake at 350F for 50 mins.",
confidence: 0.85,
certaintyLabel: "High Confidence",
meta: { reason: "Standard recipe." }
}
];
let currentIdx = 0;
let batchRemaining = tasks.length;
// --- 3. State Management ---
const state = {
helpfulness: 3,
accuracy: 4,
clarity: 5,
notes: "",
flags: {
toxicity: false,
hallucination: false
}
};
// --- 4. DOM Elements ---
const els = {
prompt: document.getElementById('prompt-text'),
response: document.getElementById('response-text'),
batchCount: document.getElementById('batch-count'),
header: document.getElementById('header'),
certaintyText: document.getElementById('certainty-text'),
certaintyLabel: document.getElementById('certainty-label'),
certaintyBar: document.getElementById('certainty-bar'),
notes: document.getElementById('notes-area'),
charCount: document.getElementById('char-count'),
btnSubmit: document.getElementById('btn-submit'),
btnSkip: document.getElementById('btn-skip')
};
// --- 5. Render Functions ---
function renderTask() {
const task = tasks[currentIdx];
// Animate out old content
const tl = gsap.timeline();
tl.to([els.prompt, els.response], { opacity: 0, y: 20, duration: 0.3, onComplete: () => {
els.prompt.textContent = task.prompt;
els.response.textContent = task.response;
// Update AL Widget
const pct = Math.round(task.confidence * 100);
els.certaintyBar.style.width = '0%';
els.certaintyText.textContent = pct + '%';
els.certaintyLabel.textContent = task.certaintyLabel;
// Color AL bar based on confidence
if (task.confidence < 0.4) {
els.certaintyBar.className = "h-full bg-gradient-to-r from-yellow-500 to-red-500";
document.querySelector('#certainty-arc').style.stroke = "#f59e0b";
} else if (task.confidence < 0.7) {
els.certaintyBar.className = "h-full bg-gradient-to-r from-yellow-500 to-green-500";
document.querySelector('#certainty-arc').style.stroke = "#eab308";
} else {
els.certaintyBar.className = "h-full bg-gradient-to-r from-green-400 to-emerald-500";
document.querySelector('#certainty-arc').style.stroke = "#4ade80";
}
// Reset form
resetForm();
updateSlider(document.getElementById('helpfulness'), 'helpfulness');
updateSlider(document.getElementById('accuracy'), 'accuracy');
updateSlider(document.getElementById('clarity'), 'clarity');
// Animate in new content
tl.to([els.prompt, els.response], { opacity: 1, y: 0, duration: 0.4, stagger: 0.1 });
}});
// Animate AL bar after content appearance
setTimeout(() => {
gsap.to(els.certaintyBar, { width: (task.confidence * 100) + '%', duration: 1, ease: "power2.out" });
}, 400);
}
function resetForm() {
state.helpfulness = 3;
state.accuracy = 4;
state.clarity = 5;
state.notes = "";
document.getElementById('notes-area').value = "";
els.charCount.textContent = "0";
}
function updateSlider(input, metric) {
const val = input.value;
state[metric] = val;
document.getElementById(`val-${metric}`).textContent = val;
const fill = document.getElementById(`fill-${metric}`);
// calculate percentage
const percent = ((val - input.min) / (input.max - input.min)) * 100;
fill.style.width = percent + '%';
}
function updateCharCount() {
const len = els.notes.value.length;
els.charCount.textContent = len;
state.notes = els.notes.value;
}
// --- 6. Active Learning Logic ---
function showToast() {
const toast = document.getElementById('toast');
toast.classList.remove('translate-y-20', 'opacity-0');
setTimeout(() => {
toast.classList.add('translate-y-20', 'opacity-0');
}, 2000);
}
function handleSubmit() {
// Collect data
const submission = {
taskId: currentIdx,
ratings: { ...state },
timestamp: new Date().toISOString()
};
console.log("Submission:", submission);
// Success feedback
showToast();
// Update counters
currentIdx++;
batchRemaining--;
els.batchCount.textContent = batchRemaining;
// Move to next
if (currentIdx < tasks.length) {
setTimeout(() => renderTask(), 800);
} else {
// Completion State
gsap.to('main', { opacity: 0, y: -50, duration: 0.5, onComplete: () => {
document.body.innerHTML = `
<div class="h-screen w-full flex flex-col items-center justify-center bg-black text-white relative z-50">
<h1 class="text-6xl font-serif mb-4 text-gray-800">ALL DONE</h1>
<p class="text-gray-400">Batch completed. Data has been queued for export.</p>
</div>`;
}});
}
}
// --- 7. Magnetic Button Interaction ---
function initMagneticButtons() {
const buttons = document.querySelectorAll('.magnetic-wrap');
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;
// Move content slightly
gsap.to(btn.querySelector('.magnetic-content'), {
x: x * 0.3,
y: y * 0.3,
duration: 0.2,
ease: 'power2.out'
});
});
btn.addEventListener('mouseleave', () => {
gsap.to(btn.querySelector('.magnetic-content'), {
x: 0,
y: 0,
duration: 0.5,
ease: 'elastic.out(1, 0.3)'
});
});
});
}
// --- 8. Three.js Background Animation (Particle Dust) ---
function initBackground() {
const container = document.getElementById('canvas-container');
const scene = new THREE.Scene();
// Fog for depth
scene.fog = new THREE.FogExp2(0x050505, 0.002);
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 50;
const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
container.appendChild(renderer.domElement);
// Particles
const particlesGeometry = new THREE.BufferGeometry();
const particlesCount = 1200;
const posArray = new Float32Array(particlesCount * 3);
for (let i = 0; i < particlesCount * 3; i++) {
posArray[i] = (Math.random() - 0.5) * 150; // Spread
}
particlesGeometry.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
const material = new THREE.PointsMaterial({
size: 0.4,
color: 0x3b82f6, // Blue accent
transparent: true,
opacity: 0.8,
blending: THREE.AdditiveBlending
});
const particlesMesh = new THREE.Points(particlesGeometry, material);
scene.add(particlesMesh);
// Mouse interaction tracking
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);
});
// Resize handling
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
// Animation Loop
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.y += (targetX - particlesMesh.rotation.y) * 0.05;
// Gentle wave motion for individual particles would be expensive,
// instead we'll rotate the whole cloud slowly.
renderer.render(scene, camera);
};
animate();
}
// --- 9. Bootstrap ---
function init() {
initBackground();
initMagneticButtons();
// Initial render
renderTask();
// Event Listeners
els.notes.addEventListener('input', updateCharCount);
els.btnSubmit.addEventListener('click', handleSubmit);
els.btnSkip.addEventListener('click', () => {
// Skipping just acts like submit without saving data (or saves skip flag)
handleSubmit();
});
}
// Start
init();
</script>
</body>
</html>