// The number of words displayed on each page
Pagesize = 5000;
// Paging Mode
Flag = 2; // 1: Automatic paging Based on words 2: Paging based on [nextpage]
// Renewal page
Startpage = 1;
// Navigation display style 0: Regular 1: Direct 3: drop-down
Topshowstyle = 1;
Downshowstyle = 0;
VaR currentset, cutflag, totalbyte, pagecount, key, temptext, temppage;
Key = "";
Currentset = 0;
VaR text = xmlarticle. selectsinglenode ("// content"). text;
Totalbyte = text. length;
If (flag = 1)
{
Pagecount = math. Round (totalbyte/pagesize );
If (parsefloat ("0." + totalbyte % pagesize)> 0 ){
If (parsefloat ("0." + totalbyte % pagesize) <0.5 ){
Pagecount = pagecount + 1;
}
}
VaR pagenum = new array (pagecount + 1 );
VaR pagetitle = new array (pagecount + 1 );
Pagenum [0] = 0;
Pagetitle [0] = "";
VaR sdrv1, sdrv2, sdrv3, sdrv4, sflag;
VaR sdrvl, steml;
VaR stem1, stem2, K;
Sflag = 0;
For (j = 1; j <pagecount + 1; j ++ ){
Pagenum [J] = pagenum [J-1] + pagesize;
Pagetitle [J] = "";
// Alert (j );
Sdrv1 = "<br> ";
Sdrv2 = "<br> ";
Sdrv3 = "<br> ";
Sdrv4 = "<br> ";
Sdrvl = sdrv1.length;
For (k = pagenum [J]; k <= totalbyte; k ++ ){
Stem1 = text. substring (pagenum [J]-sdrvl, k );
Steml = stem1.length;
Stem2 = stem1.substring (steml-sdrvl, steml)
If (stem2 = sdrv1 | stem2 = sdrv2 | stem2 = sdrv3 | stem2 = sdrv4)
{
Sflag = sflag + 1;
Pagenum [J] = K;
Break;
}
}
If (pagenum [J]> totalbyte)
{
Break;
}
}
If (j <pagecount)
{
Pagenum. Length = J;
Pagecount = J
}
If (pagecount> 1 & sflag> 1 & pagecount <sflag)
{
Pagecount = sflag + 1;
}
}
Else {
// Manual Paging
VaR J, sflag, pagecount, stext;
VaR stitleflag;
VaR pagenum = new array ();
VaR pagetitle = new array ();
Pagesize = 0;
J = 1;
Pagenum [0] =-10;
Pagetitle [0] = "";
Sflag = 0;
Stext = text;
Do
{
Stext = text. substring (pagenum [J-1] + 10, totalbyte );
Sflag = stext. indexof ("[nextpage ");
If (stext. substring (sflag + 9, sflag + 10) = "= ")
{
Stitleflag = stext. indexof ("]", sflag );
Pagetitle [J] = stext. substring (sflag + 10, stitleflag );
}
Else {
Pagetitle [J] = "";
}
If (sflag> 0)
{
Pagenum [J] = sflag + pagenum [J-1] + 10;
}
Else {
Pagenum [J] = totalbyte;
}
J + = 1;
}
While (pagenum [J-1] <totalbyte );
Pagecount = J-1;
}
Function text_pagination (PAGE ){
VaR output, byte;
If (page = NULL) {page = 1 ;}
Output = "";
Output = output + "<Table width = 100% Height = 30 border = 0 align = center cellpadding = 0 cellspacing = 0> ";
Output = output + "<tr> ";
Output = output + "<TD Height = 1 Background = images/dotline.gif> </TD> ";
Output = output + "</tr> ";
// Navigation bar of the header Function
Output = output + "<tr> ";
// Search the text
Output = output + "<TD align = left bgcolor = # f0faff width = '000000'> & nbsp ;";
Output = output + "<input type = text name = keys onchange = 'key = this. value 'size = 12> & nbsp; <input type = button name = SEARCH value = 'search body 'onclick = 'searchkey (); 'style = 'width: 60'> ";
Output = output + "</TD> ";
Output = output + "<TD align = right bgcolor = # f0faff> ";
// Page number display method 1
// Page X: page title
If (page = 0 | pagecount = 0 ){
Output = output + "Current: <font color = Red> full text display </font> ";
}
Else {
If (totalbyte> pagesize) {byte = pagenum [Page]-pagenum [page-1]} else {byte = totalbyte };
Output = output + "page <font color = Red>" + Page + "</font> ";
If (pagetitle [Page]! = "")
{
Output = output + ": <font color = 800000>" + pagetitle [Page] + "</font> ";
}
Output + = '& nbsp ;';
}
// Display method 2
// Select from the drop-down menu
// If (pagecount> 0)
//{
// Output = output + article_pagenav (2, page );
// Output = output + "& nbsp; </TD> ";
//}
// Display Mode 3
// Page number selection list
// Output = output + "<TD align = right bgcolor = # f0faff> ";
// Output = output + article_pagenav (0, page );
// Output = output + "</TD> ";
Output = output + "</tr> ";
Output = output + "<tr> ";
Output = output + "<TD Height = 1 Background = images/dotline.gif> </TD> ";
Output = output + "</tr> ";
Output = output + "</table> ";
// Display the body
If (page = 0 ){
// No Paging
Temptext = text;
}
Else {
// Pagination
If (flag = 1)
// Automatic Paging
{
Temptext = text. substring (pagenum [page-1], pagenum [Page]);
}
Else {
// Manual Paging
If (pagetitle [page-1]. Length = 0)
{
Temptext = text. substring (pagenum [page-1] + 10, pagenum [Page]);
}
Else {
Temptext = text. substring (pagenum [page-1] + 11 + pagetitle [page-1]. length, pagenum [Page]);
}
}
}
// Layout content
Output = output + "<Div align = center> ";
Output = output + article_pagenav (topshowstyle, page );
Output = output + "</div> ";
Output = output + "<Div id = World> ";
Output = output + temptext;
Output = output + "</div> ";
Output = output + "<br> ";
Output = output + "<Div align = center> ";
Output = output + article_pagenav (downshowstyle, page );
Output = output + "</div> ";
Article. innerhtml = output;
If (page> 1)
{
Document. Location. href = '# Top ';
}
Eval (document. All. Keys). value = key;
If (key! = "") {Searchkey ();}
}
Function searchkey (){
// Body search function
H = "<font class = keyworld> ";
F = "</font> ";
Keyset = new array ();
Key = Document. All. Keys. value;
If (Key = ""){
Alert ("enter a keyword! ");
Return;
}
Else {
Keyset [0] = temptext. indexof (Key, 0 );
If (keyset [0] <0 ){
Return;
} Else
Temp = temptext. substring (0, keyset [0]);
Temp = temp + H + key + F;
Temp2 = temptext. substring (keyset [0] + key. length, temptext. Length );
For (I = 1; I <temptext. length; I ++ ){
Keyset [I] = temptext. indexof (keys, keyset [I-1] + key. Length );
If (keyset [I] <0 ){
Temp = temp + temptext. substring (keyset [I-1] + key. length, temptext. Length );
Break;
} Else {
Temp = temp + temptext. substring (keyset [I-1] + key. length, keyset [I]) + H + key + F;
}
}
World. innerhtml = temp;
}
}
Function article_pagenav (showstyle, page ){
// Display functions by page number
// The parameter is a call style, 0 = simple style, 1 = standard style
VaR temp = "";
If (showstyle = 0)
// Simple style
{
Temppage = page;
If (totalbyte> pagesize ){
If (page-4 <= 1 ){
Temp = temp + "<font face = webdings color = #999999> 9 </font> ";
If (page <= 1) {temp = temp + "<font face = webdings color = #999999> 7 </font> ";} else {temp = temp + "<a href = javascript: text_pagination (" + (page-1) + ")> <font face = webdings> 7 </font> </a> ";}
If (pagecount> 10 ){
For (I = 1; I <8; I ++ ){
If (I = page ){
Temp = temp + "<font color = Red>" + I + "</font> ";
} Else {
Temp = temp + "<a href = javascript: text_pagination (" + I + ")>" + I + "</a>" + "";
}
}
Temp = temp + "...";
}
Else {
For (I = 1; I <pagecount + 1; I ++ ){
If (I = page ){
Temp = temp + "<font color = Red>" + I + "</font> ";
}
Else {
Temp = temp + "<a href = javascript: text_pagination (" + I + ")>" + I + "</a>" + "";
}
}
}
If (page = pagecount) {temp = temp + "<font face = webdings color = #999999> 8 </font> ";} else {temp = temp + "<a href = javascript: text_pagination (" + (page + 1) + ")> <font face = webdings> 8 </font> </a> ";}
If (pagecount <10) {temp = temp + "<font face = webdings color = #999999 >:</font> ";} else {temp = temp + "<a href = javascript: text_pagination (" + pagecount + ")> <font face = webdings >:</font> </a> ";}
}
Else if (page + 4 <= pagecount ){
Temp = temp + "<a href = javascript: text_pagination (1)> <font face = webdings> 9 </font> </a> ";
Temp = temp + "<a href = javascript: text_pagination (" + (page-1) + ")> <font face = webdings> 7 </font> </a> ";
If (pagecount> 10 ){
Temp = temp + "..";
For (I = page-4; I <page + 4; I ++ ){
If (I = page ){
Temp = temp + "<font color = Red>" + I + "</font> ";
}
Else {
Temp = temp + "<a href = javascript: text_pagination (" + I + ")>" + I + "</a>" + "";
}
}
Temp = temp + "..";
}
Else {
For (I = 1; I <pagecount + 1; I ++ ){
If (I = page ){
Temp = temp + "<font color = Red>" + I + "</font> ";
}
Else {
Temp = temp + "<a href = javascript: text_pagination (" + I + ")>" + I + "</a>" + "";
}
}
}
If (page = pagecount) {temp = temp + "<font face = webdings color = #999999> 8 </font> ";} else {temp = temp + "<a href = javascript: text_pagination (" + (page + 1) + ")> <font face = webdings> 8 </font> </a> ";}
Temp = temp + "<a href = javascript: text_pagination (" + pagecount + ")> <font face = webdings >:</font> </a> ";
}
Else {
Temp = temp + "<a href = javascript: text_pagination (1)> <font face = webdings> 9 </font> </a> ";
Temp = temp + "<a href = javascript: text_pagination (" + (page-1) + ")> <font face = webdings> 7 </font> </a> ";
Temp = temp + ".."
For (I = page-2; I <pagecount + 1; I ++ ){
If (I = page ){
Temp = temp + "<font color = Red>" + I + "</font> ";
}
Else {
Temp = temp + "<a href = javascript: text_pagination (" + I + ")>" + I + "</a>" + "";
}
}
If (page = pagecount) {temp = temp + "<font face = webdings color = #999999> 8 </font> ";} else {temp = temp + "<a href = javascript: text_pagination (" + (page + 1) + ")> <font face = webdings> 8 </font> </a> ";}
Temp = temp + "<font face = webdings color = #999999 >:</font> ";
}
}
Else {
Temp = temp + "<font color = Red> 1 </font> ";
}
Temp = temp + "<a href = javascript: text_pagination (0)> show all </a>"
}
Else if (showstyle = 1)
// Standard style
{
If (totalbyte> pagesize) {If (page! = 0) {If (page! = 1) {temp = temp + "<a href = '# top 'onclick = javascript: text_pagination (" + (page-1) + ")> <font color = 3366cc> [Previous Page] </font> </a> & nbsp ;";}}}
For (I = 1; I <pagecount + 1; I ++)
{
If (page = I)
{
Temp = temp + "<font color = 800000> [" + I + "] </font> & nbsp ;";
}
Else {
Temp = temp + "<a href = '# top 'onclick = javascript: text_pagination (" + I + ")> <font color = 3366cc> ["+ I +"] </font> </a> & nbsp ;";
}
}
Temp = temp + "<a name = 'foot'> </a> ";
If (totalbyte> pagesize) {If (page! = 0) {If (page! = Pagecount) {temp = temp + "<a href = '# top 'onclick = javascript: text_pagination (" + (page + 1) + ")> <font color = 3366cc> [Next Page] </font> </a> ";}}}
Temp = temp + "<a href = javascript: text_pagination (0)> <font color = 3366cc> show all </font> </a>"
}
Else if (showstyle = 2)
// Drop-down menu style
{
Temp = temp + '<select onchange = "text_pagination (this. Value)">'
For (I = 1; I <pagecount + 1; I ++)
{
If (page = I)
{
Temp = temp + "<option value = '" + I + "'selected style = 'color: red'> page" + I +"
}
Else {
Temp = temp + "<option value = '" + I + "'> page" + I + ";
}
If (pagetitle [I]. length! = 0)
{
Temp = temp + ':' + pagetitle [I];
}
Temp = temp + "</option> ";
}
Temp = temp + "</SELECT> ";
}
Return (temp );
}
// Renewal page
Text_pagination (startpage );
The callback page JavaScript code ends.
--------------------------- HTML page, calling paging JS
<HTML> <Meta http-equiv = Content-Type content = "text/html; charset = gb2312">
</Head>
<Body bottommargin = 0 leftmargin = 0 topmargin = 0 rightmargin = 0>
<Table cellspacing = 1 cellpadding = 5 width = "95%" align = center
Border = 0>
<Tbody>
<Tr>
<TD>
<XML id = xmlarticle>
<Article>
<Info>
<Content>
<! [CDATA [
Let's test the paging process ~~~~~ [Nextpage] My score ~~~ [Nextpage] [nextpage] Again
]>
</Content>
</INFO>
</Article>
</XML>
<! -- Text paging JS -->
<Script language = Javascript
Src = "Attachments/month_0607/j200674214834.js"> </SCRIPT>
</TD> </tr> </tbody> </table> </TD> </tr>
</Tbody> </table>