1(function(){ 2 'use strict'; 3 const input=document.getElementById('svcImages'); 4 const preview=document.getElementById('svcPreview'); 5 const button=document.getElementById('svcRender'); 6 const status=document.getElementById('svcStatus'); 7 const result=document.getElementById('svcResult'); 8 const duration=document.getElementById('svcDuration'); 9 if(!input||!button) return; 10 let selected=[]; 11 12 function setStatus(msg,error){ 13 status.textContent=msg||''; 14 status.className='svc-status '+(error?'error':''); 15 } 16 function renderPreview(){ 17 preview.innerHTML=''; 18 selected.forEach((file,i)=>{ 19 const card=document.createElement('div'); card.className='svc-card'; 20 const img=document.createElement('img'); img.alt=''; img.src=URL.createObjectURL(file); 21 const n=document.createElement('span'); n.textContent=(i+1); 22 card.appendChild(img); card.appendChild(n); preview.appendChild(card); 23 }); 24 } 25 input.addEventListener('change',function(){ 26 selected=Array.from(input.files||[]).slice(0,30); 27 if(input.files.length>30) setStatus('Only the first 30 images will be used.',true); 28 else setStatus(selected.length?selected.length+' image(s) ready.':''); 29 renderPreview(); 30 result.innerHTML=''; 31 }); 32 button.addEventListener('click',async function(){ 33 if(!selected.length){setStatus('Please select at least one image.',true);return;} 34 button.disabled=true; result.innerHTML=''; setStatus('Uploading images and creating your MP4â¦'); 35 const fd=new FormData(); 36 fd.append('action','svc_render_video'); 37 fd.append('nonce',svc_ajax.nonce); 38 fd.append('duration',Math.max(1,Math.min(15,parseInt(duration.value||4,10)))); 39 selected.forEach((f)=>fd.append('images[]',f,f.name)); 40 try{ 41 const response=await fetch(svc_ajax.ajaxurl,{method:'POST',body:fd,credentials:'same-origin'}); 42 const data=await response.json().catch(()=>null); 43 if(!response.ok || !data || !data.success){ 44 throw new Error(data&&data.data&&data.data.message ? data.data.message : 'WordPress returned an unexpected error.'); 45 } 46 setStatus('Video created successfully.'); 47 const a=document.createElement('a'); a.href=data.data.url; a.target='_blank'; a.rel='noopener'; a.textContent='â¶ Open / download the MP4'; a.className='svc-download'; 48 result.appendChild(a); 49 const video=document.createElement('video'); video.controls=true; video.playsInline=true; video.src=data.data.url; result.appendChild(video); 50 }catch(e){ setStatus(e.message||'Could not create the video.',true); } 51 finally{button.disabled=false;} 52 }); 53})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.