mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-05-14 02:37:06 +00:00
新增 页码定位 美化前端 其他功能调整等
This commit is contained in:
234
server/src/main/resources/static/js/aes.js
Normal file
234
server/src/main/resources/static/js/aes.js
Normal file
@@ -0,0 +1,234 @@
|
||||
;(function (root, factory, undef) {
|
||||
if (typeof exports === "object") {
|
||||
// CommonJS
|
||||
module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
// AMD
|
||||
define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
|
||||
}
|
||||
else {
|
||||
// Global (browser)
|
||||
factory(root.CryptoJS);
|
||||
}
|
||||
}(this, function (CryptoJS) {
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var BlockCipher = C_lib.BlockCipher;
|
||||
var C_algo = C.algo;
|
||||
|
||||
// Lookup tables
|
||||
var SBOX = [];
|
||||
var INV_SBOX = [];
|
||||
var SUB_MIX_0 = [];
|
||||
var SUB_MIX_1 = [];
|
||||
var SUB_MIX_2 = [];
|
||||
var SUB_MIX_3 = [];
|
||||
var INV_SUB_MIX_0 = [];
|
||||
var INV_SUB_MIX_1 = [];
|
||||
var INV_SUB_MIX_2 = [];
|
||||
var INV_SUB_MIX_3 = [];
|
||||
|
||||
// Compute lookup tables
|
||||
(function () {
|
||||
// Compute double table
|
||||
var d = [];
|
||||
for (var i = 0; i < 256; i++) {
|
||||
if (i < 128) {
|
||||
d[i] = i << 1;
|
||||
} else {
|
||||
d[i] = (i << 1) ^ 0x11b;
|
||||
}
|
||||
}
|
||||
|
||||
// Walk GF(2^8)
|
||||
var x = 0;
|
||||
var xi = 0;
|
||||
for (var i = 0; i < 256; i++) {
|
||||
// Compute sbox
|
||||
var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
|
||||
sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
|
||||
SBOX[x] = sx;
|
||||
INV_SBOX[sx] = x;
|
||||
|
||||
// Compute multiplication
|
||||
var x2 = d[x];
|
||||
var x4 = d[x2];
|
||||
var x8 = d[x4];
|
||||
|
||||
// Compute sub bytes, mix columns tables
|
||||
var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
|
||||
SUB_MIX_0[x] = (t << 24) | (t >>> 8);
|
||||
SUB_MIX_1[x] = (t << 16) | (t >>> 16);
|
||||
SUB_MIX_2[x] = (t << 8) | (t >>> 24);
|
||||
SUB_MIX_3[x] = t;
|
||||
|
||||
// Compute inv sub bytes, inv mix columns tables
|
||||
var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
|
||||
INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
|
||||
INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
|
||||
INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
|
||||
INV_SUB_MIX_3[sx] = t;
|
||||
|
||||
// Compute next counter
|
||||
if (!x) {
|
||||
x = xi = 1;
|
||||
} else {
|
||||
x = x2 ^ d[d[d[x8 ^ x2]]];
|
||||
xi ^= d[d[xi]];
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
||||
// Precomputed Rcon lookup
|
||||
var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
|
||||
|
||||
/**
|
||||
* AES block cipher algorithm.
|
||||
*/
|
||||
var AES = C_algo.AES = BlockCipher.extend({
|
||||
_doReset: function () {
|
||||
var t;
|
||||
|
||||
// Skip reset of nRounds has been set before and key did not change
|
||||
if (this._nRounds && this._keyPriorReset === this._key) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Shortcuts
|
||||
var key = this._keyPriorReset = this._key;
|
||||
var keyWords = key.words;
|
||||
var keySize = key.sigBytes / 4;
|
||||
|
||||
// Compute number of rounds
|
||||
var nRounds = this._nRounds = keySize + 6;
|
||||
|
||||
// Compute number of key schedule rows
|
||||
var ksRows = (nRounds + 1) * 4;
|
||||
|
||||
// Compute key schedule
|
||||
var keySchedule = this._keySchedule = [];
|
||||
for (var ksRow = 0; ksRow < ksRows; ksRow++) {
|
||||
if (ksRow < keySize) {
|
||||
keySchedule[ksRow] = keyWords[ksRow];
|
||||
} else {
|
||||
t = keySchedule[ksRow - 1];
|
||||
|
||||
if (!(ksRow % keySize)) {
|
||||
// Rot word
|
||||
t = (t << 8) | (t >>> 24);
|
||||
|
||||
// Sub word
|
||||
t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
||||
|
||||
// Mix Rcon
|
||||
t ^= RCON[(ksRow / keySize) | 0] << 24;
|
||||
} else if (keySize > 6 && ksRow % keySize == 4) {
|
||||
// Sub word
|
||||
t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
||||
}
|
||||
|
||||
keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
|
||||
}
|
||||
}
|
||||
|
||||
// Compute inv key schedule
|
||||
var invKeySchedule = this._invKeySchedule = [];
|
||||
for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
|
||||
var ksRow = ksRows - invKsRow;
|
||||
|
||||
if (invKsRow % 4) {
|
||||
var t = keySchedule[ksRow];
|
||||
} else {
|
||||
var t = keySchedule[ksRow - 4];
|
||||
}
|
||||
|
||||
if (invKsRow < 4 || ksRow <= 4) {
|
||||
invKeySchedule[invKsRow] = t;
|
||||
} else {
|
||||
invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
|
||||
INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
encryptBlock: function (M, offset) {
|
||||
this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
|
||||
},
|
||||
|
||||
decryptBlock: function (M, offset) {
|
||||
// Swap 2nd and 4th rows
|
||||
var t = M[offset + 1];
|
||||
M[offset + 1] = M[offset + 3];
|
||||
M[offset + 3] = t;
|
||||
|
||||
this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
|
||||
|
||||
// Inv swap 2nd and 4th rows
|
||||
var t = M[offset + 1];
|
||||
M[offset + 1] = M[offset + 3];
|
||||
M[offset + 3] = t;
|
||||
},
|
||||
|
||||
_doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
|
||||
// Shortcut
|
||||
var nRounds = this._nRounds;
|
||||
|
||||
// Get input, add round key
|
||||
var s0 = M[offset] ^ keySchedule[0];
|
||||
var s1 = M[offset + 1] ^ keySchedule[1];
|
||||
var s2 = M[offset + 2] ^ keySchedule[2];
|
||||
var s3 = M[offset + 3] ^ keySchedule[3];
|
||||
|
||||
// Key schedule row counter
|
||||
var ksRow = 4;
|
||||
|
||||
// Rounds
|
||||
for (var round = 1; round < nRounds; round++) {
|
||||
// Shift rows, sub bytes, mix columns, add round key
|
||||
var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
|
||||
var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
|
||||
var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
|
||||
var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
|
||||
|
||||
// Update state
|
||||
s0 = t0;
|
||||
s1 = t1;
|
||||
s2 = t2;
|
||||
s3 = t3;
|
||||
}
|
||||
|
||||
// Shift rows, sub bytes, add round key
|
||||
var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
|
||||
var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
|
||||
var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
|
||||
var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
|
||||
|
||||
// Set output
|
||||
M[offset] = t0;
|
||||
M[offset + 1] = t1;
|
||||
M[offset + 2] = t2;
|
||||
M[offset + 3] = t3;
|
||||
},
|
||||
|
||||
keySize: 256/32
|
||||
});
|
||||
|
||||
/**
|
||||
* Shortcut functions to the cipher's object interface.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
|
||||
* var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
|
||||
*/
|
||||
C.AES = BlockCipher._createHelper(AES);
|
||||
}());
|
||||
|
||||
|
||||
return CryptoJS.AES;
|
||||
|
||||
}));
|
||||
6191
server/src/main/resources/static/js/crypto-js.js
Normal file
6191
server/src/main/resources/static/js/crypto-js.js
Normal file
File diff suppressed because it is too large
Load Diff
299
server/src/main/resources/static/js/fenye.js
Normal file
299
server/src/main/resources/static/js/fenye.js
Normal file
@@ -0,0 +1,299 @@
|
||||
function htmlttt (str){
|
||||
var s = "";
|
||||
if(str.length == 0) return "";
|
||||
s = str.replace(/&/gi,"&");
|
||||
s = s.replace(/ /gi," ");
|
||||
s = s.replace(/'/gi,"\'");
|
||||
s = s.replace(/"/gi,"\"");
|
||||
s = s.replace(/javascript/g,"javascript ");
|
||||
s = s.replace(/iframe/gi, "iframe ");
|
||||
return s;
|
||||
}
|
||||
|
||||
function isEmptyString(str) {
|
||||
return !str || str.length === 0;
|
||||
}
|
||||
|
||||
function removeExtraNewlines(str) {
|
||||
// 替换连续的换行符为单个换行符
|
||||
return str.replace(/(?:\r\n|\r|\n){2,}/g, '\n');
|
||||
}
|
||||
|
||||
function DHTMLpagenation(content,kkkeyword,Length,page,txt)
|
||||
{
|
||||
if(page==0){
|
||||
page=1;
|
||||
}
|
||||
this.content=content; // 内容
|
||||
this.contentLength=s.length; // 内容长度
|
||||
this.pageSizeCount; // 总页数
|
||||
this.perpageLength= Length; //default perpage byte length.
|
||||
this.currentPage= page; // 起始页为第1页
|
||||
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)
|
||||
{
|
||||
if(txt =="code"){
|
||||
content = htmlttt(content);
|
||||
strDisplayContent = '<pre><code>'+content+'</code></pre>';
|
||||
divDisplayContent.innerHTML=strDisplayContent;
|
||||
if (!!window.ActiveXObject || "ActiveXObject" in window){
|
||||
}else{
|
||||
hljs.highlightAll(kkkeyword);
|
||||
}
|
||||
}else if(txt =="js"){
|
||||
content = htmlttt(content);
|
||||
var result = js_beautify(content, 1, "\t");
|
||||
strDisplayContent = '<pre><code class="language-js">'+result+'</code></pre>';
|
||||
divDisplayContent.innerHTML=strDisplayContent;
|
||||
if (!!window.ActiveXObject || "ActiveXObject" in window){
|
||||
}else{
|
||||
hljs.highlightAll(kkkeyword);
|
||||
}
|
||||
}else{
|
||||
content = removeExtraNewlines(content);
|
||||
let list = content.split('\n') // 换行符分割
|
||||
for(let i=0;i<list.length;i++) {
|
||||
list[i] = i + "." + list[i] // 加序号
|
||||
}
|
||||
let txt = list.join('\n');
|
||||
if (kkkeyword!==""&&kkkeyword!==null&&kkkeyword!=="null") {
|
||||
txt = txt.split(kkkeyword).join("<span class='highlight'>" + kkkeyword + "</span>");
|
||||
}
|
||||
divDisplayContent.innerHTML=txt;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
pageSizeCount=Math.ceil((contentLength/perpageLength));
|
||||
|
||||
DHTMLpagenation.goto(currentPage);
|
||||
|
||||
DHTMLpagenation.displayContent();
|
||||
};
|
||||
|
||||
//显示分页栏
|
||||
DHTMLpagenation.displayPage=function()
|
||||
{
|
||||
strDisplayPagenation="";
|
||||
if(currentPage && currentPage !=1)
|
||||
{
|
||||
|
||||
strDisplayPagenation+='<button onclick="DHTMLpagenation.previous()">上一页 </button>';
|
||||
}
|
||||
else
|
||||
{
|
||||
strDisplayPagenation+="上一页";
|
||||
}
|
||||
|
||||
if(currentPage && currentPage!=pageSizeCount)
|
||||
{
|
||||
strDisplayPagenation+='<button onclick="DHTMLpagenation.next()">下一页 </button>';
|
||||
|
||||
strDisplayPagenation+="<input type='number' value='"+currentPage+"' id='yemaPerpageLength' style='width:70px' /><button type='button' onclick='DHTMLpagenation.tiaozhuan()'/> 跳转</button> ";
|
||||
}
|
||||
else
|
||||
{
|
||||
strDisplayPagenation+="下一页";
|
||||
}
|
||||
if (isEmptyString(currentPage)) {
|
||||
currentPage =1;
|
||||
}
|
||||
strDisplayPagenation+=+currentPage+"/" + pageSizeCount + "页。<br>每页 " + perpageLength + " 字符,调整字符数:<input type='number' value='"+perpageLength+"' id='ctlPerpageLength' style='width:70px' /><button onclick='DHTMLpagenation.change()' /> 确定</button>";
|
||||
divDisplayPagenation.innerHTML=strDisplayPagenation;
|
||||
};
|
||||
|
||||
//上一页
|
||||
DHTMLpagenation.previous=function()
|
||||
{
|
||||
DHTMLpagenation.goto(currentPage-1);
|
||||
};
|
||||
|
||||
//下一页
|
||||
DHTMLpagenation.next=function()
|
||||
{
|
||||
|
||||
DHTMLpagenation.goto(currentPage+1);
|
||||
};
|
||||
|
||||
//跳转至某一页
|
||||
DHTMLpagenation.goto=function(iCurrentPage)
|
||||
{
|
||||
if (isEmptyString(iCurrentPage)) {
|
||||
iCurrentPage =1;
|
||||
}
|
||||
if(regularExp.test(iCurrentPage))
|
||||
{
|
||||
currentPage=iCurrentPage;
|
||||
//获取当前的内容 里面包含 ❈
|
||||
var currentContent = s.substr((currentPage-1)*perpageLength,perpageLength);
|
||||
//当前页是否有 ❈ 获取最后一个 ❈ 的位置
|
||||
var indexOf = currentContent.indexOf("❈");
|
||||
if(indexOf >= 0)
|
||||
{
|
||||
//获取从开始位置到当前页位置的内容
|
||||
var beginToEndContent = s.substr(0,currentPage*perpageLength);
|
||||
|
||||
//获取开始到当前页位置的内容 中的 * 的最后的下标
|
||||
var reCount = beginToEndContent.split("❈").length - 1;
|
||||
|
||||
var contentArray = currentContent.split("❈");
|
||||
|
||||
currentContent = replaceStr(contentArray,reCount,matchContent);
|
||||
|
||||
}
|
||||
|
||||
strDisplayContent=currentContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
alert("页面参数错误");
|
||||
}
|
||||
DHTMLpagenation.displayPage();
|
||||
DHTMLpagenation.displayContent();
|
||||
};
|
||||
//显示当前页内容
|
||||
DHTMLpagenation.displayContent=function()
|
||||
{
|
||||
if(txt =="code"){
|
||||
strDisplayContent = htmlttt(strDisplayContent);
|
||||
strDisplayContent = "<pre><code>"+strDisplayContent+"</code></pre>";
|
||||
divDisplayContent.innerHTML=strDisplayContent;
|
||||
if (!!window.ActiveXObject || "ActiveXObject" in window){
|
||||
}else{
|
||||
hljs.highlightAll(kkkeyword);
|
||||
}
|
||||
}else if(txt =="js"){
|
||||
strDisplayContent = htmlttt(strDisplayContent);
|
||||
var result = js_beautify(strDisplayContent, 1, "\t");
|
||||
strDisplayContent ='<pre><code class="language-js">'+result+'</code></pre>';
|
||||
divDisplayContent.innerHTML=strDisplayContent;
|
||||
if (!!window.ActiveXObject || "ActiveXObject" in window){
|
||||
}else{
|
||||
hljs.highlightAll(kkkeyword);
|
||||
}
|
||||
}else{
|
||||
if (kkkeyword!==""&&kkkeyword!==null&&kkkeyword!=="null") {
|
||||
|
||||
strDisplayContent = strDisplayContent.split(kkkeyword).join("<span class='highlight'>" + kkkeyword + "</span>");
|
||||
}
|
||||
divDisplayContent.innerHTML=strDisplayContent;
|
||||
}
|
||||
};
|
||||
//改变每页的字节数
|
||||
DHTMLpagenation.change=function()
|
||||
{
|
||||
|
||||
var iPerpageLength = document.getElementById("ctlPerpageLength").value;
|
||||
if(regularExp.test(iPerpageLength))
|
||||
{
|
||||
|
||||
DHTMLpagenation(s,iPerpageLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
alert("请输入数字");
|
||||
}
|
||||
};
|
||||
//改变页码
|
||||
DHTMLpagenation.tiaozhuan=function()
|
||||
{
|
||||
var yema = document.getElementById("yemaPerpageLength").value;
|
||||
if(regularExp.test(yema))
|
||||
{
|
||||
DHTMLpagenation.goto(yema);
|
||||
}
|
||||
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;
|
||||
}
|
||||
72
server/src/main/resources/static/js/jsformat.js
Normal file
72
server/src/main/resources/static/js/jsformat.js
Normal file
@@ -0,0 +1,72 @@
|
||||
function js_beautify(js_source_text,indent_size,indent_character,indent_level)
|
||||
{var input,output,token_text,last_type,last_text,last_word,current_mode,modes,indent_string;var whitespace,wordchar,punct,parser_pos,line_starters,in_case;var prefix,token_type,do_block_just_closed,var_line,var_line_tainted;function trim_output()
|
||||
{while(output.length&&(output[output.length-1]===' '||output[output.length-1]===indent_string)){output.pop();}}
|
||||
function print_newline(ignore_repeated)
|
||||
{ignore_repeated=typeof ignore_repeated==='undefined'?true:ignore_repeated;trim_output();if(!output.length){return;}
|
||||
if(output[output.length-1]!=="\n"||!ignore_repeated){output.push("\n");}
|
||||
for(var i=0;i<indent_level;i++){output.push(indent_string);}}
|
||||
function print_space()
|
||||
{var last_output=output.length?output[output.length-1]:' ';if(last_output!==' '&&last_output!=='\n'&&last_output!==indent_string){output.push(' ');}}
|
||||
function print_token()
|
||||
{output.push(token_text);}
|
||||
function indent()
|
||||
{indent_level++;}
|
||||
function unindent()
|
||||
{if(indent_level){indent_level--;}}
|
||||
function remove_indent()
|
||||
{if(output.length&&output[output.length-1]===indent_string){output.pop();}}
|
||||
function set_mode(mode)
|
||||
{modes.push(current_mode);current_mode=mode;}
|
||||
function restore_mode()
|
||||
{do_block_just_closed=current_mode==='DO_BLOCK';current_mode=modes.pop();}
|
||||
function in_array(what,arr)
|
||||
{for(var i=0;i<arr.length;i++)
|
||||
{if(arr[i]===what){return true;}}
|
||||
return false;}
|
||||
function get_next_token()
|
||||
{var n_newlines=0;var c='';do{if(parser_pos>=input.length){return['','TK_EOF'];}
|
||||
c=input.charAt(parser_pos);parser_pos+=1;if(c==="\n"){n_newlines+=1;}}
|
||||
while(in_array(c,whitespace));if(n_newlines>1){for(var i=0;i<2;i++){print_newline(i===0);}}
|
||||
var wanted_newline=(n_newlines===1);if(in_array(c,wordchar)){if(parser_pos<input.length){while(in_array(input.charAt(parser_pos),wordchar)){c+=input.charAt(parser_pos);parser_pos+=1;if(parser_pos===input.length){break;}}}
|
||||
if(parser_pos!==input.length&&c.match(/^[0-9]+[Ee]$/)&&input.charAt(parser_pos)==='-'){parser_pos+=1;var t=get_next_token(parser_pos);c+='-'+t[0];return[c,'TK_WORD'];}
|
||||
if(c==='in'){return[c,'TK_OPERATOR'];}
|
||||
return[c,'TK_WORD'];}
|
||||
if(c==='('||c==='['){return[c,'TK_START_EXPR'];}
|
||||
if(c===')'||c===']'){return[c,'TK_END_EXPR'];}
|
||||
if(c==='{'){return[c,'TK_START_BLOCK'];}
|
||||
if(c==='}'){return[c,'TK_END_BLOCK'];}
|
||||
if(c===';'){return[c,'TK_END_COMMAND'];}
|
||||
if(c==='/'){var comment='';if(input.charAt(parser_pos)==='*'){parser_pos+=1;if(parser_pos<input.length){while(!(input.charAt(parser_pos)==='*'&&input.charAt(parser_pos+1)&&input.charAt(parser_pos+1)==='/')&&parser_pos<input.length){comment+=input.charAt(parser_pos);parser_pos+=1;if(parser_pos>=input.length){break;}}}
|
||||
parser_pos+=2;return['/*'+comment+'*/','TK_BLOCK_COMMENT'];}
|
||||
if(input.charAt(parser_pos)==='/'){comment=c;while(input.charAt(parser_pos)!=="\x0d"&&input.charAt(parser_pos)!=="\x0a"){comment+=input.charAt(parser_pos);parser_pos+=1;if(parser_pos>=input.length){break;}}
|
||||
parser_pos+=1;if(wanted_newline){print_newline();}
|
||||
return[comment,'TK_COMMENT'];}}
|
||||
if(c==="'"||c==='"'||(c==='/'&&((last_type==='TK_WORD'&&last_text==='return')||(last_type==='TK_START_EXPR'||last_type==='TK_END_BLOCK'||last_type==='TK_OPERATOR'||last_type==='TK_EOF'||last_type==='TK_END_COMMAND')))){var sep=c;var esc=false;c='';if(parser_pos<input.length){while(esc||input.charAt(parser_pos)!==sep){c+=input.charAt(parser_pos);if(!esc){esc=input.charAt(parser_pos)==='\\';}else{esc=false;}
|
||||
parser_pos+=1;if(parser_pos>=input.length){break;}}}
|
||||
parser_pos+=1;if(last_type==='TK_END_COMMAND'){print_newline();}
|
||||
return[sep+c+sep,'TK_STRING'];}
|
||||
if(in_array(c,punct)){while(parser_pos<input.length&&in_array(c+input.charAt(parser_pos),punct)){c+=input.charAt(parser_pos);parser_pos+=1;if(parser_pos>=input.length){break;}}
|
||||
return[c,'TK_OPERATOR'];}
|
||||
return[c,'TK_UNKNOWN'];}
|
||||
indent_character=indent_character||' ';indent_size=indent_size||4;indent_string='';while(indent_size--){indent_string+=indent_character;}
|
||||
input=js_source_text;last_word='';last_type='TK_START_EXPR';last_text='';output=[];do_block_just_closed=false;var_line=false;var_line_tainted=false;whitespace="\n\r\t ".split('');wordchar='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$'.split('');punct='+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |='.split(' ');line_starters='continue,try,throw,return,var,if,switch,case,default,for,while,break,function'.split(',');current_mode='BLOCK';modes=[current_mode];indent_level=indent_level||0;parser_pos=0;in_case=false;while(true){var t=get_next_token(parser_pos);token_text=t[0];token_type=t[1];if(token_type==='TK_EOF'){break;}
|
||||
switch(token_type){case'TK_START_EXPR':var_line=false;set_mode('EXPRESSION');if(last_type==='TK_END_EXPR'||last_type==='TK_START_EXPR'){}else if(last_type!=='TK_WORD'&&last_type!=='TK_OPERATOR'){print_space();}else if(in_array(last_word,line_starters)&&last_word!=='function'){print_space();}
|
||||
print_token();break;case'TK_END_EXPR':print_token();restore_mode();break;case'TK_START_BLOCK':if(last_word==='do'){set_mode('DO_BLOCK');}else{set_mode('BLOCK');}
|
||||
if(last_type!=='TK_OPERATOR'&&last_type!=='TK_START_EXPR'){if(last_type==='TK_START_BLOCK'){print_newline();}else{print_space();}}
|
||||
print_token();indent();break;case'TK_END_BLOCK':if(last_type==='TK_START_BLOCK'){trim_output();unindent();}else{unindent();print_newline();}
|
||||
print_token();restore_mode();break;case'TK_WORD':if(do_block_just_closed){print_space();print_token();print_space();break;}
|
||||
if(token_text==='case'||token_text==='default'){if(last_text===':'){remove_indent();}else{unindent();print_newline();indent();}
|
||||
print_token();in_case=true;break;}
|
||||
prefix='NONE';if(last_type==='TK_END_BLOCK'){if(!in_array(token_text.toLowerCase(),['else','catch','finally'])){prefix='NEWLINE';}else{prefix='SPACE';print_space();}}else if(last_type==='TK_END_COMMAND'&&(current_mode==='BLOCK'||current_mode==='DO_BLOCK')){prefix='NEWLINE';}else if(last_type==='TK_END_COMMAND'&¤t_mode==='EXPRESSION'){prefix='SPACE';}else if(last_type==='TK_WORD'){prefix='SPACE';}else if(last_type==='TK_START_BLOCK'){prefix='NEWLINE';}else if(last_type==='TK_END_EXPR'){print_space();prefix='NEWLINE';}
|
||||
if(last_type!=='TK_END_BLOCK'&&in_array(token_text.toLowerCase(),['else','catch','finally'])){print_newline();}else if(in_array(token_text,line_starters)||prefix==='NEWLINE'){if(last_text==='else'){print_space();}else if((last_type==='TK_START_EXPR'||last_text==='=')&&token_text==='function'){}else if(last_type==='TK_WORD'&&(last_text==='return'||last_text==='throw')){print_space();}else if(last_type!=='TK_END_EXPR'){if((last_type!=='TK_START_EXPR'||token_text!=='var')&&last_text!==':'){if(token_text==='if'&&last_type==='TK_WORD'&&last_word==='else'){print_space();}else{print_newline();}}}else{if(in_array(token_text,line_starters)&&last_text!==')'){print_newline();}}}else if(prefix==='SPACE'){print_space();}
|
||||
print_token();last_word=token_text;if(token_text==='var'){var_line=true;var_line_tainted=false;}
|
||||
break;case'TK_END_COMMAND':print_token();var_line=false;break;case'TK_STRING':if(last_type==='TK_START_BLOCK'||last_type==='TK_END_BLOCK'){print_newline();}else if(last_type==='TK_WORD'){print_space();}
|
||||
print_token();break;case'TK_OPERATOR':var start_delim=true;var end_delim=true;if(var_line&&token_text!==','){var_line_tainted=true;if(token_text===':'){var_line=false;}}
|
||||
if(token_text===':'&&in_case){print_token();print_newline();break;}
|
||||
in_case=false;if(token_text===','){if(var_line){if(var_line_tainted){print_token();print_newline();var_line_tainted=false;}else{print_token();print_space();}}else if(last_type==='TK_END_BLOCK'){print_token();print_newline();}else{if(current_mode==='BLOCK'){print_token();print_newline();}else{print_token();print_space();}}
|
||||
break;}else if(token_text==='--'||token_text==='++'){if(last_text===';'){start_delim=true;end_delim=false;}else{start_delim=false;end_delim=false;}}else if(token_text==='!'&&last_type==='TK_START_EXPR'){start_delim=false;end_delim=false;}else if(last_type==='TK_OPERATOR'){start_delim=false;end_delim=false;}else if(last_type==='TK_END_EXPR'){start_delim=true;end_delim=true;}else if(token_text==='.'){start_delim=false;end_delim=false;}else if(token_text===':'){if(last_text.match(/^\d+$/)){start_delim=true;}else{start_delim=false;}}
|
||||
if(start_delim){print_space();}
|
||||
print_token();if(end_delim){print_space();}
|
||||
break;case'TK_BLOCK_COMMENT':print_newline();print_token();print_newline();break;case'TK_COMMENT':print_space();print_token();print_newline();break;case'TK_UNKNOWN':print_token();break;}
|
||||
last_type=token_type;last_text=token_text;}
|
||||
return output.join('');}
|
||||
@@ -2612,7 +2612,8 @@
|
||||
return this.destroy();
|
||||
}
|
||||
var images = [];
|
||||
forEach(isImg ? [element] : element.querySelectorAll('img'), function (image) {
|
||||
//console.log('Hello, World!');
|
||||
forEach(isImg ? [element] : element.querySelectorAll('div'), function (image) {
|
||||
if (isFunction(options.filter)) {
|
||||
if (options.filter.call(_this12, image)) {
|
||||
images.push(image);
|
||||
@@ -2989,7 +2990,8 @@
|
||||
}
|
||||
var isImg = element.localName === 'img';
|
||||
var images = [];
|
||||
forEach(isImg ? [element] : element.querySelectorAll('img'), function (image) {
|
||||
// console.log('Hello, World!');
|
||||
forEach(isImg ? [element] : element.querySelectorAll('div'), function (image) {
|
||||
if (isFunction(options.filter)) {
|
||||
if (options.filter.call(_this, image)) {
|
||||
images.push(image);
|
||||
|
||||
Reference in New Issue
Block a user