Spaces:
Sleeping
Sleeping
Download dashboard.html from SimblyPaul/Tron: direct link, hf CLI and curl.
- Browser
- Download file 35.2 kB
-
https://huggingface.co/spaces/SimblyPaul/Tron/resolve/main/dashboard.html
- Command line
-
hf download hf://spaces/SimblyPaul/Tron/dashboard.html
-
curl -L -o dashboard.html https://huggingface.co/spaces/SimblyPaul/Tron/resolve/main/dashboard.html
35.2 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>TRON - Creator Dashboard</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;1,400&family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet"> | |
| <style> | |
| body { | |
| font-family: 'Inter', sans-serif; | |
| background: radial-gradient(circle at top left, #0f172a, #020617); | |
| } | |
| .toi-header { | |
| font-family: 'Playfair Display', serif; | |
| letter-spacing: 0.05em; | |
| } | |
| .toi-body { | |
| font-family: Georgia, serif; | |
| line-height: 1.6; | |
| } | |
| </style> | |
| </head> | |
| <body class="min-h-screen text-slate-100 flex flex-col"> | |
| <!-- Navbar --> | |
| <header class="border-b border-slate-800 bg-slate-900/60 backdrop-blur-md sticky top-0 z-50"> | |
| <div class="max-w-7xl mx-auto px-6 py-4 flex items-center justify-between"> | |
| <div class="flex items-center space-x-3"> | |
| <div class="w-10 h-10 rounded-xl bg-gradient-to-tr from-cyan-500 to-indigo-500 flex items-center justify-center shadow-lg shadow-indigo-500/20"> | |
| <span class="text-xl font-bold text-white tracking-widest toi-header">T</span> | |
| </div> | |
| <div> | |
| <h1 class="text-lg font-bold bg-gradient-to-r from-white to-slate-400 bg-clip-text text-transparent">TRON</h1> | |
| <p class="text-xs text-slate-500 font-medium">Voice-Activated News Creator</p> | |
| </div> | |
| </div> | |
| <div class="flex items-center space-x-3"> | |
| <a href="/admin/analytics" target="_blank" class="text-xs font-semibold px-4 py-2 rounded-xl bg-slate-800 border border-slate-700 text-slate-300 hover:text-white transition-all hover:bg-slate-700"> | |
| 📊 View Analytics | |
| </a> | |
| <div class="text-sm font-semibold px-4 py-1.5 rounded-full bg-slate-800 border border-slate-700 text-slate-300"> | |
| Planning & Creation Mode | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Main Content --> | |
| <main class="flex-1 max-w-7xl w-full mx-auto px-6 py-8 grid grid-cols-1 lg:grid-cols-2 gap-8"> | |
| <!-- LEFT PANEL: Article Builder & Live Preview --> | |
| <section class="flex flex-col space-y-6"> | |
| <div class="bg-slate-900/40 border border-slate-800 rounded-2xl p-6 backdrop-blur-sm space-y-4"> | |
| <h2 class="text-xl font-semibold flex items-center space-x-2"> | |
| <span class="w-2.5 h-2.5 rounded-full bg-cyan-500 animate-pulse"></span> | |
| <span>1. Write Article Content</span> | |
| </h2> | |
| <div class="space-y-4"> | |
| <div> | |
| <label class="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">Headline</label> | |
| <input id="input-headline" type="text" class="w-full bg-slate-950 border border-slate-800 focus:border-cyan-500 focus:ring-1 focus:ring-cyan-500 rounded-xl px-4 py-3 text-slate-100 placeholder-slate-600 outline-none transition-all" placeholder="Enter article headline..." value="TRON AI CHANNELS REAL-TIME NEWS DIRECTLY VIA VOICE PROTOCOL"> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label class="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">Reporter / Author</label> | |
| <input id="input-author" type="text" class="w-full bg-slate-950 border border-slate-800 focus:border-cyan-500 focus:ring-1 focus:ring-cyan-500 rounded-xl px-4 py-3 text-slate-100 placeholder-slate-600 outline-none transition-all" placeholder="Reporter name..." value="Special Correspondent"> | |
| </div> | |
| <div> | |
| <label class="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">Publication Date</label> | |
| <input id="input-date" type="text" class="w-full bg-slate-950 border border-slate-800 focus:border-cyan-500 focus:ring-1 focus:ring-cyan-500 rounded-xl px-4 py-3 text-slate-100 placeholder-slate-600 outline-none transition-all" value="June 25, 2026"> | |
| </div> | |
| </div> | |
| <div> | |
| <label class="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">Article Body Text</label> | |
| <textarea id="input-body" rows="6" class="w-full bg-slate-950 border border-slate-800 focus:border-cyan-500 focus:ring-1 focus:ring-cyan-500 rounded-xl px-4 py-3 text-slate-100 placeholder-slate-600 outline-none transition-all resize-y" placeholder="Start typing the article content...">In an unprecedented milestone for digital media, developers have unveiled TRON, a conversational, voice-activated news assistant designed to ground reader inquiries directly within investigative reports. By bridging real-time WebSocket connections with Google's latest multimodal audio models, the prototype enables readers to hold active, low-latency dialogue with editorial content. | |
| Rather than relying on static pages, the technology converts the text into a structured knowledge base, preventing the assistant from hallucinating facts outside the uploaded context. Users can question layout decisions, dispute specific assertions, or ask the system to automatically generate comprehensive research summaries as Microsoft Word downloads.</textarea> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Times of India Editorial Live Preview --> | |
| <div class="bg-white text-neutral-900 rounded-2xl p-8 border border-slate-200 shadow-2xl flex flex-col justify-between min-h-[450px]"> | |
| <div> | |
| <!-- TOI Masthead --> | |
| <div class="text-center border-b-4 border-double border-neutral-900 pb-3 mb-4"> | |
| <div class="text-xs uppercase tracking-widest font-serif font-bold text-neutral-500 flex justify-between px-1"> | |
| <span>Established 1838</span> | |
| <span>The Times of India</span> | |
| <span>Daily Edition</span> | |
| </div> | |
| <h1 class="text-3xl md:text-4xl font-serif font-black tracking-normal toi-header my-2 text-neutral-950">THE TIMES OF INDIA</h1> | |
| <div class="text-xs border-t border-neutral-900 pt-1 flex justify-between font-serif italic text-neutral-700"> | |
| <span>Reg. No. Delhi-0912</span> | |
| <span id="preview-date-top">June 25, 2026</span> | |
| <span>Price: ₹ 5.00</span> | |
| </div> | |
| </div> | |
| <!-- Article Header --> | |
| <div class="mb-4"> | |
| <h2 id="preview-headline" class="text-xl md:text-2xl font-bold font-serif leading-tight text-neutral-900 tracking-tight">TRON AI CHANNELS REAL-TIME NEWS DIRECTLY VIA VOICE PROTOCOL</h2> | |
| <div class="mt-2 text-xs text-neutral-600 border-b border-neutral-200 pb-2 font-serif flex items-center justify-between"> | |
| <span>By <strong id="preview-author" class="text-neutral-900">Special Correspondent</strong></span> | |
| <span id="preview-date-sub">June 25, 2026</span> | |
| </div> | |
| </div> | |
| <!-- Article Body in Column Layout --> | |
| <div id="preview-body" class="toi-body text-sm text-neutral-800 space-y-3 columns-1 md:columns-2 gap-6 text-justify"> | |
| In an unprecedented milestone for digital media, developers have unveiled TRON, a conversational, voice-activated news assistant designed to ground reader inquiries directly within investigative reports. By bridging real-time WebSocket connections with Google's latest multimodal audio models, the prototype enables readers to hold active, low-latency dialogue with editorial content. | |
| Rather than relying on static pages, the technology converts the text into a structured knowledge base, preventing the assistant from hallucinating facts outside the uploaded context. Users can question layout decisions, dispute specific assertions, or ask the system to automatically generate comprehensive research summaries as Microsoft Word downloads. | |
| </div> | |
| </div> | |
| <!-- Preview CTA Button --> | |
| <div class="mt-8 border-t border-neutral-200 pt-4 flex justify-end"> | |
| <button class="px-5 py-2.5 rounded-lg bg-neutral-900 hover:bg-neutral-800 text-white font-medium text-sm flex items-center space-x-2 transition-all shadow-md active:scale-95 cursor-not-allowed opacity-90" disabled> | |
| <svg class="w-4 h-4 text-cyan-400 animate-pulse" fill="currentColor" viewBox="0 0 24 24"><path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/><path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/></svg> | |
| <span>Talk to Tron</span> | |
| </button> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- RIGHT PANEL: Tron Settings & RAG Context --> | |
| <section class="flex flex-col space-y-6"> | |
| <div class="bg-slate-900/40 border border-slate-800 rounded-2xl p-6 backdrop-blur-sm space-y-6 flex-1 flex flex-col justify-between"> | |
| <div class="space-y-6"> | |
| <h2 class="text-xl font-semibold flex items-center space-x-2"> | |
| <span class="w-2.5 h-2.5 rounded-full bg-indigo-500 animate-pulse"></span> | |
| <span>2. Customize Tron Settings & RAG</span> | |
| </h2> | |
| <!-- Persona Prompt --> | |
| <div> | |
| <label class="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">System Persona Prompt</label> | |
| <textarea id="input-persona" rows="4" class="w-full bg-slate-950 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl px-4 py-3 text-slate-100 placeholder-slate-600 outline-none transition-all resize-y text-sm">You are Tron, a 25-year-old male reporter/assistant from Delhi, India. You speak fluent, natural conversational English with a professional yet friendly Delhi cadence and human rhythm.</textarea> | |
| </div> | |
| <!-- Strict Grounding Toggle & Custom Instructions --> | |
| <div class="bg-slate-950 p-4 border border-slate-800 rounded-xl space-y-3"> | |
| <div class="flex items-start space-x-3"> | |
| <input id="input-grounding" type="checkbox" checked class="mt-1 w-4 h-4 text-indigo-600 border-slate-800 bg-slate-900 rounded focus:ring-indigo-500 focus:ring-offset-slate-950"> | |
| <div class="flex-1"> | |
| <label for="input-grounding" class="text-sm font-semibold text-slate-200">Enforce Strict Context Bounding (RAG)</label> | |
| <p class="text-xs text-slate-500 mt-0.5 mb-2">If checked, the custom rules below will be appended to Tron's System Persona Prompt.</p> | |
| <textarea id="input-grounding-instructions" rows="4" class="w-full bg-slate-900 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-lg px-3 py-2 text-slate-100 placeholder-slate-600 outline-none transition-all text-xs resize-y">1. You must NEVER answer questions or ground your statements using any knowledge outside of the uploaded source files/documents provided in this session. | |
| 2. If the answer to the reader's question is not directly mentioned in the uploaded documents, you must politely respond: 'I am sorry, but that information is not available in the investigative report or the uploaded research documents.' | |
| 3. You must follow all principles of Non-violent Communication (NVC). Always be empathetic, observation-based, feelings-aware, and request-oriented. | |
| 4. You must ask the user if they want you to read the article aloud.</textarea> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Voice Dropdown, VAD & Salutary Greeting --> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-4"> | |
| <div> | |
| <label class="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">Active Voice Profile</label> | |
| <select id="input-voice" class="w-full bg-slate-950 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl px-4 py-3 text-slate-100 outline-none transition-all text-sm"> | |
| <option value="Puck">Puck (Male - Soft & Friendly)</option> | |
| <option value="Fenrir" selected>Fenrir (Male - Rich & Crisp)</option> | |
| <option value="Aoede">Aoede (Female - Calm & Clear)</option> | |
| <option value="Charon">Charon (Female - Warm & Professional)</option> | |
| </select> | |
| </div> | |
| <div> | |
| <label class="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">VAD Silence Threshold</label> | |
| <select id="input-vad-silence" class="w-full bg-slate-950 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl px-4 py-3 text-slate-100 outline-none transition-all text-sm"> | |
| <option value="400">400ms (Rapid response)</option> | |
| <option value="800">800ms (Balanced conversational)</option> | |
| <option value="1200" selected>1200ms (Standard / Deliberate)</option> | |
| <option value="2000">2000ms (Relaxed / Long pauses)</option> | |
| </select> | |
| </div> | |
| <div> | |
| <label class="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">Salutary Greeting Message</label> | |
| <input id="input-greeting" type="text" class="w-full bg-slate-950 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl px-4 py-3 text-slate-100 placeholder-slate-600 outline-none transition-all text-sm" value="Hello! I am Tron, your news assistant. I have analyzed the research document. Would you like me to read the article to you, or answer any specific questions?"> | |
| </div> | |
| </div> | |
| <!-- Custom Backend URL (Optional) --> | |
| <div> | |
| <label class="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">Custom Backend Host URL (Optional)</label> | |
| <input id="input-backend-url" type="text" class="w-full bg-slate-950 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl px-4 py-3 text-slate-100 placeholder-slate-600 outline-none transition-all text-sm" placeholder="e.g. wss://your-tunnel.ngrok-free.app (leave blank for local address http://localhost:49999)"> | |
| <span class="text-[10px] text-slate-500 mt-1 block">Specify this if you want to run Tron over a public tunnel (like ngrok) or host it on Render/HF, so your shared files can connect back to your server over the internet.</span> | |
| </div> | |
| <!-- File Upload Zone --> | |
| <div> | |
| <label class="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">Knowledge Base Documents (RAG)</label> | |
| <div id="drop-zone" class="border-2 border-dashed border-slate-800 hover:border-indigo-500 bg-slate-950/50 rounded-xl p-6 text-center cursor-pointer transition-all flex flex-col items-center justify-center group"> | |
| <input type="file" id="file-input" multiple accept=".pdf,.docx" class="hidden"> | |
| <svg class="w-8 h-8 text-slate-500 group-hover:text-indigo-400 mb-2 transition-all" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"/></svg> | |
| <span class="text-sm font-semibold text-slate-300">Drag & Drop PDF or Word files</span> | |
| <span class="text-xs text-slate-600 mt-1">Accepts .pdf and .docx documents</span> | |
| </div> | |
| <!-- File list --> | |
| <div id="file-list" class="mt-3 space-y-2"></div> | |
| </div> | |
| </div> | |
| <!-- Construct Button --> | |
| <div class="mt-8 border-t border-slate-800 pt-6"> | |
| <button id="btn-construct" class="w-full bg-gradient-to-r from-cyan-500 to-indigo-600 hover:from-cyan-600 hover:to-indigo-700 text-white font-semibold py-3.5 px-6 rounded-xl transition-all shadow-lg shadow-indigo-500/10 flex items-center justify-center space-x-2 active:scale-[0.98]"> | |
| <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg> | |
| <span>Construct Tron Asset</span> | |
| </button> | |
| <div id="status-message" class="text-center text-xs mt-3 hidden"></div> | |
| </div> | |
| </div> | |
| </section> | |
| </main> | |
| <!-- Footer --> | |
| <footer class="border-t border-slate-800 py-6 text-center text-xs text-slate-500 bg-slate-950/40"> | |
| <p>© 2026 TRON News Assistant Prototype. Powered by Gemini Multimodal Live API.</p> | |
| </footer> | |
| <!-- Frontend logic --> | |
| <script> | |
| const inputHeadline = document.getElementById('input-headline'); | |
| const inputAuthor = document.getElementById('input-author'); | |
| const inputDate = document.getElementById('input-date'); | |
| const inputBody = document.getElementById('input-body'); | |
| const previewHeadline = document.getElementById('preview-headline'); | |
| const previewAuthor = document.getElementById('preview-author'); | |
| const previewDateTop = document.getElementById('preview-date-top'); | |
| const previewDateSub = document.getElementById('preview-date-sub'); | |
| const previewBody = document.getElementById('preview-body'); | |
| // Live updates | |
| function updatePreview() { | |
| previewHeadline.textContent = inputHeadline.value || 'UNTITLED REPORT'; | |
| previewAuthor.textContent = inputAuthor.value || 'Anonymous'; | |
| previewDateTop.textContent = inputDate.value; | |
| previewDateSub.textContent = inputDate.value; | |
| // Format paragraphs | |
| const text = inputBody.value || ''; | |
| const paras = text.split('\n').filter(p => p.trim() !== ''); | |
| previewBody.innerHTML = paras.map(p => `<p class="mb-3">${p.trim()}</p>`).join(''); | |
| } | |
| [inputHeadline, inputAuthor, inputDate, inputBody].forEach(el => { | |
| el.addEventListener('input', updatePreview); | |
| }); | |
| // Initialize preview | |
| updatePreview(); | |
| // Drag & Drop | |
| const dropZone = document.getElementById('drop-zone'); | |
| const fileInput = document.getElementById('file-input'); | |
| const fileList = document.getElementById('file-list'); | |
| let selectedFiles = []; | |
| dropZone.addEventListener('click', () => fileInput.click()); | |
| dropZone.addEventListener('dragover', (e) => { | |
| e.preventDefault(); | |
| dropZone.classList.add('border-indigo-500', 'bg-slate-900/50'); | |
| }); | |
| dropZone.addEventListener('dragleave', () => { | |
| dropZone.classList.remove('border-indigo-500', 'bg-slate-900/50'); | |
| }); | |
| dropZone.addEventListener('drop', (e) => { | |
| e.preventDefault(); | |
| dropZone.classList.remove('border-indigo-500', 'bg-slate-900/50'); | |
| handleFiles(e.dataTransfer.files); | |
| }); | |
| fileInput.addEventListener('change', () => { | |
| handleFiles(fileInput.files); | |
| }); | |
| function handleFiles(files) { | |
| for (let file of files) { | |
| if (file.name.endsWith('.pdf') || file.name.endsWith('.docx')) { | |
| // Prevent duplicates | |
| if (!selectedFiles.some(f => f.name === file.name && f.size === file.size)) { | |
| selectedFiles.push(file); | |
| } | |
| } | |
| } | |
| renderFileList(); | |
| } | |
| function removeFile(index) { | |
| selectedFiles.splice(index, 1); | |
| renderFileList(); | |
| } | |
| function renderFileList() { | |
| fileList.innerHTML = selectedFiles.map((file, i) => ` | |
| <div class="flex items-center justify-between bg-slate-950 border border-slate-800 rounded-xl px-4 py-2 text-xs"> | |
| <div class="flex items-center space-x-2 truncate"> | |
| <svg class="w-4 h-4 text-indigo-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/></svg> | |
| <span class="text-slate-300 font-medium truncate">${file.name}</span> | |
| <span class="text-slate-600 flex-shrink-0">(${(file.size / 1024 / 1024).toFixed(2)} MB)</span> | |
| </div> | |
| <button onclick="removeFile(${i})" class="text-slate-500 hover:text-red-400 transition-colors p-1"> | |
| <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg> | |
| </button> | |
| </div> | |
| `).join(''); | |
| } | |
| // Construct TRON asset | |
| const btnConstruct = document.getElementById('btn-construct'); | |
| const statusMessage = document.getElementById('status-message'); | |
| btnConstruct.addEventListener('click', async () => { | |
| btnConstruct.disabled = true; | |
| statusMessage.className = 'text-center text-xs mt-3 text-cyan-400'; | |
| statusMessage.textContent = 'Uploading files and generating asset... Please wait.'; | |
| statusMessage.classList.remove('hidden'); | |
| const formData = new FormData(); | |
| formData.append('headline', inputHeadline.value); | |
| formData.append('author', inputAuthor.value); | |
| formData.append('date', inputDate.value); | |
| formData.append('body', inputBody.value); | |
| formData.append('persona', document.getElementById('input-persona').value); | |
| formData.append('grounding', document.getElementById('input-grounding').checked ? 'true' : 'false'); | |
| formData.append('grounding_instructions', document.getElementById('input-grounding-instructions').value); | |
| formData.append('voice', document.getElementById('input-voice').value); | |
| formData.append('greeting', document.getElementById('input-greeting').value); | |
| formData.append('silence_duration_ms', document.getElementById('input-vad-silence').value); | |
| formData.append('custom_backend_url', document.getElementById('input-backend-url').value); | |
| selectedFiles.forEach((file) => { | |
| formData.append('files', file); | |
| }); | |
| try { | |
| let backendOrigin = window.location.origin; | |
| if (window.location.protocol === 'file:') { | |
| backendOrigin = 'http://127.0.0.1:49999'; | |
| } else if ((window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') && window.location.port !== '49999') { | |
| backendOrigin = 'http://127.0.0.1:49999'; | |
| } | |
| const response = await fetch(`${backendOrigin}/construct`, { | |
| method: 'POST', | |
| body: formData | |
| }); | |
| if (!response.ok) { | |
| throw new Error(await response.text() || 'Failed to construct asset'); | |
| } | |
| const data = await response.json(); | |
| statusMessage.className = 'text-center text-xs mt-3 text-green-400'; | |
| statusMessage.textContent = 'TRON Asset compiled and hosted successfully!'; | |
| // Open the Share Modal with the link and download info | |
| openShareModal(data.shareable_url, data.filename); | |
| } catch (err) { | |
| console.error(err); | |
| statusMessage.className = 'text-center text-xs mt-3 text-red-400'; | |
| statusMessage.textContent = 'Error: ' + err.message; | |
| } finally { | |
| btnConstruct.disabled = false; | |
| } | |
| }); | |
| inputGrounding.addEventListener('change', () => { | |
| inputGroundingInstructions.disabled = !inputGrounding.checked; | |
| if (inputGrounding.checked) { | |
| inputGroundingInstructions.classList.remove('opacity-50', 'cursor-not-allowed'); | |
| } else { | |
| inputGroundingInstructions.classList.add('opacity-50', 'cursor-not-allowed'); | |
| } | |
| }); | |
| // Shareable Modal functions | |
| var currentDownloadUrl = ""; | |
| var currentFilename = ""; | |
| function openShareModal(shareableUrl, filename) { | |
| var shareModal = document.getElementById('share-modal'); | |
| var shareLinkInput = document.getElementById('share-link-input'); | |
| var btnDownloadModal = document.getElementById('btn-download-modal'); | |
| currentDownloadUrl = shareableUrl; | |
| currentFilename = filename; | |
| shareLinkInput.value = shareableUrl; | |
| const btnOpen = document.getElementById("btn-open-article"); | |
| if (btnOpen) btnOpen.href = shareableUrl; | |
| // Show modal | |
| shareModal.classList.remove('hidden'); | |
| // Allow display change before fading in | |
| setTimeout(() => { | |
| shareModal.classList.remove('opacity-0'); | |
| shareModal.querySelector('.transform').classList.remove('scale-95'); | |
| }, 50); | |
| // Configure download button in modal | |
| btnDownloadModal.onclick = async () => { | |
| try { | |
| const response = await fetch(currentDownloadUrl); | |
| const blob = await response.blob(); | |
| const url = window.URL.createObjectURL(blob); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = currentFilename; | |
| document.body.appendChild(a); | |
| a.click(); | |
| a.remove(); | |
| window.URL.revokeObjectURL(url); | |
| } catch (e) { | |
| alert("Download failed: " + e.message); | |
| } | |
| }; | |
| } | |
| function closeShareModal() { | |
| var shareModal = document.getElementById('share-modal'); | |
| var copyFeedback = document.getElementById('copy-feedback'); | |
| var btnCopyLink = document.getElementById('btn-copy-link'); | |
| shareModal.classList.add('opacity-0'); | |
| shareModal.querySelector('.transform').classList.add('scale-95'); | |
| setTimeout(() => { | |
| shareModal.classList.add('hidden'); | |
| // Clear feedback status | |
| copyFeedback.classList.add('hidden'); | |
| btnCopyLink.textContent = "Copy"; | |
| btnCopyLink.className = "bg-indigo-600 hover:bg-indigo-500 text-white font-semibold rounded-xl px-4 text-xs transition-all active:scale-95 flex items-center justify-center gap-1 min-w-[90px]"; | |
| }, 300); | |
| } | |
| async function copyShareLink() { | |
| var shareLinkInput = document.getElementById('share-link-input'); | |
| var btnCopyLink = document.getElementById('btn-copy-link'); | |
| var copyFeedback = document.getElementById('copy-feedback'); | |
| try { | |
| await navigator.clipboard.writeText(shareLinkInput.value); | |
| btnCopyLink.textContent = "Copied!"; | |
| btnCopyLink.className = "bg-green-600 hover:bg-green-500 text-white font-semibold rounded-xl px-4 text-xs transition-all active:scale-95 flex items-center justify-center gap-1 min-w-[90px]"; | |
| copyFeedback.classList.remove('hidden'); | |
| } catch (err) { | |
| console.error('Failed to copy text: ', err); | |
| // Fallback for non-secure contexts | |
| shareLinkInput.select(); | |
| document.execCommand('copy'); | |
| btnCopyLink.textContent = "Copied!"; | |
| copyFeedback.classList.remove('hidden'); | |
| } | |
| } | |
| </script> | |
| <!-- Shareable Link Modal Overlay --> | |
| <div id="share-modal" class="fixed inset-0 bg-slate-950/80 backdrop-blur-md flex items-center justify-center z-50 hidden opacity-0 transition-opacity duration-300"> | |
| <div class="bg-gradient-to-b from-slate-900 to-slate-950 border border-slate-800 rounded-3xl p-8 max-w-md w-full mx-4 shadow-2xl relative transform scale-95 transition-transform duration-300"> | |
| <!-- Close icon --> | |
| <button onclick="closeShareModal()" class="absolute top-4 right-4 text-slate-500 hover:text-slate-300 transition-colors"> | |
| <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg> | |
| </button> | |
| <!-- Header --> | |
| <div class="text-center mb-6"> | |
| <div class="w-16 h-16 bg-indigo-500/10 border border-indigo-500/20 text-indigo-400 rounded-full flex items-center justify-center mx-auto mb-4 animate-pulse"> | |
| <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.684 10.742l4.63-2.315a4 4 0 11.83 1.66l-4.63 2.315a4 4 0 11-.83-1.66zm0 0L13 12.042m0 0l4.63 2.315a4 4 0 11-.83 1.66l-4.63-2.315a4 4 0 11.83-1.66z"/></svg> | |
| </div> | |
| <h3 class="text-xl font-bold text-slate-100 font-sans tracking-wide">TRON Asset Ready!</h3> | |
| <p class="text-xs text-slate-400 mt-2">Your interactive voice-activated article is hosted and ready to share.</p> | |
| </div> | |
| <!-- Share Link Input --> | |
| <div class="mb-6"> | |
| <label class="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">Shareable Web Link</label> | |
| <div class="flex gap-2"> | |
| <input id="share-link-input" type="text" readonly class="w-full bg-slate-950 border border-slate-800 rounded-xl px-4 py-3 text-slate-200 outline-none text-xs font-mono select-all"> | |
| <button id="btn-copy-link" onclick="copyShareLink()" class="bg-indigo-600 hover:bg-indigo-500 text-white font-semibold rounded-xl px-4 text-xs transition-all active:scale-95 flex items-center justify-center gap-1 min-w-[90px]"> | |
| <span>Copy</span> | |
| </button> | |
| </div> | |
| <span id="copy-feedback" class="text-[10px] text-green-400 mt-1.5 hidden flex items-center gap-1"> | |
| <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg> | |
| Link copied to clipboard! | |
| </span> | |
| </div> | |
| <!-- Action buttons --> | |
| <div class="flex flex-col gap-3"> | |
| <a id="btn-open-article" href="#" target="_blank" class="w-full bg-gradient-to-r from-cyan-600 to-indigo-600 hover:from-cyan-500 hover:to-indigo-500 text-white font-semibold rounded-xl py-3.5 text-xs transition-all active:scale-98 flex items-center justify-center gap-2 shadow-lg shadow-indigo-500/20"> | |
| <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/></svg> | |
| Open Article in Browser (Direct Voice Mode) | |
| </a> | |
| <button id="btn-download-modal" class="w-full bg-slate-800/80 hover:bg-slate-800 border border-slate-700/50 text-slate-200 font-semibold rounded-xl py-3 text-xs transition-all active:scale-98 flex items-center justify-center gap-2"> | |
| <svg class="w-4 h-4 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/></svg> | |
| Download Standalone HTML File | |
| </button> | |
| <button onclick="closeShareModal()" class="w-full text-slate-400 hover:text-slate-200 font-semibold py-2 text-xs transition-all"> | |
| Done | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </body> | |
| </html> | |