var THROBBER=document.createElement('img'); THROBBER.src='img/throbber.gif'; function commentsInit() { fetchComments(1,COMMENT_RESPERPAGE); if(document.getElementById('doComment')) { document.getElementById('doComment').onclick=doComment; } } function fetchComments(p,resperpage) { if(!VIDEO_ID) return; if(!p) p=0; var cont=document.getElementById('comments_cont'); if(!cont) return; var qs='&p='+p; if(resperpage) { qs+="&resperpage="+resperpage; } //throbber: cont.innerHTML=''; var d=document.createElement('div'); d.style.textAlign='center'; var t=THROBBER.cloneNode(true); d.appendChild(t); cont.appendChild(d); sendRequest('xmlhttp.php',handleComments,'mod=comments&v='+VIDEO_ID+qs,cont); } function handleComments(data,cont) { if(!data) return; if(!cont) return; cont.innerHTML=''; var main=eval("("+data.responseText+")"); if(main['error']!=null) { var d=document.createElement('div'); d.className='comments_err'; d.style.textAlign='center'; d.innerHTML=main['error']; cont.appendChild(d); } else if(main['result']['comments'].length>0) { for(var i=0;i0) { COMMENT_CURR_PAGE=parseInt(main['result']['pagination'][0]); COMMENT_PAGES=parseInt(main['result']['pagination'][2]); COMMENT_RESPERPAGE=parseInt(main['result']['pagination'][2]); if(COMMENT_PAGES>0) { var x=commentPagination(main['result']['pagination']); cont.appendChild(x); } } if(document.getElementById('resperpage_select')) { document.getElementById('resperpage_select').onchange=function() { fetchComments(COMMENT_CURR_PAGE,this.options[this.options.selectedIndex].value); } } } function oneComment(c) { var d=document.createElement('div'); var h=document.createElement('h4'); var n=document.createTextNode(c['nomen']); var s=document.createElement('span'); s.innerHTML=c['datum']; h.appendChild(n); h.appendChild(s); var p=document.createElement('p'); p.innerHTML=decodeURIComponent(c['textus']); d.appendChild(h); d.appendChild(p); d.className='one_comment'; return d; } function commentPagination(data) { var p=parseInt(data[0]); var pages=parseInt(data[1]); var resperpage=parseInt(data[2]); var d=document.createElement('div'); d.className='div'; var d2=document.createElement('div'); d2.className='pager'; if(p>1) { if(p>2) { var butt=document.createElement('a'); butt.className='frev'; butt.innerHTML=' '; butt.rel=1; butt.onclick=function(){fetchComments(this.rel,COMMENT_RESPERPAGE)}; butt.title='Ugrás a legelső oldalra'; butt.style.cursor='pointer'; d2.appendChild(butt); } var butt=document.createElement('a'); butt.className='rev'; butt.innerHTML=' '; butt.rel=(p==1)?1:(p-1); butt.onclick=function(){fetchComments(this.rel,COMMENT_RESPERPAGE)}; butt.title='Előző oldal'; butt.style.cursor='pointer'; d2.appendChild(butt); } var st=((p-2)<1)?1:(p-2); var fn=((st+5)>(pages+1))?(pages+1):(st+5); for(var i=st;ipages)?pages:(p+1); butt.onclick=function(){fetchComments(this.rel,COMMENT_RESPERPAGE)}; butt.title='Következő oldal'; butt.style.cursor='pointer'; d2.appendChild(butt); if((p+1)0) { doComment_errhandling(err,errnum); } else { var qs=''; qs+="&nomen="+encodeURIComponent(n.value)+"&textus="+encodeURIComponent(t.value); //throbberize COMMENT_FORM_CACHE=f.cloneNode(true); f.innerHTML=''; var d=document.createElement('div'); d.style.textAlign='center'; var t=THROBBER.cloneNode(true); d.appendChild(t); d.appendChild(document.createElement('br')); d.appendChild(document.createTextNode('Kis türelmet...')); f.appendChild(d); sendRequest('xmlhttp.php',handleDoComment,'mod=doComment&v='+VIDEO_ID+qs,f); } } function handleDoComment(data,f) { if(!data) return; if(!COMMENT_FORM_CACHE) return; if(!f) return; f.innerHTML=''; var main=eval("("+data.responseText+")"); if(main.error!=null) { f.parentNode.replaceChild(COMMENT_FORM_CACHE,f); document.getElementById('doComment').onclick=doComment; var errnum=0; for(k in main.error) { errnum++; } doComment_errhandling(main.error,errnum); } else if(main.result!=null) { var d=document.createElement('div'); d.className='comment_result_msg'; d.innerHTML=main.result.msg; f.appendChild(d); location.hash='#comment_box'; fetchComments(1,COMMENT_RESPERPAGE); COMMENT_FORM_CACHE=null; } } function doComment_errhandling(err,errnum) { if(!err) return; if(errnum<1) return; var c=document.getElementById('doComment_err_msg'); if(!c) return; var m=''; if(errnum>1) { m+="Hiba! A hozzászólás elküldése az alábbi okok miatt nem sikerült:"; } else { m+="Hiba! A hozzászólás elküldése az alábbi ok miatt nem sikerült:"; } m+="
"; var focal=false; for(k in err) { if(focal==false) { document.getElementById('doComment_'+k).focus(); var focal=true; } m+="- "+err[k]+"
"; //AddClassName(document.getElementById('doComment_'+k),'erred'); } c.innerHTML=m; }