Spaces:
Running
Running
Upload static/app_v2.js with huggingface_hub
Browse files- static/app_v2.js +24 -7
static/app_v2.js
CHANGED
|
@@ -122,7 +122,7 @@ async function makeShortVideo(postId, btn, voice, speed){
|
|
| 122 |
const r = await fetch(url, {method:'POST'});
|
| 123 |
const j = await r.json();
|
| 124 |
if(!r.ok || j.error) throw new Error(j.error||'Lỗi tạo video');
|
| 125 |
-
toast('✅ Đã tạo video shorts!');
|
| 126 |
const p = _wallPosts.find(x => String(x.id) === String(postId));
|
| 127 |
if(p){
|
| 128 |
p.video = j.video;
|
|
@@ -136,6 +136,11 @@ async function makeShortVideo(postId, btn, voice, speed){
|
|
| 136 |
}
|
| 137 |
}
|
| 138 |
refreshShortAISlider();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
}catch(e){
|
| 140 |
toast('❌ '+e.message);
|
| 141 |
if(btn){btn.disabled=false;btn.textContent=origText;}
|
|
@@ -146,14 +151,26 @@ function refreshShortAISlider(){
|
|
| 146 |
const aiShorts = _wallPosts.filter(p=>p.video);
|
| 147 |
let shortAISection = document.getElementById('short-ai-section');
|
| 148 |
if(aiShorts.length === 0){ if(shortAISection) shortAISection.remove(); return; }
|
| 149 |
-
if(shortAISection){
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
}
|
| 156 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
}
|
| 158 |
|
| 159 |
function prependWallPost(post){
|
|
|
|
| 122 |
const r = await fetch(url, {method:'POST'});
|
| 123 |
const j = await r.json();
|
| 124 |
if(!r.ok || j.error) throw new Error(j.error||'Lỗi tạo video');
|
| 125 |
+
toast('✅ Đã tạo video shorts! Xem trong slider 🎬 Short AI');
|
| 126 |
const p = _wallPosts.find(x => String(x.id) === String(postId));
|
| 127 |
if(p){
|
| 128 |
p.video = j.video;
|
|
|
|
| 136 |
}
|
| 137 |
}
|
| 138 |
refreshShortAISlider();
|
| 139 |
+
// Scroll to Short AI section after a short delay
|
| 140 |
+
setTimeout(()=>{
|
| 141 |
+
const s = document.getElementById('short-ai-section');
|
| 142 |
+
if(s) s.scrollIntoView({behavior:'smooth',block:'nearest'});
|
| 143 |
+
},300);
|
| 144 |
}catch(e){
|
| 145 |
toast('❌ '+e.message);
|
| 146 |
if(btn){btn.disabled=false;btn.textContent=origText;}
|
|
|
|
| 151 |
const aiShorts = _wallPosts.filter(p=>p.video);
|
| 152 |
let shortAISection = document.getElementById('short-ai-section');
|
| 153 |
if(aiShorts.length === 0){ if(shortAISection) shortAISection.remove(); return; }
|
| 154 |
+
if(!shortAISection){
|
| 155 |
+
// Create Short AI section if it doesn't exist
|
| 156 |
+
const homeEl = document.getElementById('view-home');
|
| 157 |
+
if(!homeEl) return;
|
| 158 |
+
shortAISection = document.createElement('div');
|
| 159 |
+
shortAISection.id = 'short-ai-section';
|
| 160 |
+
shortAISection.className = 'slider-wrap';
|
| 161 |
+
// Insert before the wall section or at end
|
| 162 |
+
const wallEl = document.getElementById('ai-wall-wrap');
|
| 163 |
+
if(wallEl && wallEl.parentNode === homeEl){
|
| 164 |
+
homeEl.insertBefore(shortAISection, wallEl);
|
| 165 |
+
} else {
|
| 166 |
+
homeEl.appendChild(shortAISection);
|
| 167 |
}
|
| 168 |
}
|
| 169 |
+
// Build the slider track
|
| 170 |
+
let h = '<div class="slider-header"><span class="slider-label">🎬 Short AI</span></div><div class="slider-track">';
|
| 171 |
+
aiShorts.slice(0,20).forEach((p,i)=>{h+=`<div class="slider-item shorts-item" onclick="openShortAIFeed(${i})"><div class="slider-thumb shorts-thumb"><video src="${esc(p.video)}" muted preload="metadata"></video><div class="card-play">▶</div></div><div class="slider-title">${esc(p.title)}</div></div>`;});
|
| 172 |
+
h += '</div>';
|
| 173 |
+
shortAISection.innerHTML = h;
|
| 174 |
}
|
| 175 |
|
| 176 |
function prependWallPost(post){
|