Commit ·
3d4874c
1
Parent(s): 9834af3
Add Fact-Image UI section with form and status polling
Browse files- static/index.html +121 -0
static/index.html
CHANGED
|
@@ -270,6 +270,9 @@
|
|
| 270 |
<button class="tab-btn" data-tab="video">
|
| 271 |
📹 Video Creator
|
| 272 |
</button>
|
|
|
|
|
|
|
|
|
|
| 273 |
</div>
|
| 274 |
|
| 275 |
<!-- Story Reels Tab -->
|
|
@@ -367,6 +370,60 @@
|
|
| 367 |
<div id="videoStatus" class="status hidden"></div>
|
| 368 |
</div>
|
| 369 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
</div>
|
| 371 |
|
| 372 |
<script>
|
|
@@ -461,6 +518,70 @@
|
|
| 461 |
`;
|
| 462 |
});
|
| 463 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 464 |
// Video Form
|
| 465 |
document.getElementById('videoForm').addEventListener('submit', async (e) => {
|
| 466 |
e.preventDefault();
|
|
|
|
| 270 |
<button class="tab-btn" data-tab="video">
|
| 271 |
📹 Video Creator
|
| 272 |
</button>
|
| 273 |
+
<button class="tab-btn" data-tab="fact">
|
| 274 |
+
🧠 Fact Image
|
| 275 |
+
</button>
|
| 276 |
</div>
|
| 277 |
|
| 278 |
<!-- Story Reels Tab -->
|
|
|
|
| 370 |
<div id="videoStatus" class="status hidden"></div>
|
| 371 |
</div>
|
| 372 |
</div>
|
| 373 |
+
|
| 374 |
+
<!-- Fact Image Tab -->
|
| 375 |
+
<div id="fact-tab" class="tab-content">
|
| 376 |
+
<div class="card">
|
| 377 |
+
<h2>🧠 Fact Image Video</h2>
|
| 378 |
+
<p style="color: var(--text-secondary); margin-bottom: 1.5rem;">
|
| 379 |
+
Generate a clean image → Add fact text overlay → Create short video (4-7s)
|
| 380 |
+
</p>
|
| 381 |
+
|
| 382 |
+
<form id="factForm">
|
| 383 |
+
<div class="form-row">
|
| 384 |
+
<div class="form-group">
|
| 385 |
+
<label>Image Model</label>
|
| 386 |
+
<select id="factModel">
|
| 387 |
+
<option value="nvidia">NVIDIA (AI Generated)</option>
|
| 388 |
+
<option value="cloudflare">Cloudflare (AI Generated)</option>
|
| 389 |
+
<option value="pexels">Pexels (Stock Photo)</option>
|
| 390 |
+
</select>
|
| 391 |
+
</div>
|
| 392 |
+
<div class="form-group">
|
| 393 |
+
<label>Duration (seconds)</label>
|
| 394 |
+
<select id="factDuration">
|
| 395 |
+
<option value="4">4 seconds</option>
|
| 396 |
+
<option value="5" selected>5 seconds</option>
|
| 397 |
+
<option value="6">6 seconds</option>
|
| 398 |
+
<option value="7">7 seconds</option>
|
| 399 |
+
</select>
|
| 400 |
+
</div>
|
| 401 |
+
</div>
|
| 402 |
+
|
| 403 |
+
<div class="form-group">
|
| 404 |
+
<label>Image Prompt *</label>
|
| 405 |
+
<textarea id="factImagePrompt" rows="2"
|
| 406 |
+
placeholder="e.g., calm forest with soft sunlight filtering through trees, peaceful nature scene"
|
| 407 |
+
required></textarea>
|
| 408 |
+
<small style="color: var(--text-secondary);">Describe the background image. It will be generated
|
| 409 |
+
without text.</small>
|
| 410 |
+
</div>
|
| 411 |
+
|
| 412 |
+
<div class="form-group">
|
| 413 |
+
<label>Fact Text *</label>
|
| 414 |
+
<textarea id="factText" rows="3"
|
| 415 |
+
placeholder="e.g., People who daydream more tend to have higher creative intelligence."
|
| 416 |
+
required></textarea>
|
| 417 |
+
<small style="color: var(--text-secondary);">The psychology/motivational fact to overlay on the
|
| 418 |
+
image.</small>
|
| 419 |
+
</div>
|
| 420 |
+
|
| 421 |
+
<button type="submit" class="btn btn-primary">🎬 Generate Fact Video</button>
|
| 422 |
+
</form>
|
| 423 |
+
|
| 424 |
+
<div id="factStatus" class="status hidden"></div>
|
| 425 |
+
</div>
|
| 426 |
+
</div>
|
| 427 |
</div>
|
| 428 |
|
| 429 |
<script>
|
|
|
|
| 518 |
`;
|
| 519 |
});
|
| 520 |
|
| 521 |
+
// Fact Image Form
|
| 522 |
+
document.getElementById('factForm').addEventListener('submit', async (e) => {
|
| 523 |
+
e.preventDefault();
|
| 524 |
+
const status = document.getElementById('factStatus');
|
| 525 |
+
status.className = 'status processing';
|
| 526 |
+
status.innerHTML = '⏳ Generating fact video...';
|
| 527 |
+
status.classList.remove('hidden');
|
| 528 |
+
|
| 529 |
+
const data = {
|
| 530 |
+
model: document.getElementById('factModel').value,
|
| 531 |
+
image_prompt: document.getElementById('factImagePrompt').value,
|
| 532 |
+
fact_text: document.getElementById('factText').value,
|
| 533 |
+
duration: parseInt(document.getElementById('factDuration').value)
|
| 534 |
+
};
|
| 535 |
+
|
| 536 |
+
try {
|
| 537 |
+
const res = await fetch('/api/fact-image/', {
|
| 538 |
+
method: 'POST',
|
| 539 |
+
headers: { 'Content-Type': 'application/json' },
|
| 540 |
+
body: JSON.stringify(data)
|
| 541 |
+
});
|
| 542 |
+
const result = await res.json();
|
| 543 |
+
|
| 544 |
+
if (result.job_id) {
|
| 545 |
+
status.innerHTML = `✅ Job started! ID: ${result.job_id}<br>Checking status...`;
|
| 546 |
+
pollFactStatus(result.job_id);
|
| 547 |
+
}
|
| 548 |
+
} catch (err) {
|
| 549 |
+
status.className = 'status error';
|
| 550 |
+
status.innerHTML = '❌ Error: ' + err.message;
|
| 551 |
+
}
|
| 552 |
+
});
|
| 553 |
+
|
| 554 |
+
// Poll Fact Image status
|
| 555 |
+
async function pollFactStatus(jobId) {
|
| 556 |
+
const status = document.getElementById('factStatus');
|
| 557 |
+
|
| 558 |
+
const check = async () => {
|
| 559 |
+
try {
|
| 560 |
+
const res = await fetch(`/api/fact-image/${jobId}/status`);
|
| 561 |
+
const data = await res.json();
|
| 562 |
+
|
| 563 |
+
const progress = data.progress || 0;
|
| 564 |
+
status.innerHTML = `
|
| 565 |
+
<div>Status: <strong>${data.status}</strong></div>
|
| 566 |
+
<div class="progress-bar"><div class="progress-fill" style="width: ${progress}%"></div></div>
|
| 567 |
+
`;
|
| 568 |
+
|
| 569 |
+
if (data.status === 'ready') {
|
| 570 |
+
status.className = 'status success';
|
| 571 |
+
status.innerHTML += `<br><a href="/api/fact-image/${jobId}" class="btn btn-primary" style="margin-top: 1rem; display: inline-block;">📥 Download Video</a>`;
|
| 572 |
+
} else if (data.status === 'failed') {
|
| 573 |
+
status.className = 'status error';
|
| 574 |
+
status.innerHTML = '❌ Failed: ' + (data.error || 'Unknown error');
|
| 575 |
+
} else {
|
| 576 |
+
setTimeout(check, 2000);
|
| 577 |
+
}
|
| 578 |
+
} catch (err) {
|
| 579 |
+
setTimeout(check, 3000);
|
| 580 |
+
}
|
| 581 |
+
};
|
| 582 |
+
check();
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
// Video Form
|
| 586 |
document.getElementById('videoForm').addEventListener('submit', async (e) => {
|
| 587 |
e.preventDefault();
|