390 lines
23 KiB
JavaScript
390 lines
23 KiB
JavaScript
let JavascriptCompilationPNameAll = [];//存储所有的多层指向PName命令
|
||
let JsonJSCodeJQ = [];//储存所有的JQ编译数据
|
||
let JsonJSCodeTransformation = [];//储存所有的代码转换类编译数据
|
||
let JavascriptCodeKey = [];//储存所有的JS关键字
|
||
let JavascriptNoCodeStatic = [];//储存所有非静态的类中命令
|
||
let JavascriptEvCode = [];//储存所有的全局侦听事件命令
|
||
let JavascriptYesCodeStatic = [];//储存所有的静态命令
|
||
let JavascriptYesCodeStatic2 = [];//储存所有的静态命令,将endfofdianhaobenin转换为.
|
||
let JavascriptOverallCode = [];//储存所有的全局命令
|
||
let JavascriptCompilerLineBreak = [];//编译换行处理,例如类名\r\n .
|
||
//初始化JS编译JSON信息
|
||
function JsonJSCodeMain(JavascriptCompilationPNameAll_, JSON_JQ, JsonJSCodeTransformation_, JavascriptCodeKey_, JavascriptNoCodeStatic_, JavascriptEvCode_, JavascriptYesCodeStatic_, JavascriptOverallCode_) {
|
||
JavascriptCompilationPNameAll = JavascriptCompilationPNameAll_
|
||
let JavascriptCompilationPNameAllLs = [[], [], [], [], [], [], [], [], [], []];
|
||
for (let index = 0; index < JavascriptCompilationPNameAll_.length; index++) {
|
||
if (JavascriptCompilationPNameAll_[index]["com1"].indexOf("endfofdianhaobenin") == -1) {
|
||
JavascriptCompilationPNameAllLs[0][JavascriptCompilationPNameAllLs[0].length] = JavascriptCompilationPNameAll_[index];
|
||
}
|
||
let intEnd = JavascriptCompilationPNameAll_[index]["com1"].split("endfofdianhaobenin");
|
||
if (intEnd.length == 2) {
|
||
JavascriptCompilationPNameAllLs[1][JavascriptCompilationPNameAllLs[1].length] = JavascriptCompilationPNameAll_[index];
|
||
}
|
||
if (intEnd.length == 3) {
|
||
JavascriptCompilationPNameAllLs[2][JavascriptCompilationPNameAllLs[2].length] = JavascriptCompilationPNameAll_[index];
|
||
}
|
||
if (intEnd.length == 4) {
|
||
JavascriptCompilationPNameAllLs[3][JavascriptCompilationPNameAllLs[3].length] = JavascriptCompilationPNameAll_[index];
|
||
}
|
||
if (intEnd.length == 5) {
|
||
JavascriptCompilationPNameAllLs[4][JavascriptCompilationPNameAllLs[4].length] = JavascriptCompilationPNameAll_[index];
|
||
}
|
||
if (intEnd.length == 6) {
|
||
JavascriptCompilationPNameAllLs[5][JavascriptCompilationPNameAllLs[5].length] = JavascriptCompilationPNameAll_[index];
|
||
}
|
||
if (intEnd.length == 7) {
|
||
JavascriptCompilationPNameAllLs[6][JavascriptCompilationPNameAllLs[6].length] = JavascriptCompilationPNameAll_[index];
|
||
}
|
||
}
|
||
for (let index = 0; index < JavascriptCompilationPNameAllLs.length; index++) {
|
||
for (let index_ = 0; index_ < JavascriptCompilationPNameAllLs[JavascriptCompilationPNameAllLs.length - index - 1].length; index_++) {
|
||
JavascriptCompilationPNameAll[JavascriptCompilationPNameAll.length] = JavascriptCompilationPNameAllLs[JavascriptCompilationPNameAllLs.length - index - 1][index_]
|
||
}
|
||
}
|
||
JsonJSCodeJQ = JSON_JQ;
|
||
JsonJSCodeTransformation = JsonJSCodeTransformation_;
|
||
JavascriptCodeKey = JavascriptCodeKey_;
|
||
JavascriptNoCodeStatic = JavascriptNoCodeStatic_;
|
||
JavascriptEvCode = JavascriptEvCode_;
|
||
JavascriptYesCodeStatic = JavascriptYesCodeStatic_;
|
||
if (JavascriptYesCodeStatic != undefined) {
|
||
JavascriptYesCodeStatic2 = JSON.parse(JSON.stringify(JavascriptYesCodeStatic).replaceAll("endfofdianhaobenin", "."))
|
||
}
|
||
JavascriptOverallCode = JavascriptOverallCode_;
|
||
}
|
||
//编译Html文件下所有Script中的JS代码
|
||
//编译JS命令
|
||
//str-要编译的页面代码,
|
||
//CodeType-编译的类型,1代表编译成本地语言,2代表编译成英文
|
||
//【注意:本地语言,例如中文、柬埔寨或者其他国家语言以正则为主,目前暂时支持中文】
|
||
//FileID - 文件的ID,可以是空字符串
|
||
function JsCodeCompilerAll(str, CodeType, FileID) {
|
||
let JsCodeAll = JsCodeAllScript(str);
|
||
for (let index = 0; index < JsCodeAll.length; index++) {
|
||
let JsCodeAr = [JsCodeAll[index], JsCodeAll[index]];
|
||
JsCodeAr[1] = JsCodeCompiler({
|
||
"JSCode": JsCodeAr[1],
|
||
"CodeType": CodeType,
|
||
"FileID": FileID
|
||
});
|
||
str = str.replace(JsCodeAr[0], JsCodeAr[1])
|
||
}
|
||
return str;
|
||
}
|
||
//获取所有Script标签中的内容
|
||
function JsCodeAllScript(htmlStr) {
|
||
let reg = RegExp("(<script[^]*?</script>)", "g");
|
||
htmlStr = htmlStr.replaceAll("<脚本失败提示", "<jiaobenshibaitishiyingwenlinshizhuanhuan")
|
||
htmlStr = htmlStr.replaceAll("</脚本失败提示", "</jiaobenshibaitishiyingwenlinshizhuanhuan")
|
||
let htmlStrAll = htmlStr.match(reg);
|
||
if (htmlStrAll == null || htmlStrAll == undefined) {
|
||
htmlStrAll = [];
|
||
}
|
||
let htmlStrAllReturn = [];
|
||
if (htmlStrAll.length >= 1) {
|
||
for (let index = 0; index < htmlStrAll.length; index++) {
|
||
let JsCodeStrSplit = htmlStrAll[index];
|
||
let JsCodeStrSplitArr = JsCodeStrSplit.split(">");
|
||
if (JsCodeStrSplitArr.length >= 1) {
|
||
if (indexOfT(JsCodeStrSplitArr[0], "=\"") == false && indexOfT(JsCodeStrSplitArr[0], "=\'") == false && indexOfT(JsCodeStrSplitArr[0], FileTypeExtension.js) == false && indexOfT(JsCodeStrSplitArr[0], " http://") == false && indexOfT(JsCodeStrSplitArr[0], " https://") == false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
} else {
|
||
if (indexOfT(JsCodeStrSplitArr[0], `type="module"`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `type='module'`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `因特网标准='module'`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `因特网标准="module"`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
reg = RegExp("(<脚本[^]*?</脚本>)", "g");
|
||
htmlStrAll = htmlStr.match(reg);
|
||
if (htmlStrAll == null || htmlStrAll == undefined) {
|
||
htmlStrAll = [];
|
||
}
|
||
if (htmlStrAll.length >= 1) {
|
||
for (let index = 0; index < htmlStrAll.length; index++) {
|
||
let JsCodeStrSplit = htmlStrAll[index];
|
||
let JsCodeStrSplitArr = JsCodeStrSplit.split(">");
|
||
if (JsCodeStrSplitArr.length >= 1) {
|
||
if (indexOfT(JsCodeStrSplitArr[0], "=\"") == false && indexOfT(JsCodeStrSplitArr[0], "=\'") == false && indexOfT(JsCodeStrSplitArr[0], FileTypeExtension.js) == false && indexOfT(JsCodeStrSplitArr[0], " http://") == false && indexOfT(JsCodeStrSplitArr[0], " https://") == false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
} else {
|
||
if (indexOfT(JsCodeStrSplitArr[0], `type="module"`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `type='module'`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `因特网标准='module'`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `因特网标准="module"`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
reg = RegExp("(<script[^]*?</脚本>)", "g");
|
||
htmlStrAll = htmlStr.match(reg);
|
||
if (htmlStrAll == null || htmlStrAll == undefined) {
|
||
htmlStrAll = [];
|
||
}
|
||
if (htmlStrAll.length >= 1) {
|
||
for (let index = 0; index < htmlStrAll.length; index++) {
|
||
let JsCodeStrSplit = htmlStrAll[index];
|
||
let JsCodeStrSplitArr = JsCodeStrSplit.split(">");
|
||
if (JsCodeStrSplitArr.length >= 1) {
|
||
if (indexOfT(JsCodeStrSplitArr[0], "=\"") == false && indexOfT(JsCodeStrSplitArr[0], "=\'") == false && indexOfT(JsCodeStrSplitArr[0], FileTypeExtension.js) == false && indexOfT(JsCodeStrSplitArr[0], " http://") == false && indexOfT(JsCodeStrSplitArr[0], " https://") == false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
} else {
|
||
if (indexOfT(JsCodeStrSplitArr[0], `type="module"`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `type='module'`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `因特网标准='module'`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `因特网标准="module"`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
reg = RegExp("(<脚本[^]*?</script>)", "g");
|
||
htmlStrAll = htmlStr.match(reg);
|
||
if (htmlStrAll == null || htmlStrAll == undefined) {
|
||
htmlStrAll = [];
|
||
}
|
||
if (htmlStrAll.length >= 1) {
|
||
for (let index = 0; index < htmlStrAll.length; index++) {
|
||
let JsCodeStrSplit = htmlStrAll[index];
|
||
let JsCodeStrSplitArr = JsCodeStrSplit.split(">");
|
||
if (JsCodeStrSplitArr.length >= 1) {
|
||
if (indexOfT(JsCodeStrSplitArr[0], "=\"") == false && indexOfT(JsCodeStrSplitArr[0], "=\'") == false && indexOfT(JsCodeStrSplitArr[0], FileTypeExtension.js) == false && indexOfT(JsCodeStrSplitArr[0], " http://") == false && indexOfT(JsCodeStrSplitArr[0], " https://") == false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
} else {
|
||
if (indexOfT(JsCodeStrSplitArr[0], `type="module"`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `type='module'`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `因特网标准='module'`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
if (indexOfT(JsCodeStrSplitArr[0], `因特网标准="module"`) != false) {
|
||
htmlStrAllReturn[htmlStrAllReturn.length] = htmlStrAll[index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return htmlStrAllReturn;
|
||
}
|
||
//编译JS命令
|
||
//JSCode-要编译的JS代码
|
||
//CodeType-编译的类型,1代表编译成本地语言,2代表编译成英文
|
||
//【注意:本地语言,例如中文、柬埔寨或者其他国家语言以正则为主,目前暂时支持中文】
|
||
//FileID - 文件的ID,可以是空字符串
|
||
//CompilerObj - 编译配置
|
||
function JsCodeCompiler(CompilerObj = {}) {
|
||
JavascriptCompilerLineBreak = [];//编译换行处理
|
||
CompilerObj["JSCode"] = "CompilerStartJS" + CompilerStart + CompilerObj["JSCode"];
|
||
CompilerObj["JSCode"] = RegularReplacer(CompilerObj["JSCode"], 1)//编译特殊符号替换
|
||
CompilerObj["JSCode"] = JsCodeCompilerCodeJQ(CompilerObj["CodeType"], CompilerObj["JSCode"]);//JQ专属编译
|
||
let JsCodeJSonCompilerStr = [];//储存所有编译时产生的临时数据,该变量中的临时数据将不会参与到JS编译!
|
||
let RetJSCode = NoStrCompiler(JsCodeJSonCompilerStr, CompilerObj["JSCode"], 1, ComPilerDataMsgType.IfComPiler, CompilerObj["FileID"]);//不参与编译的相关数据加密
|
||
JsCodeJSonCompilerStr = RetJSCode["JsCodeJSonCompilerStr"]
|
||
CompilerObj["JSCode"] = RetJSCode["code"]
|
||
CompilerObj["JSCode"] = JsCodeCompilertEvCode(CompilerObj["CodeType"], CompilerObj["JSCode"]);//全局事件侦听编译
|
||
CompilerObj["JSCode"] = JsCodeCompilerCodePNameAll(CompilerObj["CodeType"], CompilerObj["JSCode"]);//多层指向PName编译
|
||
CompilerObj["JSCode"] = JsCodeCompYesCodeStatic(CompilerObj["CodeType"], CompilerObj["JSCode"]);//静态命令编译
|
||
CompilerObj["JSCode"] = JsCodeCompilerClassCode(CompilerObj["CodeType"], CompilerObj["JSCode"]);//类数据编译
|
||
CompilerObj["JSCode"] = JsCodeCompilerCodeKeyword(CompilerObj["CodeType"], CompilerObj["JSCode"]);//关键字的编译
|
||
CompilerObj["JSCode"] = JsCodeCompOverallCode(CompilerObj["CodeType"], CompilerObj["JSCode"]);//全局命令编译
|
||
RetJSCode = NoStrCompiler(JsCodeJSonCompilerStr, CompilerObj["JSCode"], 2, ComPilerDataMsgType.IfComPiler, CompilerObj["FileID"]);//不参与编译的相关数据解密
|
||
CompilerObj["JSCode"] = RetJSCode["code"]
|
||
CompilerObj["JSCode"] = YesStrCompiler(CompilerObj["JSCode"], CompilerObj["CodeType"]);
|
||
//处理需要编译的NoStrCompiler代码,例如:双引号中的html代码等
|
||
CompilerObj["JSCode"] = RegularReplacer(CompilerObj["JSCode"], 2)//编译特殊符号还原
|
||
CompilerObj["JSCode"] = CompilerObj["JSCode"].replace("CompilerStartJS" + CompilerStart, "");
|
||
return CompilerObj["JSCode"];
|
||
}
|
||
//类数据编译
|
||
function JsCodeCompilerClassCode(CodeType, JSCode) {
|
||
for (let index = 0; index < JavascriptNoCodeStatic.length; index++) {
|
||
if (JSCode.includes(JavascriptNoCodeStatic[index]["T_title_en"]) || JSCode.includes(JavascriptNoCodeStatic[index]["T_title"]))//查询到代码中有这个类的关键字
|
||
{
|
||
if (CodeType == 1) {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptNoCodeStatic[index]["T_title_en"], JavascriptNoCodeStatic[index]["T_title"], 1, 2);
|
||
} else {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptNoCodeStatic[index]["T_title"], JavascriptNoCodeStatic[index]["T_title_en"], 1, 2);
|
||
}
|
||
if (JavascriptCompilerLineBreak.indexOf(JavascriptNoCodeStatic[index]["T_title_en"]) == -1) {
|
||
JavascriptCompilerLineBreak[JavascriptCompilerLineBreak.length] = JavascriptNoCodeStatic[index]["T_title_en"]
|
||
}
|
||
if (JavascriptCompilerLineBreak.indexOf(JavascriptNoCodeStatic[index]["T_title"]) == -1) {
|
||
JavascriptCompilerLineBreak[JavascriptCompilerLineBreak.length] = JavascriptNoCodeStatic[index]["T_title"]
|
||
}
|
||
|
||
}
|
||
if (JavascriptNoCodeStatic[index]["CodeList"] != undefined && JavascriptNoCodeStatic[index]["CodeList"] != null) {
|
||
for (let index_ = 0; index_ < JavascriptNoCodeStatic[index]["CodeList"].length; index_++) {//循环遍历类下面的命令
|
||
let CodeData = {
|
||
T_title: "." + JavascriptNoCodeStatic[index]["CodeList"][index_]["T_title"],
|
||
T_title_en: "." + JavascriptNoCodeStatic[index]["CodeList"][index_]["T_title_en"]
|
||
}
|
||
CodeData.T_title = CodeData.T_title.replaceAll(".", Comendfofdianhaobenin)
|
||
CodeData.T_title_en = CodeData.T_title_en.replaceAll(".", Comendfofdianhaobenin)
|
||
if (CodeType == 1) {
|
||
JSCode = JsCodeReplace(JSCode, CodeData.T_title_en, CodeData.T_title, 1, 3);
|
||
} else {
|
||
JSCode = JsCodeReplace(JSCode, CodeData.T_title, CodeData.T_title_en, 1, 3);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return JSCode;
|
||
}
|
||
//全局侦听事件编译
|
||
function JsCodeCompilertEvCode(CodeType, JSCode) {
|
||
for (let index = 0; index < JavascriptEvCode.length; index++) {
|
||
if (JavascriptEvCode[index]["CodeList"] != undefined && JavascriptEvCode[index]["CodeList"] != null) {
|
||
for (let index_ = 0; index_ < JavascriptEvCode[index]["CodeList"].length; index_++) {//循环遍历类下面的命令
|
||
for (let index__ = 0; index__ < 6; index__++) {
|
||
let IDInt = index__ + 1;
|
||
let CodeData = {
|
||
T_title: "." + JavascriptEvCode[index]["CodeList"][index_]["com" + IDInt],
|
||
T_title_en: "." + JavascriptEvCode[index]["CodeList"][index_]["comEn" + IDInt]
|
||
}
|
||
CodeData.T_title = CodeData.T_title.replaceAll(".", Comendfofdianhaobenin)
|
||
CodeData.T_title_en = CodeData.T_title_en.replaceAll(".", Comendfofdianhaobenin)
|
||
if (CodeType == 1) {
|
||
JSCode = JsCodeReplace(JSCode, CodeData.T_title_en, CodeData.T_title, 3, 3);
|
||
} else {
|
||
JSCode = JsCodeReplace(JSCode, CodeData.T_title, CodeData.T_title_en, 3, 3);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return JSCode;
|
||
}
|
||
//关键字编译
|
||
//CodeType-编译的类型,1代表编译成本地语言,2代表编译成英文
|
||
function JsCodeCompilerCodeKeyword(CodeType, JSCode) {
|
||
for (let index = 0; index < JavascriptCodeKey.length; index++) {
|
||
if (JavascriptCodeKey[index]["JSType"] == "全局函数") {
|
||
continue;
|
||
}
|
||
if (CodeType == 1) {
|
||
if (JSCode.includes(JavascriptCodeKey[index]["JSNameEN"]))//代表有需要进行处理的关键字
|
||
{
|
||
JSCode = JsCodeReplace(JSCode, JavascriptCodeKey[index]["JSNameEN"], JavascriptCodeKey[index]["JSName"], 2, 1);
|
||
}
|
||
}
|
||
if (CodeType == 2) {
|
||
if (JSCode.includes(JavascriptCodeKey[index]["JSName"]))//代表有需要进行处理的关键字
|
||
{
|
||
JSCode = JsCodeReplace(JSCode, JavascriptCodeKey[index]["JSName"], JavascriptCodeKey[index]["JSNameEN"], 2, 1);
|
||
}
|
||
}
|
||
}
|
||
return JSCode;
|
||
}
|
||
//静态命令编译
|
||
function JsCodeCompYesCodeStatic(CodeType, JSCode) {
|
||
for (let index = 0; index < JavascriptYesCodeStatic.length; index++) {
|
||
if (JavascriptYesCodeStatic[index]["CodeList"] != undefined && JavascriptYesCodeStatic[index]["CodeList"] != null) {
|
||
for (let index_ = 0; index_ < JavascriptYesCodeStatic[index]["CodeList"].length; index_++) {//循环遍历类下面的命令
|
||
let CodeData = {
|
||
T_title: JavascriptYesCodeStatic[index]["CodeList"][index_]["comZh"],
|
||
T_title_en: JavascriptYesCodeStatic[index]["CodeList"][index_]["comEn"]
|
||
}
|
||
if (CodeType == 1) {
|
||
if (JSCode.includes(JavascriptYesCodeStatic[index]["CodeList"][index_]["com1"]) == true) {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptYesCodeStatic[index]["CodeList"][index_]["com1"], CodeData.T_title, 2, 4);
|
||
}
|
||
if (JSCode.includes(JavascriptYesCodeStatic[index]["CodeList"][index_]["com2"]) == true) {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptYesCodeStatic[index]["CodeList"][index_]["com2"], CodeData.T_title, 2, 4);
|
||
}
|
||
if (JSCode.includes(JavascriptYesCodeStatic[index]["CodeList"][index_]["com3"]) == true) {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptYesCodeStatic[index]["CodeList"][index_]["com3"], CodeData.T_title, 2, 4);
|
||
}
|
||
if (JSCode.includes(JavascriptYesCodeStatic[index]["CodeList"][index_]["com4"]) == true) {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptYesCodeStatic[index]["CodeList"][index_]["com4"], CodeData.T_title, 2, 4);
|
||
}
|
||
} else {
|
||
if (JSCode.includes(JavascriptYesCodeStatic[index]["CodeList"][index_]["com1"]) == true) {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptYesCodeStatic[index]["CodeList"][index_]["com1"], CodeData.T_title_en, 2, 4);
|
||
}
|
||
if (JSCode.includes(JavascriptYesCodeStatic[index]["CodeList"][index_]["com2"]) == true) {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptYesCodeStatic[index]["CodeList"][index_]["com2"], CodeData.T_title_en, 2, 4);
|
||
}
|
||
if (JSCode.includes(JavascriptYesCodeStatic[index]["CodeList"][index_]["com3"]) == true) {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptYesCodeStatic[index]["CodeList"][index_]["com3"], CodeData.T_title_en, 2, 4);
|
||
}
|
||
if (JSCode.includes(JavascriptYesCodeStatic[index]["CodeList"][index_]["com4"]) == true) {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptYesCodeStatic[index]["CodeList"][index_]["com4"], CodeData.T_title_en, 2, 4);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return JSCode;
|
||
}
|
||
//全局命令编译
|
||
function JsCodeCompOverallCode(CodeType, JSCode) {
|
||
for (let index = 0; index < JavascriptOverallCode.length; index++) {
|
||
let CodeData = {
|
||
T_title: JavascriptOverallCode[index]["T_title"],
|
||
T_title_en: JavascriptOverallCode[index]["T_title_en"]
|
||
}
|
||
if (CodeType == 1) {
|
||
JSCode = JsCodeReplace(JSCode, CodeData.T_title_en, CodeData.T_title, 2, 5);
|
||
} else {
|
||
JSCode = JsCodeReplace(JSCode, CodeData.T_title, CodeData.T_title_en, 2, 5);
|
||
}
|
||
}
|
||
return JSCode;
|
||
}
|
||
//多层PName命令编译
|
||
function JsCodeCompilerCodePNameAll(CodeType, JSCode) {
|
||
for (let index = 0; index < JavascriptCompilationPNameAll.length; index++) {
|
||
if (JSCode.includes(JavascriptCompilationPNameAll[index]["com1"]) == true || JSCode.includes(JavascriptCompilationPNameAll[index]["com2"]) == true) {
|
||
if (CodeType == 1) {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptCompilationPNameAll[index]["com1"], JavascriptCompilationPNameAll[index]["comEnd2"], 2, 3);
|
||
JSCode = JsCodeReplace(JSCode, JavascriptCompilationPNameAll[index]["com2"], JavascriptCompilationPNameAll[index]["comEnd2"], 2, 3);
|
||
} else {
|
||
JSCode = JsCodeReplace(JSCode, JavascriptCompilationPNameAll[index]["com1"], JavascriptCompilationPNameAll[index]["comEnd1"], 2, 3);
|
||
JSCode = JsCodeReplace(JSCode, JavascriptCompilationPNameAll[index]["com2"], JavascriptCompilationPNameAll[index]["comEnd1"], 2, 3);
|
||
}
|
||
}
|
||
}
|
||
return JSCode;
|
||
}
|
||
//Type-1代表替换转变,2代表转变还原
|
||
function RegularReplacer(code, Type) {
|
||
if (Type == 1) {
|
||
code = code.replaceAll("${", ComSymbol$FOFStuDio);//编译条件点号转编译内容
|
||
code = code.replaceAll(".", Comendfofdianhaobenin);//编译条件点号转编译内容
|
||
}
|
||
if (Type == 2) {
|
||
code = code.replaceAll(Comendfofdianhaobenin, ".");//编译条件点号转编译内容
|
||
code = code.replaceAll(ComSymbol$FOFStuDio, "${");//编译条件点号转编译内容
|
||
}
|
||
return code
|
||
} |