js| Pagination | client
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<meta name= "generator" content= "EditPlus" >
<meta name= "Author" content= "" >
<meta name= "Keywords" content= "" >
<meta name= "Description" content= "" >
<style>
* {
font-size:10.2pt;
Font-family:tahoma;
line-height:150%;
}
. divcontent
{
border:1px solid red;
Background-color: #FFD2D3;
width:500px;
Word-break:break-all;
margin:10px 0px 10px;
padding:10px;
}
</style>
</HEAD>
<BODY>
Header
<div id= "Divpagenation" ></div>
<div id= "Divcontent" ></div>
Footer
<script language= "JavaScript" >
<!--
S= "<p> The female teacher tried hard to prove to the children the importance of learning good lessons. </p><p> She said: "Newton sat under the tree, his eyes fixed on the tree, and there was an apple falling on his head, and he discovered the law of gravitation, children, think about how good and how wonderful it is to be a great scientist. You must study hard. A naughty Ghost in the "</p><p>" class was not satisfied with it. He said: "Maybe so, but if he sits in the school and buries himself in the book, he will find nothing." </p><p> teachers are trying to prove to their children the importance of learning good lessons. </p><p> She said: "Newton sat under the tree, his eyes fixed on the tree, and there was an apple falling on his head, and he discovered the law of gravitation, children, think about how good and how wonderful it is to be a great scientist. You must study hard. A naughty Ghost in the "</p><p>" class was not satisfied with it. He said: "Maybe so, but if he sits in the school and buries himself in the book, he will find nothing." </p><p> teachers are trying to prove to their children the importance of learning good lessons. </p><p> She said: "Newton sat under the tree, his eyes fixed on the tree, and there was an apple falling on his head, and he discovered the law of gravitation, children, think about how good and how wonderful it is to be a great scientist. You must study hard. A naughty Ghost in the "</p><p>" class was not satisfied with it. He said: "Maybe so, but if he sits in the school and buries himself in the book, he will find nothing." </p><p> teachers are trying to prove to their children the importance of learning good lessons. </p><p> She said: "Newton sat under the tree, his eyes fixed on the tree, and there was an apple falling on his head, and he discovered the law of gravitation, children, think about how good and how wonderful it is to be a great scientist. You must study hard. A naughty Ghost in the "</p><p>" class was not satisfied with it. He said: "Maybe so, but if he sits in the school and buries himself in the book, he will find nothing." </p><p> teachers are trying to prove to their children the importance of learning good lessons. </p><p> She said: "Newton sat under the tree, his eyes fixed on the tree thinking, when, an Apple fell on his head, so he discovered the law of gravitation, children, think about it, how good and how wonderful it is to be a great scientist, if you want to do this, you must study hard. A naughty Ghost in the "</p><p>" class was not satisfied with it. He said: "Maybe so, but if he sits in the school and buries himself in the book, he will find nothing." "</p>";
Encapsulation Dhtmlpagenation
function Dhtmlpagenation (content) {with (this)
{
Client static HTML file pagenation
Scipit by Bluedestiny,never-online, www.never-online.net
This.content=content; Content
This.contentlength=content.length; Content length
This.pagesizecount; Total pages
this.perpagelength=100; Default Perpage byte length.
this.currentpage=1; Start Page is 1th page
This.regularexp=/.+[\?\&]{1}page= (\d+)/;
this.regularexp=/\d+/; Establishes a regular expression that matches a numeric string.
This.divdisplaycontent;
This.contentstyle=null;
This.strdisplaycontent= "";
This.divdisplaypagenation;
This.strdisplaypagenation= "";
Assigning the second parameter to Perpagelength;
ARGUMENTS.LENGTH==2?PERPAGELENGTH=ARGUMENTS[1]: ';
try {
Divexecutetime=document.createelement ("DIV");
Document.body.appendChild (Divexecutetime);
}
catch (E)
{
}
Get the Divpagenation container.
if (document.getElementById ("Divpagenation"))
{
Divdisplaypagenation=document.getelementbyid ("Divpagenation");
}
Else
{
Try
{
Divdisplaypagenation=document.createelement ("DIV");
Divdisplaypagenation.id= "Divpagenation";
Document.body.appendChild (divdisplaypagenation);
}
catch (E)
{
return false;
}
}
Get Divcontent Container
if (document.getElementById ("Divcontent"))
{
Divdisplaycontent=document.getelementbyid ("Divcontent");
}
Else
{
Try
{
Divdisplaycontent=document.createelement ("DIV");
Divdisplaycontent.id= "Divcontent";
Document.body.appendChild (divdisplaycontent);
}
catch (E)
{
return false;
}
}
Dhtmlpagenation.initialize ();
return this;
}};
Initialize the paging;
Include adding CSS to check if paging is required
Dhtmlpagenation.initialize=function () {with (this)
{
Divdisplaycontent.classname=contentstyle!=null?contentstyle: "Divcontent";
if (contentlength<=perpagelength)
{
Strdisplaycontent=content;
Divdisplaycontent.innerhtml=strdisplaycontent;
return null;
}
Pagesizecount=math.ceil ((contentlength/perpagelength));
Dhtmlpagenation.goto (currentpage);
Dhtmlpagenation.displaycontent ();
}};
Show Page Bar
Dhtmlpagenation.displaypage=function () {with (this)
{
strdisplaypagenation= "pagination:";
if (currentpage&¤tpage!=1)
strdisplaypagenation+= ' <a href= javascript:void (0) "> Prev </a>";
Else
strdisplaypagenation+= "Previous page";
for (Var i=1;i<=pagesizecount;i++)
{
if (i!=currentpage)
strdisplaypagenation+= ' <a href= ' javascript:void (0) ' > ' +i+ ' </a> ';
Else
strdisplaypagenation+=i+ "";
}
if (Currentpage&¤tpage!=pagesizecount)
strdisplaypagenation+= ' <a href= "javascript:void (0)" > Next </a> ';
Else
strdisplaypagenation+= "Next page";
strdisplaypagenation+= "Total" + pagesizecount + "page, per page" + perpagelength + "character, adjust the number of characters: <input type= ' text ' value= '" +perpagele ngth+ "' id= ' ctlperpagelength ' ><input type= ' button ' value= ' Determine ' onclick= ' Dhtmlpagenation.change ( document.getElementById (\ "Ctlperpagelength\"). value); ' > ";
Divdisplaypagenation.innerhtml=strdisplaypagenation;
}};
Previous page
Dhtmlpagenation.previous=function () {with (this)
{
Dhtmlpagenation.goto (currentPage-1);
}};
Next page
Dhtmlpagenation.next=function () {with (this)
{
Dhtmlpagenation.goto (currentpage+1);
}};
Jump to a page
Dhtmlpagenation.goto=function (Icurrentpage) {with (this)
{
Startime=new Date ();
if (Regularexp.test (icurrentpage))
{
Currentpage=icurrentpage;
Strdisplaycontent=content.substr ((currentPage-1) *perpagelength,perpagelength);
}
Else
{
Alert ("page parameter error!");
}
Dhtmlpagenation.displaypage ();
Dhtmlpagenation.displaycontent ();
}};
Show current page content
Dhtmlpagenation.displaycontent=function () {with (this)
{
Divdisplaycontent.innerhtml=strdisplaycontent;
}};
Change the number of bytes per page
Dhtmlpagenation.change=function (Iperpagelength) {with (this)
{
if (Regularexp.test (iperpagelength))
{
Dhtmlpagenation.perpagelength=iperpagelength;
dhtmlpagenation.currentpage=1;
Dhtmlpagenation.initialize ();
}
Else
{
Alert ("Please enter a number");
}
}};
Interface API
Dhtmlpagenation (Strcontent[,perpagelength])
Dhtmlpagenation (s,100);
Power by Bluedestiny,never-online
-->
</SCRIPT>
</BODY>
</HTML>