1(()=>{ 2'use strict'; 3 4const modal=document.querySelector('[data-video-report-modal]'); 5const openBtn=document.querySelector('[data-video-report-open]'); 6if(!modal||!openBtn)return; 7 8const form=modal.querySelector('[data-video-report-form]'); 9const closeBtns=[...modal.querySelectorAll('[data-video-report-close]')]; 10const question=modal.querySelector('[data-video-report-question]'); 11const tokenInput=modal.querySelector('[name="captcha_token"]'); 12const answerInput=modal.querySelector('[name="captcha_answer"]'); 13const refreshBtn=modal.querySelector('[data-video-report-captcha-refresh]'); 14const errorBox=modal.querySelector('[data-video-report-error]'); 15const successBox=modal.querySelector('[data-video-report-success]'); 16const formBody=modal.querySelector('[data-video-report-form-body]'); 17const submitBtn=form?.querySelector('[type="submit"]'); 18 19function setError(text=''){ 20 if(!errorBox)return; 21 errorBox.textContent=text; 22 errorBox.hidden=!text; 23} 24function showSuccess(){ 25 if(formBody)formBody.hidden=true; 26 if(successBox)successBox.hidden=false; 27} 28function resetState(){ 29 form?.reset(); 30 if(formBody)formBody.hidden=false; 31 if(successBox)successBox.hidden=true; 32 setError(''); 33} 34async function loadCaptcha(){ 35 if(question)question.textContent='â¦'; 36 if(tokenInput)tokenInput.value=''; 37 if(answerInput)answerInput.value=''; 38 try{ 39 const res=await fetch('/video-report-captcha.php',{credentials:'same-origin',cache:'no-store'}); 40 const data=await res.json(); 41 if(!res.ok||!data.ok)throw new Error('captcha'); 42 if(question)question.textContent=data.question||''; 43 if(tokenInput)tokenInput.value=data.token||''; 44 answerInput?.focus(); 45 }catch(e){ 46 if(question)question.textContent='â'; 47 setError(modal.dataset.errorLabel||'Could not load the security check.'); 48 } 49} 50function open(){ 51 resetState(); 52 modal.hidden=false; 53 document.documentElement.classList.add('vv-modal-open'); 54 loadCaptcha(); 55} 56function close(){ 57 modal.hidden=true; 58 document.documentElement.classList.remove('vv-modal-open'); 59} 60openBtn.addEventListener('click',open); 61closeBtns.forEach(btn=>btn.addEventListener('click',close)); 62modal.addEventListener('click',e=>{if(e.target===modal)close()}); 63document.addEventListener('keydown',e=>{if(e.key==='Escape'&&!modal.hidden)close()}); 64refreshBtn?.addEventListener('click',loadCaptcha); 65 66form?.addEventListener('submit',async e=>{ 67 e.preventDefault(); 68 setError(''); 69 if(!tokenInput?.value){ 70 await loadCaptcha(); 71 return; 72 } 73 74 const normalLabel=submitBtn?.dataset.label||'Report'; 75 const sendingLabel=submitBtn?.dataset.sendingLabel||'Sendingâ¦'; 76 if(submitBtn){ 77 submitBtn.disabled=true; 78 submitBtn.textContent=sendingLabel; 79 } 80 81 try{ 82 const res=await fetch('/video-report.php',{ 83 method:'POST', 84 body:new FormData(form), 85 credentials:'same-origin', 86 headers:{'X-Requested-With':'XMLHttpRequest'} 87 }); 88 const data=await res.json().catch(()=>({ok:false,error:'server_error'})); 89 if(!res.ok||!data.ok){ 90 if(data.error==='invalid_captcha'){ 91 setError(modal.dataset.captchaErrorLabel||'Incorrect security answer.'); 92 await loadCaptcha(); 93 }else if(data.error==='rate_limited'){ 94 setError(modal.dataset.rateLabel||'Too many reports. Try again later.'); 95 }else if(data.error==='already_reported'){ 96 setError(modal.dataset.duplicateLabel||'You already reported this video recently.'); 97 }else{ 98 setError(modal.dataset.errorLabel||'Could not send the report.'); 99 await loadCaptcha(); 100 } 101 return; 102 } 103 showSuccess(); 104 }catch(err){ 105 setError(modal.dataset.errorLabel||'Could not send the report.'); 106 await loadCaptcha(); 107 }finally{ 108 if(submitBtn){ 109 submitBtn.disabled=false; 110 submitBtn.textContent=normalLabel; 111 } 112 } 113}); 114})();
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.