📄 comment.page.js
字号:
/*================================================================
Created:2007-5-29
Autor:linwenzhong
Copyright:www.Kesion.com bbs.kesion.com
Version:KesionCMS V4.0
Service QQ:111394,54004407
==================================================================*/
//ajax 控件
function PageAjax(){
var xhrObj=null;
if(window.XMLHttpRequest){
xhrObj=new XMLHttpRequest();
}
else if(window.ActiveXObject){
try{
xhrObj=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e1)
{
try{
xhrObj=new ActiveXObject("MSXML2.XMLHTTP");
}
catch(e2){
try{
xhrObj=new ActiveXObject("MSXML3.XMLHTTP");
}
catch(e3){
alert("创建Ajax失败:"+e3)
}
}
}
}
else
{
alert("未能识别的浏览器");
}
return xhrObj;
}
var loader=new PageAjax;
function ajaxLoadPage(url,request,method,fun)
{
method=method.toUpperCase();
if (method=='GET')
{
urls=url.split("?");
if (urls[1]=='' || typeof urls[1]=='undefined')
{
url=urls[0]+"?"+request;
}
else
{
url=urls[0]+"?"+urls[1]+"&"+request;
}
request=null;
}
loader.open(method,url,true);
if (method=="POST")
{
loader.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
loader.onreadystatechange=function(){
eval(fun+'()');
}
loader.send(request);
}
//评论支持
function Support(id,typeid,installdir)
{
ajaxLoadPage(installdir+'plus/Comment.asp','action=Support&Type='+typeid+'&id=' +id,'post','callback');
}
function callback()
{
if (loader.readyState==4)
{
var s=loader.responseText;
if (s=='good'||s=='bad')
{
if (s=='good')
alert('成功的献上了一束鲜花!');
else
alert('成功的扔出了一个鸡蛋!');
loadDate(_page);
}
else
alert(s);
}
}
//当前页,频道ID,栏目ID,信息ID,Action,InstallDir
function Page(curPage,channelid,infoid,action,installdir)
{
this._channelid = channelid;
this._infoid = infoid;
this._action = action;
this._url = installdir +"plus/comment.asp";
this._c_obj="c_"+infoid;
this._p_obj="p_"+infoid;
this._installdir=installdir;
this._page=curPage;
loadDate(1);
}
function loadDate(p)
{ this._page=p;
var xhr=new PageAjax();
xhr.open("get",_url+"?channelid="+_channelid+"&infoid="+_infoid+"&action=" +_action+"&page="+p,true);
xhr.onreadystatechange=function (){
if(xhr.readyState==1)
{
//getObject(_c_obj).innerHTML="<div align='center'><img src='"+_installdir+"images/loading.gif'>正在连接服务器...</div>";
}
else if(xhr.readyState==2 || xhr.readyState==3)
{
//getObject(_c_obj).innerHTML="<div align='center'><img src='"+_installdir+"images/loading.gif'>正在读取数据...</div>";
}
else if(xhr.readyState==4)
{
if (xhr.status==200)
{
var pagearr=xhr.responseText.split("{ks:page}")
var pageparamarr=pagearr[1].split("|");
count=pageparamarr[0];
perpagenum=pageparamarr[1];
pagecount=pageparamarr[2];
itemunit=pageparamarr[3];
itemname=pageparamarr[4];
pagestyle=pageparamarr[5];
getObject(_c_obj).innerHTML=pagearr[0];
pagelist();
}
}
}
xhr.send(null);
}
function getObject(id)
{
if(document.getElementById)
{
return document.getElementById(id);
}
else if(document.all)
{
return document.all[id];
}
else if(document.layers)
{
return document.layers[id];
}
}
function pagelist()
{
var n=1;
var statushtml=null;
switch(parseInt(this.pagestyle))
{
case 1:
statushtml="共"+this.count+this.itemunit+" <a href=\"javascript:homePage();\" title=\"首页\">首页</a> <a href=\"javascript:previousPage()\" title=\"上一页\">上一页</a> <a href=\"javascript:nextPage()\" title=\"下一页\">下一页</a> <a href=\"javascript:lastPage();\" title=\"最后一页\">尾页</a> 页次:<font color=red>"+this._page+"</font>/"+this.pagecount+"页 "+this.perpagenum+this.itemunit+this.itemname+"/页";
break;
case 2:
statushtml="共"+this.pagecount+"页/"+this.count+this.itemunit+this.itemname+" <a href=\"javascript:homePage();\" title=\"首页\"><font face=webdings>9</font></a> <a href=\"javascript:previousPage()\" title=\"上一页\"><font face=webdings>7</font></a> ";
var startpage=1;
if (this._page>10)
startpage=(parseInt(this._page/10)-1)*10+parseInt(this._page%10)+1;
for(var i=startpage;i<=this.pagecount;i++){
if (i==this._page)
statushtml+="<a href=\"#\"><font color=\"#ff0000\">"+i+"</font></a> "
else
statushtml+="<a href=\"javascript:turn("+i+")\">["+i+"]</a> "
n=n+1;
if (n>10) break;
}
statushtml+="<a href=\"javascript:nextPage()\" title=\"下一页\"><font face=webdings>8</font></a> <a href=\"javascript:lastPage();\" title=\"最后一页\"><font face=webdings>:</font></a>";
statushtml="<span class='kspage'>"+statushtml+"</span>";
break;
case 3:
statushtml="第<font color=#ff000>"+this._page+"</font>页 共"+this.pagecount+"页 <a href=\"javascript:homePage();\" title=\"首页\"><<</a> <a href=\"javascript:previousPage()\" title=\"上一页\"><</a> <a href=\"javascript:nextPage()\" title=\"下一页\">></a> <a href=\"javascript:lastPage();\" title=\"最后一页\">>></a> "+this.perpagenum+this.itemunit+this.itemname+"/页";
case 4:
statushtml="页次:<font color=red>"+this._page+"</font>/"+this.pagecount+"页 [ <a href=\"javascript:homePage();\" title=\"首页\">首页</a> <a href=\"javascript:previousPage()\" title=\"上一页\">上一页</a> <a href=\"javascript:nextPage()\" title=\"下一页\">下一页</a> <a href=\"javascript:lastPage();\" title=\"最后一页\">尾页</a> ]";
break;
}
statushtml+=" 跳转到第<select name=\"goto\" onchange=\"turn(parseInt(this.value));\">";
for(var i=1;i<=this.pagecount;i++){
if (i==this._page)
statushtml+="<option value='"+i+"' selected>"+i+"</option>";
else
statushtml+="<option value='"+i+"'>"+i+"</option>";
}
statushtml+="</select>页";
if (this.pagecount!=""&&this.count!=0)
{
getObject(this._p_obj).innerHTML=statushtml;
}
}
function homePage()
{
if(this._page==1)
alert("已经是首页了!")
else
loadDate(1);
}
function lastPage()
{
if(this._page==this.pagecount)
alert("已经是最后一页了!")
else
loadDate(this.pagecount);
}
function previousPage()
{
if (this._page>1)
loadDate(this._page-1);
else
alert("已经是第一页了");
}
function nextPage()
{
if(this._page<this.pagecount)
loadDate(this._page+1);
else
alert("已经到最后一页了");
}
function turn(i)
{
loadDate(i);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -