⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comment.js

📁 用最近的dojo1.2.1制作前端的ajax购书网站
💻 JS
字号:
var Layer0=document.getElementById("Layer0");
var over=document.getElementById("over");
var _initial_listbox_top=Layer0.offsetHeight-over.offsetHeight;
var _submit_bottom=Layer0.offsetHeight*0.8;


var cx=0;

var _document_width=document.getElementById("Layer0").offsetWidth
var x,y;
var b_id;
var object;
var temp1,temp2;
var object_mousedown=false;
var _move_listbox=false;
var _type_words=false;
var interval=0;
var move_all=false;
var _move_words=false;
var _tx0=document.getElementById("text0");
var _tx1=document.getElementById("text1");
var _tx2=document.getElementById("text2")
var _move_text0=false;
var _move_text1=false;
var _change_left=false;
var _change_right=false;
var _instantPage=1;
var _page_content=5;
var _first_visit=true;
var _whole_pages;
var _times=0;
var _show_time=0;
var pages=document.getElementById("pages");
var result=document.getElementById("result");
var text0=document.getElementById("text0");
var text0child=document.getElementById("text0child");
var text1=document.getElementById("text1");
var text1child=document.getElementById("text1child");
var text2=document.getElementById("text2");
var text2child=document.getElementById("text2child");
var over=document.getElementById("over");
 
function allInitial(book_id)
{ b_id=book_id
li.setActive();


Layer0.style.visibility="visible";


getComment(1,b_id,_times);
 }
  function shut_listbox()
  {
  Layer0.style.visibility="hidden";
  }
function showResult()
{var  m=setInterval(function(){result_show(m)},100);}
	function  result_show(m)
	{

	_show_time++;
 	var t=_show_time%8;
	
	result.style.display="block";
 	
	result.style.filter="glow(color=yellow,strength="+t+")";
	if(_show_time>=100)
{	result.style.display="none";
	clearInterval(m);
	_show_time=0;
}	
	}


function move_words(t)
{

var m=setInterval(function(){words_hide(t,m)},1);
}

function words_hide(t,m )
{
var obj= _tx0;

  
 
if( obj.style.left=="")
{obj.style.left=obj.offsetLeft;
obj.style.offsetRight=obj.offsetLeft+obj.offsetWidth;}
 
if(obj.offsetLeft<-obj.offsetWidth+50)
{
 
clearInterval(m);_change_left=true;
obj.style.left=parseInt(-obj.offsetWidth)+"px";

}


else
{
_change_left=false;
temp=parseInt(obj.style.left);
obj.style.left=t+temp+"px";
} 


}
function switch_text()
{

}
  
 setInterval(function(){text_show()},1);
function handleSendComment()
{
var obj=acceptData();
if(obj.result==true)
{
result.innerText="Thank You!";
showResult(); _instantPage=1;
}
else
{result.innerText="Sorry,Error Comes!";

showResult();
}
 
getComment(1,b_id,++_times);
}
function spring_listbox(y)
{ 
var tops=parseInt(y);
if(tops<_submit_bottom)
{
if(li.innerText=="")
{
result.innerText="Can't Be Empty!";

showResult();
initial("over");return;}






var ct=li.value;

sendComment(ct,b_id);

initial("over");
}
}

function initial(id)
{ 
var object=document.getElementById(id)
over.style.top=_initial_listbox_top+"px";
over.style.left=0;
 if(_move_listbox)
 _move_listbox=false;
 
li.innerText="";

}

 
function listbox_onmousedown(id,child_id)
{
 

object=document.getElementById(id);
 if(_move_listbox==true)
 
 {
 
 object=document.getElementById("over");
 
 }
    
 if(_move_words)
 {
 object=_tx0;
 }
 
temp1=parseInt(object.offsetLeft);
temp2=parseInt(object.offsetTop);
 


x=event.clientX;
y=event.clientY;

object_mousedown=true;
object.setCapture();
}

