Download script.js from Handtful/pattern-factory-studio-ady9j: direct link, hf CLI and curl.
- Browser
- Download file 7.22 kB
-
https://huggingface.co/spaces/Handtful/pattern-factory-studio-ady9j/resolve/main/script.js
- Command line
-
hf download hf://spaces/Handtful/pattern-factory-studio-ady9j/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Handtful/pattern-factory-studio-ady9j/resolve/main/script.js
7.22 kB
| // Sample pattern data | |
| const samplePattern = `PATTERN: Nordic Cable Knit Sweater | |
| TYPE: Adult Pullover | |
| DIFFICULTY: Intermediate | |
| SIZE: M (L, XL, 2XL) | |
| MATERIALS: | |
| - Yarn: Worsted weight wool, 1200(1400,1600,1800) yards | |
| - Needles: US 8 (5mm) circular 24", US 6 (4mm) for ribbing | |
| - Stitch markers, cable needle, tapestry needle | |
| GAUGE: 18 sts x 24 rows = 4" in stockinette | |
| PATTERN NOTES: | |
| - Cable panel worked over 12 stitches | |
| - Body worked in round to armholes | |
| - Raglan sleeve construction | |
| - Classic fit with 2" positive ease | |
| ABBREVIATIONS: | |
| CO: Cast on, BO: Bind off, C6F: Cable 6 front, C6B: Cable 6 back`; | |
| // Generation tasks | |
| const tasks = [ | |
| { name: "Parsing pattern structure...", time: 800 }, | |
| { name: "Generating core JSON schema...", time: 1200 }, | |
| { name: "Creating visual diagrams (AI image gen)...", time: 3000 }, | |
| { name: "Generating accessibility layers...", time: 1500 }, | |
| { name: "Building course curricula (LLM)...", time: 2500 }, | |
| { name: "Synthesizing audio (TTS)...", time: 4000 }, | |
| { name: "Rendering 3D assets...", time: 3500 }, | |
| { name: "Creating marketing copy...", time: 1000 }, | |
| { name: "Translating to 5 languages...", time: 3000 }, | |
| { name: "Packaging deliverables...", time: 800 } | |
| ]; | |
| let currentTask = 0; | |
| let isGenerating = false; | |
| // Initialize Lucide icons | |
| document.addEventListener('DOMContentLoaded', () => { | |
| lucide.createIcons(); | |
| }); | |
| function loadSample() { | |
| document.getElementById('pattern-input').value = samplePattern; | |
| document.getElementById('source-id').textContent = 'PATTERN-' + Math.random().toString(36).substr(2, 6).toUpperCase(); | |
| } | |
| function generateAll() { | |
| const input = document.getElementById('pattern-input').value.trim(); | |
| if (!input) { | |
| alert('Please enter a pattern or load a sample first.'); | |
| return; | |
| } | |
| if (isGenerating) return; | |
| isGenerating = true; | |
| currentTask = 0; | |
| // UI Updates | |
| const grid = document.getElementById('deliverables-grid'); | |
| const progress = document.getElementById('generation-progress'); | |
| const progressBar = document.getElementById('progress-bar'); | |
| const progressText = document.getElementById('progress-text'); | |
| const currentTaskEl = document.getElementById('current-task'); | |
| grid.classList.remove('opacity-50', 'pointer-events-none'); | |
| progress.classList.remove('hidden'); | |
| // Disable all check icons initially | |
| document.querySelectorAll('.check-icon').forEach(icon => { | |
| icon.classList.remove('text-green-400'); | |
| icon.classList.add('text-slate-600'); | |
| }); | |
| // Update stat badges | |
| document.querySelectorAll('.status-badge').forEach(badge => { | |
| badge.textContent = 'Generating...'; | |
| badge.classList.add('text-indigo-400'); | |
| }); | |
| document.getElementById('total-status').textContent = 'Processing'; | |
| document.getElementById('total-status').className = 'text-xs bg-indigo-500 text-white px-2 py-1 rounded-full mono animate-pulse'; | |
| // Process tasks | |
| let totalProgress = 0; | |
| const totalDuration = tasks.reduce((acc, t) => acc + t.time, 0); | |
| let elapsed = 0; | |
| function processNextTask() { | |
| if (currentTask >= tasks.length) { | |
| // Generate complete | |
| isGenerating = false; | |
| progress.classList.add('hidden'); | |
| markComplete(); | |
| document.getElementById('download-all-btn').disabled = false; | |
| document.getElementById('deliverable-count').textContent = '39/39 Generated'; | |
| document.getElementById('total-status').textContent = 'Complete'; | |
| document.getElementById('total-status').className = 'text-xs bg-green-500 text-white px-2 py-1 rounded-full mono'; | |
| // Trigger confetti effect (simulated) | |
| showCompletionEffect(); | |
| return; | |
| } | |
| const task = tasks[currentTask]; | |
| currentTaskEl.textContent = task.name; | |
| const taskStart = Date.now(); | |
| const taskInterval = setInterval(() => { | |
| const now = Date.now(); | |
| const taskProgress = Math.min((now - taskStart) / task.time, 1); | |
| const taskWeightedProgress = (taskProgress * task.time) / totalDuration * 100; | |
| const totalProgress = (elapsed / totalDuration * 100) + taskWeightedProgress; | |
| progressBar.style.width = Math.min(totalProgress, 100) + '%'; | |
| progressText.textContent = Math.floor(Math.min(totalProgress, 100)) + '%'; | |
| if (taskProgress >= 1) { | |
| clearInterval(taskInterval); | |
| elapsed += task.time; | |
| currentTask++; | |
| processNextTask(); | |
| } | |
| }, 50); | |
| } | |
| processNextTask(); | |
| // Staggered card animations | |
| const cards = document.querySelectorAll('.category-card'); | |
| cards.forEach((card, index) => { | |
| setTimeout(() => { | |
| card.classList.add('border-indigo-500/50'); | |
| setTimeout(() => { | |
| card.classList.remove('border-indigo-500/50'); | |
| }, 500); | |
| }, index * 800); | |
| }); | |
| } | |
| function markComplete() { | |
| // Mark all items complete | |
| document.querySelectorAll('.check-icon').forEach((icon, index) => { | |
| setTimeout(() => { | |
| icon.classList.remove('text-slate-600'); | |
| icon.classList.add('text-green-400'); | |
| }, index * 50); | |
| }); | |
| document.querySelectorAll('.status-badge').forEach(badge => { | |
| badge.textContent = 'Ready'; | |
| badge.classList.remove('text-indigo-400'); | |
| badge.classList.add('text-green-400'); | |
| }); | |
| } | |
| function downloadAll() { | |
| // Create a simulated download | |
| const blob = new Blob(['Pattern Suite Complete Package'], { type: 'application/zip' }); | |
| const url = URL.createObjectURL(blob); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = 'pattern-suite-39-deliverables.zip'; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); | |
| URL.revokeObjectURL(url); | |
| // Show success message | |
| const btn = document.getElementById('download-all-btn'); | |
| const originalText = btn.innerHTML; | |
| btn.innerHTML = '<i data-lucide="check" class="w-4 h-4"></i> Downloaded!'; | |
| btn.classList.add('bg-green-600'); | |
| lucide.createIcons(); | |
| setTimeout(() => { | |
| btn.innerHTML = originalText; | |
| btn.classList.remove('bg-green-600'); | |
| lucide.createIcons(); | |
| }, 2000); | |
| } | |
| function showCompletionEffect() { | |
| // Simple pulse animation on complete | |
| document.querySelectorAll('.category-card').forEach((card, i) => { | |
| setTimeout(() => { | |
| card.classList.add('animate-pulse-glow'); | |
| setTimeout(() => card.classList.remove('animate-pulse-glow'), 2000); | |
| }, i * 100); | |
| }); | |
| } | |
| // Add hover effects for deliverable items | |
| document.querySelectorAll('.category-card').forEach(card => { | |
| card.addEventListener('click', (e) => { | |
| if (e.target.closest('.flex.items-center.justify-between.text-sm')) { | |
| e.target.closest('.flex.items-center.justify-between.text-sm').classList.toggle('bg-indigo-900/30'); | |
| } | |
| }); | |
| }); |