!231 修复txt文本类 分页二次加载问题

Merge pull request !231 from 高雄/N/A
pull/236/head
kailing 1 year ago committed by Gitee
commit 7e0f7f6608
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -14,7 +14,7 @@
<input hidden id="textData" value="${textData}"/> <input hidden id="textData" value="${textData}"/>
<#if "${file.suffix?html}" == "txt" || "${file.suffix?html}" == "log" || "${file.suffix?html}" == "TXT" || "${file.suffix?html}" == "LOG"> <#if "${file.suffix?html}" == "txt" || "${file.suffix?html}" == "log" || "${file.suffix?html}" == "TXT" || "${file.suffix?html}" == "LOG">
<style type="text/css"> <style type="text/css">
DIV.black{line-height:25px;PADDING-RIGHT:1px;PADDING-LEFT:1px;FONT-SIZE:100%;MARGIN:1px;COLOR:#fff;BACKGROUND-COLOR:#000;TEXT-ALIGN:left} DIV.black{line-height:25px;PADDING-RIGHT:1px;PADDING-LEFT:1px;FONT-SIZE:100%;MARGIN:1px;COLOR:#909090;BACKGROUND-COLOR:#000;TEXT-ALIGN:left}
DIV.black A{BORDER-RIGHT:#909090 1px solid;PADDING-RIGHT:5px;BACKGROUND-POSITION:50% bottom;BORDER-TOP:#909090 1px solid;PADDING-LEFT:5px;BACKGROUND-IMAGE:url();PADDING-BOTTOM:2px;BORDER-LEFT:#909090 1px solid;COLOR:#fff;MARGIN-RIGHT:3px;PADDING-TOP:2px;BORDER-BOTTOM:#909090 1px solid;TEXT-DECORATION:none} DIV.black A{BORDER-RIGHT:#909090 1px solid;PADDING-RIGHT:5px;BACKGROUND-POSITION:50% bottom;BORDER-TOP:#909090 1px solid;PADDING-LEFT:5px;BACKGROUND-IMAGE:url();PADDING-BOTTOM:2px;BORDER-LEFT:#909090 1px solid;COLOR:#fff;MARGIN-RIGHT:3px;PADDING-TOP:2px;BORDER-BOTTOM:#909090 1px solid;TEXT-DECORATION:none}
DIV.black A:hover{BORDER-RIGHT:#f0f0f0 1px solid;BORDER-TOP:#f0f0f0 1px solid;BACKGROUND-IMAGE:BORDER-LEFT:#f0f0f0 1px solid;COLOR:#ffffff;BORDER-BOTTOM:#f0f0f0 1px solid;BACKGROUND-COLOR:#404040} DIV.black A:hover{BORDER-RIGHT:#f0f0f0 1px solid;BORDER-TOP:#f0f0f0 1px solid;BACKGROUND-IMAGE:BORDER-LEFT:#f0f0f0 1px solid;COLOR:#ffffff;BORDER-BOTTOM:#f0f0f0 1px solid;BACKGROUND-COLOR:#404040}
DIV.black A:active{BORDER-RIGHT:#f0f0f0 1px solid;BORDER-TOP:#f0f0f0 1px solid;BACKGROUND-IMAGE:BORDER-LEFT:#f0f0f0 1px solid;COLOR:#ffffff;BORDER-BOTTOM:#f0f0f0 1px solid;BACKGROUND-COLOR:#404040} DIV.black A:active{BORDER-RIGHT:#f0f0f0 1px solid;BORDER-TOP:#f0f0f0 1px solid;BACKGROUND-IMAGE:BORDER-LEFT:#f0f0f0 1px solid;COLOR:#ffffff;BORDER-BOTTOM:#f0f0f0 1px solid;BACKGROUND-COLOR:#404040}
@ -47,14 +47,9 @@ background-color:#000000
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var base64data = $("#textData").val() var base64data = $("#textData").val()
var s = Base64.decode(base64data); var s = Base64.decode(base64data);
// s=s.replace(/。/g,"。<br>");
// $("#xml").hide()
//对img标签进行匹配
var imgReg = /(<img\s+src='\S+'\s*(\/)?>)/gi; var imgReg = /(<img\s+src='\S+'\s*(\/)?>)/gi;
matchContent = s.match(imgReg); matchContent = s.match(imgReg);
imgContent = s; imgContent = s;
@ -63,18 +58,16 @@ background-color:#000000
//将img标签替换为❈ //将img标签替换为❈
imgContent = s.replace(imgReg,"❈"); imgContent = s.replace(imgReg,"❈");
} }
var Length= 20000;
// 封装DHTMLpagenation // 封装DHTMLpagenation
function DHTMLpagenation(content) function DHTMLpagenation(content)
{ {
this.content=content; // 内容 this.content=content; // 内容
this.contentLength=imgContent.length; // 内容长度 this.contentLength=imgContent.length; // 内容长度
this.pageSizeCount; // 总页数 this.pageSizeCount; // 总页数
this.perpageLength= 20000; //default perpage byte length. this.perpageLength= Length; //default perpage byte length.
this.currentPage=1; // 起始页为第1页 this.currentPage=1; // 起始页为第1页
//this.regularExp=/.+[\?\&]{1}page=(\d+)/;
this.regularExp=/\d+/; // 建立正则表达式,匹配数字型字符串。 this.regularExp=/\d+/; // 建立正则表达式,匹配数字型字符串。
this.divDisplayContent; this.divDisplayContent;
this.contentStyle=null; this.contentStyle=null;
this.strDisplayContent=""; this.strDisplayContent="";
@ -132,7 +125,6 @@ background-color:#000000
return false; return false;
} }
} }
DHTMLpagenation.initialize(); DHTMLpagenation.initialize();
return this; return this;
@ -142,7 +134,6 @@ background-color:#000000
//包括把加入CSS检查是否需要分页 //包括把加入CSS检查是否需要分页
DHTMLpagenation.initialize=function() DHTMLpagenation.initialize=function()
{ {
divDisplayContent.className= contentStyle != null ? contentStyle : "divContent"; divDisplayContent.className= contentStyle != null ? contentStyle : "divContent";
if(contentLength<=perpageLength) if(contentLength<=perpageLength)
@ -159,15 +150,14 @@ background-color:#000000
DHTMLpagenation.displayContent(); DHTMLpagenation.displayContent();
}; };
//显示分页栏 //显示分页栏
DHTMLpagenation.displayPage=function() DHTMLpagenation.displayPage=function()
{ {
strDisplayPagenation=""; strDisplayPagenation="";
if(currentPage && currentPage !=1) if(currentPage && currentPage !=1)
{ {
strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.previous()"></a> ';
strDisplayPagenation+='<button onclick="DHTMLpagenation.previous()"></button>';
} }
else else
{ {
@ -178,7 +168,8 @@ background-color:#000000
{ {
if(i!=currentPage) if(i!=currentPage)
{ {
strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.goto('+i+');">'+i+'</a> ';
strDisplayPagenation+='<button onclick="DHTMLpagenation.goto('+i+');">'+i+'</button>';
} }
else else
{ {
@ -188,18 +179,14 @@ background-color:#000000
if(currentPage && currentPage!=pageSizeCount) if(currentPage && currentPage!=pageSizeCount)
{ {
strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.next()"></a> '; strDisplayPagenation+='<button onclick="DHTMLpagenation.next()"></button>';
} }
else else
{ {
strDisplayPagenation+="下一页 "; strDisplayPagenation+="下一页 ";
} }
strDisplayPagenation+="共 " + pageSizeCount + " 页。<br>每页" + perpageLength + " 字符,调整字符数:<input type='text' value='"+perpageLength+"' id='ctlPerpageLength' /><input type='button' value='确定' onclick='DHTMLpagenation.change()' />";
strDisplayPagenation+="共 " + pageSizeCount + " 页。<br>每页" + perpageLength + " 字符,调整字符数:<input type='text' value='"+perpageLength+"' id='ctlPerpageLength' /><input type='button' value='确定' onclick='DHTMLpagenation.change()' />"; divDisplayPagenation.innerHTML=strDisplayPagenation;
divDisplayPagenation.innerHTML=strDisplayPagenation;
}; };
//上一页 //上一页
@ -218,21 +205,16 @@ background-color:#000000
//跳转至某一页 //跳转至某一页
DHTMLpagenation.goto=function(iCurrentPage) DHTMLpagenation.goto=function(iCurrentPage)
{ {
startime=new Date();
if(regularExp.test(iCurrentPage)) if(regularExp.test(iCurrentPage))
{ {
currentPage=iCurrentPage; currentPage=iCurrentPage;
var tempContent = ""; var tempContent = "";
//获取当前的内容 里面包含 ❈ //获取当前的内容 里面包含 ❈
var currentContent = imgContent.substr((currentPage-1)*perpageLength,perpageLength); var currentContent = imgContent.substr((currentPage-1)*perpageLength,perpageLength);
tempContent = currentContent; tempContent = currentContent;
//当前页是否有 ❈ 获取最后一个 ❈ 的位置 //当前页是否有 ❈ 获取最后一个 ❈ 的位置
var indexOf = currentContent.indexOf("❈"); var indexOf = currentContent.indexOf("❈");
if(indexOf >= 0) if(indexOf >= 0)
{ {
//获取从开始位置到当前页位置的内容 //获取从开始位置到当前页位置的内容
@ -246,10 +228,6 @@ background-color:#000000
tempContent = replaceStr(contentArray,reCount,matchContent); tempContent = replaceStr(contentArray,reCount,matchContent);
} }
// else
// {
// tempContent=imgContent.substr((currentPage-1)*perpageLength,perpageLength);
// }
strDisplayContent=tempContent; strDisplayContent=tempContent;
} }
@ -274,10 +252,6 @@ background-color:#000000
if(regularExp.test(iPerpageLength)) if(regularExp.test(iPerpageLength))
{ {
// DHTMLpagenation.perpageLength=iPerpageLength;
// DHTMLpagenation.currentPage=1;
// DHTMLpagenation.initialize();
DHTMLpagenation(s,iPerpageLength); DHTMLpagenation(s,iPerpageLength);
} }
else else
@ -292,7 +266,6 @@ background-color:#000000
*/ */
function replaceStr(currentArray,replaceCount,matchArray) function replaceStr(currentArray,replaceCount,matchArray)
{ {
var result = ""; var result = "";
for(var i=currentArray.length -1,j = replaceCount-1 ;i>=1; i--) for(var i=currentArray.length -1,j = replaceCount-1 ;i>=1; i--)
{ {
@ -308,10 +281,8 @@ background-color:#000000
return result; return result;
} }
DHTMLpagenation(s,Length);
DHTMLpagenation(s,20000);
/** /**
* *
@ -319,11 +290,8 @@ background-color:#000000
window.onload = function () { window.onload = function () {
initWaterMark(); initWaterMark();
} }
</script> </script>
<#else/> <#else/>
<div class="container"> <div class="container">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
@ -359,8 +327,5 @@ background-color:#000000
} }
</script> </script>
</#if> </#if>
</body> </body>
</html> </html>

Loading…
Cancel
Save