function text_show()
{
if(_tx0.style.left!="")
{
if(_tx1.style.left<0)
{
_tx1.style.left=0;
return;}
 
_tx1.style.left=_document_width+parseInt(_tx0.style.left)+"px";

}

if(_tx0.style.left!="")
{
if(_tx2.style.left>0)
{
_tx2.style.left=0;
}
_tx2.style.left=parseInt(_tx0.style.left)-_document_width+"px";
}



if(_change_left==true)
{ 
_change_left=false;
 

var d0=_tx0;
var d1=_tx1;
var d2=_tx2;
_tx0=d2;
_tx1=d0;
_tx2=d1;
_tx0.style.left=0;

_tx1.childNodes[0].innerText="";
_tx2.childNodes[0].innerText="";

   _instantPage--;
if(_instantPage>=1)
getComment(_instantPage,b_id,++_times);
 
}


if(_change_right==true)
{
_change_right=false;
 

var d0=_tx0;
var d1=_tx1;
var d2=_tx2;
_tx0=d1;
_tx1=d2;
_tx2=d0;
_tx0.style.left=0;


_tx1.childNodes[0].innerText="";
_tx2.childNodes[0].innerText="";
   
   _instantPage++;
if(_instantPage<=_whole_pages)
getComment(_instantPage,b_id,++_times);

}


} 

 
function handleComment()
{

obj=acceptData();
var hml="";
 _whole_pages=Math.ceil(parseInt(obj[0].wholeresult)/5);
pages.innerText=_whole_pages+"pages, page No."+_instantPage;


for(var i=1;i<=_page_content;i++)
{

if(obj[i]==null)
break;
hml=hml+"<p>";
hml=hml+obj[i].ip;
hml=hml+" ";
hml=hml+obj[i].datetime;
hml=hml+"</p>"; 
hml=hml+"<p>";
hml=hml+obj[i].context;
hml=hml+"</p>";
 

}

//if(_first_visit) 
 
_tx0.childNodes[0].innerHTML=hml;


 

 

}
function listbox_onmousemove(id)
{

 if(_type_words)
 return;

 if(_move_words)
 text_show();
if(object_mousedown)
{ 
  
object.style.left=temp1+event.clientX-x+"px";
 
object.style.top=temp2+event.clientY-y+"px";
x=event.clientX;
y=event.clientY;

 
if(!_move_words) 
{temp1=temp1<0?0:parseInt(object.style.left);
temp2=temp2<0?0:parseInt(object.style.top);
}
else
{temp1=parseInt(object.style.left);
temp2=parseInt(object.style.top);
var idd=document.getElementById(id);
 
 

}
 _tx0.style.top=0;
}
}
function spring_words()
{ 


if(!_move_words)
return false;
 
 
var t=-_tx0.offsetWidth/2 ;
 
if(_tx0.offsetLeft<t)
{// alert(_whole_pages);
//alert(_instantPage);

if(_instantPage>=_whole_pages)
{ 
 return false;}
  
  _change_right=true;


 

 

return true;}

else if(_tx0.offsetLeft>-t)
{





if(_instantPage<=1)
{ 
 return false;}


_change_left=true;return true;}

else
{return false;
}

}



function latter(i,m)
{
i++;
if(i==3)
clearInterval(m);
}


function listbox_onmouseup(id)
{
 
 if(!_type_words)
 
spring_listbox(over.style.top);
 
if(!spring_words())
{_tx1.style.left=_document_width+"px";
_tx0.style.left=0;
_tx2.style_left=-_document_width+"px";
}

object_mousedown=false;

object.releaseCapture();




} 
 
 
 over.onmouseenter=function(e){ _move_listbox=true;}
 over.onmouseleave=function(e){_move_listbox=false;}
 li.onmouseenter=function(e){_type_words=true;li.setActive();}
 li.onmouseleave=function(e){_type_words=false;}
 
 _tx0.onmouseenter=function(e){_move_words=true;_move_text0=true;}
 _tx0.onmouseleave=function(e){_move_words=false;;_move_text0=false;}
 _tx1.onmouseenter=function(e){_move_words=true;_move_text1=true;}
 _tx1.onmouseleave=function(e){_move_words=false;_move_text1=false;}
_tx2.onmouseenter=function(e){_move_words=true;_move_text2=true;}
 _tx2.onmouseleave=function(e){_move_words=false;_move_text2=false;}
  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -