Skip to content

Text to vertical video in 100+ styles: AI codes each scene (HTML/SVG/WebGL), renders a 9:16 MP4 with music and English/Vietnamese voice. MCP, CLI and REST for AI agents.

1.8 KB
Raw Blame
// Tab "Dựng từ mẫu": nút "Sửa tiếp trong Studio" trên thẻ video đã dựng xong → POST /api/edits/from-reel {job}
// (edit/reel.mjs: giữ nguyên, tách track giọng/nhạc nếu reel còn tiếng riêng) rồi mở thẳng Studio #/edit/<id>.
// Studio có link "↩ Reel" (#reel/<id>) quay về đúng thẻ video đó.
import { $, t, I, postJSON } from './util.js';

document.addEventListener('click', async (e) => {
  const b = e.target.closest?.('[data-studio]'); if (!b || b.disabled) return;
  e.preventDefault();
  const label = b.textContent;
  b.disabled = true; b.textContent = t('job.studioBusy');
  try {
    const j = await postJSON('/api/edits/from-reel', { job: b.dataset.studio });
    location.hash = `#/edit/${encodeURIComponent(j.id)}`;
  } catch (err) {
    b.title = t('job.studioErr', { e: I.srv(err.message) });
    b.textContent = label;
    const card = b.closest('.job'); const box = card?.querySelector('.errmsg.studio') || document.createElement('div');
    box.className = 'errmsg studio'; box.textContent = t('job.studioErr', { e: I.srv(err.message) });
    if (card && !box.isConnected) b.closest('.links')?.after(box);
  } finally { b.disabled = false; if (b.textContent === t('job.studioBusy')) b.textContent = label; }
});

function showReel() {
  const m = /^#reel\/([\w-]{1,80})$/.exec(location.hash); if (!m) return;
  $('.tab[data-tab="tpl"]')?.click();
  const tryScroll = (n) => {
    const card = document.getElementById('job-' + m[1]);
    if (!card) { if (n < 20) setTimeout(() => tryScroll(n + 1), 250); return; }
    card.scrollIntoView({ block: 'center' });
    card.classList.add('flash'); setTimeout(() => card.classList.remove('flash'), 1600);
  };
  tryScroll(0);
}
window.addEventListener('hashchange', showReel);
showReel();