News inside page-js pagination _javascript

Source: Internet
Author: User
Tags chr
'//Determine if the content contains this tab
If InStr (Cinfo, "[NextPage]") >0 Then
Flag=1
Else
Flag=0
End If

'//Set parameters
<script language= "Javascript" >
var Text,pagesize,flag
Text= "<%=dealjstext (cinfo)%>";
pagesize=1500;
flag=<%=flag%>;
</script>

'//js Document Package letter
<script language= "Javascript" src= "Cutarticle.js" ></script>

'//Text display
<span class= "News" >
<div id= "article" style= "FONT-SIZE:12PX;" ></div>
<script language= "JavaScript" >
if (flag==1 | | flag==2) {
Text_pagination (1);
}
else{
Article.innerhtml=text;
}
</script>
</span>

'//The following JS text processing function

function Dealjstext (STR)
If not IsNull (STR) Then
Dim Re,po,ii
str = Replace (str, CHR (9), "")
str = Replace (str, CHR (39), "'")
str = Replace (str, CHR (13), "")
str = Replace (str, CHR & CHR (), </P><P>)
str = Replace (str, CHR (10), "")
str = Replace (str, "'", "'")
str = Replace (str, "'", "'")
str = Replace (str, "\", "\ \")
str = Replace (str, CHR (32), "")
str = Replace (str, CHR (34), "\" "")
str = Replace (str, CHR (39), "'")
Set re=new REGEXP
Re. IgnoreCase =true
Re. Global=true
Po=0
Ii=0
Re. Pattern= "(JavaScript)"
Str=re. Replace (STR, "<I>javascript</I>")
Re. pattern= "(JScript:)"
Str=re. Replace (STR, "<I>jscript:</I>")
Re. Pattern= "(JS:)"
Str=re. Replace (STR, "<I>js:</I>")
Re. Pattern= "(</SCRIPT>)"
Str=re. Replace (STR, "</script>")
Re. Pattern= "(<script)"
Str=re. Replace (STR, "<script")
Dealjstext = Str
End If
End Function

'//below for JS file cutarticle.js
var currentset,cutflag,totalbyte,pagecount,key,temptext,temppage;
Key= "";
currentset=0;
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 page-Splitting
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;
Todo
{
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 Covertcrlftobr (s)
{
var i;
var s2 = s;

while (S2.indexof ("[NextPage]") >0)
{
i = S2.indexof ("[NextPage]");
S2 = s2.substring (0, I) + "" + s2.substring (i +, s2.length);
}
return S2;
}
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>";
Head function navigation bar
output=output+ "<tr>";
Body Lookup
output=output+ "<td align=left width= ' 40% ' >";
output=output+ "<input type=hidden name=keys class=ipta onchange= ' key=this.value ' size=12> <input ' Type=hidden Class=btna name=search value= ' Find the body ' onclick= ' searchkey (); ' style= ' width:60 ' > ';
output=output+ "</td>";
output=output+ "<td align=right>";
Page number display mode one
Page x: pagination title
if (page==0 | | pagecount==0) {
Output=output+ "Current is: <font color=red> full text display </font>";
}
else{
if (totalbyte>pagesize) {byte=pagenum[page]-pagenum[page-1]}else{byte=totalbyte};
output=output+ "<font color=red>" +page+ "</font> page";
if (pagetitle[page]!= "")
{
output=output+ ": <font color=800000>" +pagetitle[page]+ "</font>";
}
}
Display Mode two
Drop-down Menu Selection
if (pagecount>0)
//{
Output=output+pagenav (2,page);
output=output+ "</td>";
//}
Display Mode three
Page number selection list
output=output+ "<td align=right bgcolor= #f0faff >";
Output=output+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>";
Show Body
if (page==0) {
No paging
TEMPTEXT=COVERTCRLFTOBR (Text);
}
else{
Paging
if (flag==1)
Automatic page splitting
{
Temptext=text.substring (Pagenum[page-1],pagenum[page]);
}
else{
Manual page-Splitting
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]);
}
}
}
output=output+ "<div id=world>";
Output=output+temptext;
output=output+ "</div>";
output=output+ "<br>";
output=output+ "<div align=center>";
Output=output+pagenav (1,page);
output=output+ "</div>";

article.innerhtml = Output;
document.location.href= ' # ';
Eval (document.all.keys). Value=key;
if (key!= "") {Searchkey ();}
}

function Searchkey () {
Body Lookup function
H= "<font class=keyworld>";
F= "</font>";
Keyset=new Array ();
Key=document.all.keys.value;
if (key== "") {
Alert ("Please enter the 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 (key,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 Pagenav (showstyle,page) {
Page-Numbering display function
parameter is 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> ";}}}
for (i=1;i<pagecount+1; i++)
{
if (page==i)
{
temp=temp+ "<font color=800000>[" +i+ "]</font>";
}
else{
temp=temp+ "<a href= ' #top ' onclick=javascript:text_pagination (" +i+ ") ><font color=3366cc>[" +i+ "]</ Font></a> ";
}
}
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 ' > ' +i+ '" page "

}
else{
temp=temp+ "<option value= '" +i+ "' >" +i+ "page";
}
if (pagetitle[i].length!=0)
{
temp=temp+ ': ' +pagetitle[i];
}
temp=temp+ "</option>";
}
temp=temp+ "</select>";
}

return (temp);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.