txt.ftl
12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
<title>${file.name}普通文本预览</title>
<#include "*/commonHeader.ftl">
</head>
<body>
<input hidden id="textData" value="${textData}"/>
<#if "${file.suffix?html}" == "txt" || "${file.suffix?html}" == "log" || "${file.suffix?html}" == "TXT" || "${file.suffix?html}" == "LOG">
<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 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: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
}
.divContent
{
color:#fff;
font-size:30px;
line-height:30px;
font-family:“SimHei”;
text-indent:2em;
padding-bottom:10px;
white-space: pre-wrap; /*css-3*/
white-space: -moz-pre-wrap; /*Mozilla,since1999*/
white-space: -pre-wrap; /*Opera4-6*/
white-space: -o-pre-wrap; /*Opera7*/
word-wrap: break-word; /*InternetExplorer5.5+*/
background-color: #000;
}
</style>
<#if file.folderName?exists&&file.updateTime?exists >
<#include "*/commonFileInfoHeader.ftl">
</#if>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
${file.name}
</a>
</h4>
</div>
<div class="panel-body">
<div id="divPagenation" class="black" >
</div>
<div id="divContent" class="panel-body">
</div>
</div>
</div>
</div>
<script type="text/javascript">
var base64data = $("#textData").val()
var s = Base64.decode(base64data);
// s=s.replace(/。/g,"。<br>");
// $("#xml").hide()
//对img标签进行匹配
var imgReg = /(<img\s+src='\S+'\s*(\/)?>)/gi;
matchContent = s.match(imgReg);
imgContent = s;
if(imgReg.test(s))
{
//将img标签替换为❈
imgContent = s.replace(imgReg,"❈");
}
// 封装DHTMLpagenation
function DHTMLpagenation(content)
{
this.content=content; // 内容
this.contentLength=imgContent.length; // 内容长度
this.pageSizeCount; // 总页数
this.perpageLength= 20000; //default perpage byte length.
this.currentPage=1; // 起始页为第1页
//this.regularExp=/.+[\?\&]{1}page=(\d+)/;
this.regularExp=/\d+/; // 建立正则表达式,匹配数字型字符串。
this.divDisplayContent;
this.contentStyle=null;
this.strDisplayContent="";
this.divDisplayPagenation;
this.strDisplayPagenation="";
// 把第二个参数赋给perpageLength;
arguments.length==2 ? perpageLength = arguments[1] : '';
try {
//创建要显示的DIV
divExecuteTime=document.createElement("DIV");
document.body.appendChild(divExecuteTime);
}
catch(e)
{
}
// 得到divPagenation容器。
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;
}
}
// 得到divContent容器
if(document.getElementById("divContent"))
{
divDisplayContent=document.getElementById("divContent");
}
else
{
try
{
//创建每页显示内容的消息的DIV
divDisplayContent=document.createElement("DIV");
divDisplayContent.id="divContent";
document.body.appendChild(divDisplayContent);
}
catch(e)
{
return false;
}
}
DHTMLpagenation.initialize();
return this;
};
//初始化分页;
//包括把加入CSS,检查是否需要分页
DHTMLpagenation.initialize=function()
{
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();
};
//显示分页栏
DHTMLpagenation.displayPage=function()
{
strDisplayPagenation="";
if(currentPage && currentPage !=1)
{
strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.previous()">上一页</a> ';
}
else
{
strDisplayPagenation+="上一页 ";
}
for(var i=1;i<=pageSizeCount;i++)
{
if(i!=currentPage)
{
strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.goto('+i+');">'+i+'</a> ';
}
else
{
strDisplayPagenation+=i+" ";
}
}
if(currentPage && currentPage!=pageSizeCount)
{
strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.next()">下一页</a> ';
}
else
{
strDisplayPagenation+="下一页 ";
}
strDisplayPagenation+="共 " + pageSizeCount + " 页。<br>每页" + perpageLength + " 字符,调整字符数:<input type='text' value='"+perpageLength+"' id='ctlPerpageLength' /><input type='button' value='确定' onclick='DHTMLpagenation.change()' />";
divDisplayPagenation.innerHTML=strDisplayPagenation;
};
//上一页
DHTMLpagenation.previous=function()
{
DHTMLpagenation.goto(currentPage-1);
};
//下一页
DHTMLpagenation.next=function()
{
DHTMLpagenation.goto(currentPage+1);
};
//跳转至某一页
DHTMLpagenation.goto=function(iCurrentPage)
{
startime=new Date();
if(regularExp.test(iCurrentPage))
{
currentPage=iCurrentPage;
var tempContent = "";
//获取当前的内容 里面包含 ❈
var currentContent = imgContent.substr((currentPage-1)*perpageLength,perpageLength);
tempContent = currentContent;
//当前页是否有 ❈ 获取最后一个 ❈ 的位置
var indexOf = currentContent.indexOf("❈");
if(indexOf >= 0)
{
//获取从开始位置到当前页位置的内容
var beginToEndContent = imgContent.substr(0,currentPage*perpageLength);
//获取开始到当前页位置的内容 中的 * 的最后的下标
var reCount = beginToEndContent.split("❈").length - 1;
var contentArray = currentContent.split("❈");
tempContent = replaceStr(contentArray,reCount,matchContent);
}
// else
// {
// tempContent=imgContent.substr((currentPage-1)*perpageLength,perpageLength);
// }
strDisplayContent=tempContent;
}
else
{
alert("页面参数错误");
}
DHTMLpagenation.displayPage();
DHTMLpagenation.displayContent();
};
//显示当前页内容
DHTMLpagenation.displayContent=function()
{
divDisplayContent.innerHTML=strDisplayContent;
};
//改变每页的字节数
DHTMLpagenation.change=function()
{
var iPerpageLength = document.getElementById("ctlPerpageLength").value;
if(regularExp.test(iPerpageLength))
{
// DHTMLpagenation.perpageLength=iPerpageLength;
// DHTMLpagenation.currentPage=1;
// DHTMLpagenation.initialize();
DHTMLpagenation(s,iPerpageLength);
}
else
{
alert("请输入数字");
}
};
/* currentArray:当前页以 * 分割后的数组
replaceCount:从开始内容到当前页的内容 * 的个数
matchArray : img标签的匹配的内容
*/
function replaceStr(currentArray,replaceCount,matchArray)
{
var result = "";
for(var i=currentArray.length -1,j = replaceCount-1 ;i>=1; i--)
{
var temp = (matchArray[j] + currentArray[i]);
result = temp + result;
j--;
}
result = currentArray[0] + result ;
return result;
}
DHTMLpagenation(s,20000);
/**
* 初始化
*/
window.onload = function () {
initWaterMark();
}
</script>
<#else/>
<#if file.folderName?exists&&file.updateTime?exists >
<#include "*/commonFileInfoHeader.ftl">
</#if>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
${file.name}
</a>
</h4>
</div>
<div class="panel-body">
<div id="text"></div>
</div>
</div>
</div>
<script>
/**
*加载普通文本
*/
function loadText() {
var base64data = $("#textData").val()
var textData = Base64.decode(base64data);
var textPreData = "<xmp style='background-color: #FFFFFF;overflow-y: scroll;border:none'>" + textData + "</xmp>";
$("#text").append(textPreData);
}
/**
* 初始化
*/
window.onload = function () {
initWaterMark();
loadText();
}
</script>
</#if>
</body>
</html>