469 lines
28 KiB
JavaScript
469 lines
28 KiB
JavaScript
//编译HTML代码的主类
|
||
var JSON1_All = [];//全局属性
|
||
var JSON2_All = [];//全局方法
|
||
var JSON3_All = [];//所有标签
|
||
let JSON3_All_Title_Html_Type1 = [];//存储所有的标签名称,不带<>的标签,与CSS的JSON3_All_Title不同的是,本数组储存所有标签字段,包括其他插件标签
|
||
let JSON3_All_Title_Html_Type2 = [];//存储所有的标签名称,不带<>的标签,与CSS的JSON3_All_Title不同的是,本数组储存所有标签字段,包括其他插件标签
|
||
var CompilerIntAll = [];//标签的中文数组
|
||
var CompilerIntAllEn = [];//标签的英文数组
|
||
var CompilerHtml = [];//所有的HTML标签,不带<>符号的纯标签名
|
||
var iframeCompilerSrcdoc = [];//iframe标签属性Srcdoc的中文英名称记录,成员1英文,成员2中文
|
||
let HTMLcompilationFun = [];//所有的全局方法,单独储存,通常用作JS编译
|
||
let HTMLcompilationAttr = [];//所有的属性、全局属性、三方属性,单独储存,通常用作JS编译
|
||
let HTMLTripartiteClass = [];//所有的三方HTML类名
|
||
let NOHtmlCodeJSonCompilerStr = [];//储存所有编译HTML时产生的临时数据,该变量中的临时数据将不会参与到HTml编译!
|
||
/*
|
||
初始化HTML编译数据
|
||
@C_JSON-HTML编译数据
|
||
*/
|
||
function JSONCompilerInt_All(C_JSON, HTMLcompilationFun_, HTMLcompilationAttr_, CompilerHtml_, HTMLTripartiteClass_) {
|
||
HTMLcompilationFun = HTMLcompilationFun_;
|
||
HTMLcompilationAttr = HTMLcompilationAttr_;
|
||
CompilerHtml = CompilerHtml_;
|
||
HTMLTripartiteClass = HTMLTripartiteClass_;
|
||
JSONCompilerInt(C_JSON["GlobalProperties"], C_JSON["GlobalMethod"], C_JSON["AllHtmlCommands"]);
|
||
}
|
||
//初始化编译器JSON
|
||
//参数1全局属性,参数2是全局方法,参数3是标签JSON
|
||
function JSONCompilerInt(C_JSON1, C_JSON2, C_JSON3) {
|
||
JSON1_All = C_JSON1
|
||
JSON2_All = C_JSON2
|
||
JSON3_All = C_JSON3
|
||
for (let index = 0; index < JSON3_All.length; index++) {
|
||
let element = JSON3_All[index];
|
||
CompilerIntAll[CompilerIntAll.length] = element["title"].toLowerCase();
|
||
CompilerIntAllEn[CompilerIntAllEn.length] = element["title_en"].toLowerCase();
|
||
}
|
||
}
|
||
//开始编译HTML代码
|
||
//htmlCode-要编译的HTMl代码
|
||
//htmlStrAll-代表所获取的所有标签
|
||
//CodeType-编译的类型,1代表编译成本地语言,2代表编译成英文
|
||
//【注意:本地语言,例如中文、柬埔寨或者其他国家语言以正则为主,目前暂时支持中文】
|
||
function ForHtmlCode(htmlCode, CodeType, FileID) {
|
||
let htmlCodeStr = htmlCode;
|
||
htmlCodeStr = CssCodeCompilerAll(htmlCodeStr, CodeType)
|
||
htmlCodeStr = JsCodeCompilerAll(htmlCodeStr, CodeType, FileID)
|
||
|
||
htmlCodeStr = HtmlCodeMultiline(htmlCodeStr, 1);
|
||
htmlCodeStr = NoHTMLStrCompiler(htmlCodeStr, 1);
|
||
if (JSON3_All_Title_Html_Type1.length <= 0) {
|
||
for (let index = 0; index < JSON3_All.length; index++) {
|
||
let LableName = [];
|
||
LableName = [JSON3_All[index]["title"], JSON3_All[index]["title_en"]]
|
||
let K01 = [LableName[0], LableName[1]]
|
||
LableName[0] = LableName[0].replaceHack("<", "");
|
||
LableName[0] = LableName[0].replaceHack(">", "");
|
||
LableName[1] = LableName[1].replaceHack("<", "");
|
||
LableName[1] = LableName[1].replaceHack(">", "");
|
||
JSON3_All_Title_Html_Type1[JSON3_All_Title_Html_Type1.length] = {
|
||
"l0": LableName[0],
|
||
"l1": LableName[1],
|
||
"l2": "</" + LableName[1] + ">",
|
||
"l3": "</" + LableName[0] + ">",
|
||
"l4": "<" + LableName[1] + ">",
|
||
"l5": "<" + LableName[0] + ">",
|
||
"l6": "</" + LableName[1] + " ",
|
||
"l7": "</" + LableName[0] + " ",
|
||
"l8": "<" + LableName[1] + " ",
|
||
"l9": "<" + LableName[0] + " ",
|
||
"k0": K01[0],
|
||
"k1": K01[1],
|
||
"c0": "<" + LableName[1],
|
||
"c1": "<" + LableName[0],
|
||
"c2": "<" + LableName[1]
|
||
}
|
||
}
|
||
}
|
||
if (JSON3_All_Title_Html_Type2.length <= 0) {
|
||
for (let index = 0; index < JSON3_All.length; index++) {
|
||
let LableName = [];
|
||
LableName = [JSON3_All[index]["title_en"], JSON3_All[index]["title"]]
|
||
let K01 = [LableName[0], LableName[1]]
|
||
LableName[0] = LableName[0].replaceHack("<", "");
|
||
LableName[0] = LableName[0].replaceHack(">", "");
|
||
LableName[1] = LableName[1].replaceHack("<", "");
|
||
LableName[1] = LableName[1].replaceHack(">", "");
|
||
JSON3_All_Title_Html_Type2[JSON3_All_Title_Html_Type2.length] = {
|
||
"l0": LableName[0],
|
||
"l1": LableName[1],
|
||
"l2": "</" + LableName[1] + ">",
|
||
"l3": "</" + LableName[0] + ">",
|
||
"l4": "<" + LableName[1] + ">",
|
||
"l5": "<" + LableName[0] + ">",
|
||
"l6": "</" + LableName[1] + " ",
|
||
"l7": "</" + LableName[0] + " ",
|
||
"l8": "<" + LableName[1] + " ",
|
||
"l9": "<" + LableName[0] + " ",
|
||
"k0": K01[0],
|
||
"k1": K01[1],
|
||
"c0": "<" + LableName[1],
|
||
"c1": "<" + LableName[0],
|
||
"c2": "<" + LableName[1]
|
||
}
|
||
}
|
||
}
|
||
if (CodeType == 1) {
|
||
JSON3_All_Title_Html = JSON3_All_Title_Html_Type1
|
||
} else {
|
||
JSON3_All_Title_Html = JSON3_All_Title_Html_Type2
|
||
}
|
||
for (let index = 0; index < JSON3_All.length; index++) {
|
||
if (htmlCodeStr.indexOf(JSON3_All_Title_Html[index]["l2"]) != -1) {
|
||
htmlCodeStr = htmlCodeStr.replaceAll(JSON3_All_Title_Html[index]["l2"], JSON3_All_Title_Html[index]["l3"]);
|
||
}
|
||
if (htmlCodeStr.indexOf(JSON3_All_Title_Html[index]["l4"]) != -1) {
|
||
htmlCodeStr = htmlCodeStr.replaceAll(JSON3_All_Title_Html[index]["l4"], JSON3_All_Title_Html[index]["l5"]);
|
||
}
|
||
if (htmlCodeStr.indexOf(JSON3_All_Title_Html[index]["l6"]) != -1) {
|
||
htmlCodeStr = htmlCodeStr.replaceAll(JSON3_All_Title_Html[index]["l6"], JSON3_All_Title_Html[index]["l7"]);
|
||
}
|
||
if (htmlCodeStr.indexOf(JSON3_All_Title_Html[index]["l8"]) != -1) {
|
||
htmlCodeStr = htmlCodeStr.replaceAll(JSON3_All_Title_Html[index]["l8"], JSON3_All_Title_Html[index]["l9"]);
|
||
}
|
||
}
|
||
for (let index = 0; index < JSON3_All.length; index++) {
|
||
let LableName = [JSON3_All_Title_Html[index]["l0"], JSON3_All_Title_Html[index]["l1"]];
|
||
let LableNameArr = ["", ""];
|
||
if (htmlCodeStr.indexOf(JSON3_All_Title_Html[index]["c0"]) != -1) {
|
||
LableNameArr[0] = TakeTheMiddleOfTheTextAll(htmlCodeStr, JSON3_All_Title_Html[index]["c0"], ">");
|
||
} else {
|
||
LableNameArr[0] = []
|
||
}
|
||
if (htmlCodeStr.indexOf(JSON3_All_Title_Html[index]["c1"]) != -1) {
|
||
LableNameArr[2] = TakeTheMiddleOfTheTextAll(htmlCodeStr, JSON3_All_Title_Html[index]["c1"], ">");
|
||
} else {
|
||
LableNameArr[2] = []
|
||
}
|
||
if (htmlCodeStr.indexOf(JSON3_All_Title_Html[index]["c2"]) != -1) {
|
||
LableNameArr[1] = TakeTheMiddleOfTheTextAll(htmlCodeStr, JSON3_All_Title_Html[index]["c2"], ">");
|
||
} else {
|
||
LableNameArr[1] = []
|
||
}
|
||
|
||
for (let index_ = 0; index_ < LableNameArr[2].length; index_++) {
|
||
if (LableNameArr[2][index_].indexOf("</") != -1) {
|
||
continue;
|
||
}
|
||
LableNameArr[0][LableNameArr[0].length] = LableNameArr[2][index_];
|
||
LableNameArr[1][LableNameArr[1].length] = LableNameArr[2][index_];
|
||
}
|
||
for (let index_ = 0; index_ < LableNameArr[0].length; index_++) {
|
||
if (LableNameArr[0][index_].indexOf("</") != -1) {
|
||
continue;
|
||
}
|
||
if (LableNameArr[0][index_].indexOf("<" + LableName[1] + " ") != -1) {
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack("<" + LableName[1] + " ", "<" + LableName[0] + " ");
|
||
}
|
||
if (LableNameArr[0][index_].indexOf("<" + LableName[1] + ">") != -1) {
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack("<" + LableName[1] + ">", "<" + LableName[0] + ">");
|
||
}
|
||
//上面已经编译完毕标签,开始编译属性及属性值
|
||
for (let indexAttr = 0; indexAttr < JSON3_All[index]["children"].length; indexAttr++) {
|
||
let StyCodeYs = "";//原始的行内样式代码
|
||
if (LableNameArr[0][index_].indexOf(`style="`) != -1 || LableNameArr[0][index_].indexOf(`行内样式="`) != -1 || LableNameArr[0][index_].indexOf(`style='`) != -1 || LableNameArr[0][index_].indexOf(`行内样式='`) != -1) {
|
||
if (LableNameArr[0][index_].indexOf(`style="`) != -1) {
|
||
let ifreplace = false;
|
||
let StyCode = TakeTheMiddleOfTheTextAll(LableNameArr[0][index_], "style=\"", "\" ");
|
||
if (StyCode != undefined) {
|
||
if (StyCode.length >= 1) {
|
||
StyCodeYs = StyCode[0];
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack(StyCode[0], " fofstudioStyCodeYs ")
|
||
ifreplace = true;
|
||
}
|
||
}
|
||
if (ifreplace == false) {
|
||
let StyCode = TakeTheMiddleOfTheTextAll(LableNameArr[0][index_], "style=\"", "\">");
|
||
if (StyCode != undefined) {
|
||
if (StyCode.length >= 1) {
|
||
StyCodeYs = StyCode[0];
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack(StyCode[0], " fofstudioStyCodeYs ")
|
||
ifreplace = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (LableNameArr[0][index_].indexOf(`style='`) != -1) {
|
||
let ifreplace = false;
|
||
let StyCode = TakeTheMiddleOfTheTextAll(LableNameArr[0][index_], "style='", "' ");
|
||
if (StyCode != undefined) {
|
||
if (StyCode.length >= 1) {
|
||
StyCodeYs = StyCode[0];
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack(StyCode[0], " fofstudioStyCodeYs ")
|
||
ifreplace = true;
|
||
}
|
||
}
|
||
if (ifreplace == false) {
|
||
let StyCode = TakeTheMiddleOfTheTextAll(LableNameArr[0][index_], "style='", "'>");
|
||
if (StyCode != undefined) {
|
||
if (StyCode.length >= 1) {
|
||
StyCodeYs = StyCode[0];
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack(StyCode[0], " fofstudioStyCodeYs ")
|
||
ifreplace = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (LableNameArr[0][index_].indexOf(`行内样式="`) != -1) {
|
||
let ifreplace = false;
|
||
let StyCode = TakeTheMiddleOfTheTextAll(LableNameArr[0][index_], "行内样式=\"", "\" ");
|
||
if (StyCode != undefined) {
|
||
if (StyCode.length >= 1) {
|
||
StyCodeYs = StyCode[0];
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack(StyCode[0], " fofstudioStyCodeYs ")
|
||
ifreplace = true;
|
||
}
|
||
}
|
||
if (ifreplace == false) {
|
||
let StyCode = TakeTheMiddleOfTheTextAll(LableNameArr[0][index_], "行内样式=\"", "\">");
|
||
if (StyCode != undefined) {
|
||
if (StyCode.length >= 1) {
|
||
StyCodeYs = StyCode[0];
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack(StyCode[0], " fofstudioStyCodeYs ")
|
||
ifreplace = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (LableNameArr[0][index_].indexOf(`行内样式='`) != -1) {
|
||
let ifreplace = false;
|
||
let StyCode = TakeTheMiddleOfTheTextAll(LableNameArr[0][index_], "行内样式='", "' ");
|
||
if (StyCode != undefined) {
|
||
if (StyCode.length >= 1) {
|
||
StyCodeYs = StyCode[0];
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack(StyCode[0], " fofstudioStyCodeYs ")
|
||
ifreplace = true;
|
||
}
|
||
}
|
||
if (ifreplace == false) {
|
||
let StyCode = TakeTheMiddleOfTheTextAll(LableNameArr[0][index_], "行内样式='", "'>");
|
||
if (StyCode != undefined) {
|
||
if (StyCode.length >= 1) {
|
||
StyCodeYs = StyCode[0];
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack(StyCode[0], " fofstudioStyCodeYs ")
|
||
ifreplace = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
let LableNameAttr = [];
|
||
if (CodeType == 1) {
|
||
LableNameAttr = [JSON3_All[index]["children"][indexAttr]["title"], JSON3_All[index]["children"][indexAttr]["title_en"]]
|
||
} else {
|
||
LableNameAttr = [JSON3_All[index]["children"][indexAttr]["title_en"], JSON3_All[index]["children"][indexAttr]["title"]]
|
||
}
|
||
if (LableNameArr[0][index_].indexOf("=\" ") != -1) {
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceAll("=\" ", "htmlkonggeshuangyinhaotihuanfofstudio")//*
|
||
}
|
||
if (LableNameArr[0][index_].indexOf("=' ") != -1) {
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceAll("=' ", "htmlkonggedanyinhaotihuanfofstudio")//*
|
||
}
|
||
if (LableNameArr[0][index_].indexOf("\"") != -1) {
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceAll("\"", "htmlshuangyinhaotihuanfofstudio")//*
|
||
}
|
||
if (LableNameArr[0][index_].indexOf("'") != -1) {
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceAll("'", "htmldanyinhaotihuanfofstudio")//*
|
||
}
|
||
let reg = new RegExp("[^0-9a-zA-Z\u4e00-\u9fa5_-]" + LableNameAttr[1] + "(?=[^0-9a-zA-Z\u4e00-\u9fa5_-])", "g");
|
||
let Original = LableNameArr[0][index_]
|
||
if (Original.indexOf(LableNameAttr[1]) != -1) {
|
||
let OriginalStrArr = Original.match(reg);
|
||
if (OriginalStrArr != undefined && OriginalStrArr != null) {
|
||
if (OriginalStrArr.length >= 1) {
|
||
let regCompilerCodeArr = [StrCodeUuid(LableNameAttr[0]), LableNameAttr[0]];
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack(reg, regCompilerCodeArr[0]);
|
||
for (let index = 0; index < OriginalStrArr.length; index++) {
|
||
let FirstText = OriginalStrArr[index].substring(0, 1);
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceHack(regCompilerCodeArr[0], FirstText + regCompilerCodeArr[1]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (LableNameArr[0][index_].indexOf("htmldanyinhaotihuanfofstudio") != -1) {
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceAll("htmldanyinhaotihuanfofstudio", "'")//*
|
||
}
|
||
if (LableNameArr[0][index_].indexOf("htmlshuangyinhaotihuanfofstudio") != -1) {
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceAll("htmlshuangyinhaotihuanfofstudio", "\"")//*
|
||
}
|
||
if (LableNameArr[0][index_].indexOf("htmlkonggeshuangyinhaotihuanfofstudio") != -1) {
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceAll("htmlkonggeshuangyinhaotihuanfofstudio", "=\" ")//*
|
||
}
|
||
if (LableNameArr[0][index_].indexOf("htmlkonggedanyinhaotihuanfofstudio") != -1) {
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replaceAll("htmlkonggedanyinhaotihuanfofstudio", "=' ")//*
|
||
}
|
||
let LableNameAttrArrData = [];
|
||
if (LableNameArr[0][index_].indexOf(LableNameAttr[0] + "=\"") != -1) {
|
||
LableNameAttrArrData = TakeTheMiddleOfTheTextAll(LableNameArr[0][index_], LableNameAttr[0] + "=\"", "\"");
|
||
if (LableNameAttrArrData.length >= 1) {
|
||
LableNameArr[0][index_] = LableNameAttrArrDataCompiler(LableNameArr[0][index_], LableNameAttrArrData, index, indexAttr, CodeType, LableNameAttr[0])
|
||
}
|
||
}
|
||
if (LableNameArr[0][index_].indexOf(LableNameAttr[0] + "='") != -1) {
|
||
LableNameAttrArrData = TakeTheMiddleOfTheTextAll(LableNameArr[0][index_], LableNameAttr[0] + "='", "'");
|
||
if (LableNameAttrArrData.length >= 1) {
|
||
LableNameArr[0][index_] = LableNameAttrArrDataCompiler(LableNameArr[0][index_], LableNameAttrArrData, index, indexAttr, CodeType, LableNameAttr[0])
|
||
}
|
||
}
|
||
LableNameArr[0][index_] = LableNameArr[0][index_].replace(" fofstudioStyCodeYs ", StyCodeYs)
|
||
}
|
||
//开始进行全局属性的编译
|
||
LableNameArr[0][index_] = GlobalAttributes(LableNameArr[0][index_], CodeType)
|
||
//三方模块自定义属性的编译
|
||
LableNameArr[0][index_] = UserAttributes(LableNameArr[0][index_], CodeType)
|
||
//开始进行全局方法的编译
|
||
LableNameArr[0][index_] = GlobalFun(LableNameArr[0][index_], CodeType, FileID)
|
||
//开始进行全局样式的编译
|
||
LableNameArr[0][index_] = Globalstyle(LableNameArr[0][index_], CodeType, FileID)
|
||
//开始进行全局Class的编译
|
||
LableNameArr[0][index_] = GlobalClass(LableNameArr[0][index_], CodeType, FileID)
|
||
//开始进行三方模块的自定义类名编译
|
||
LableNameArr[0][index_] = UserClassData(LableNameArr[0][index_], CodeType, FileID)
|
||
//开始进行srcdoc的编译
|
||
LableNameArr[0][index_] = Globalsrcdoc(LableNameArr[0][index_], CodeType)
|
||
htmlCodeStr = htmlCodeStr.replaceHack(LableNameArr[1][index_], LableNameArr[0][index_]);
|
||
}
|
||
|
||
}
|
||
htmlCodeStr = NoHTMLStrCompiler(htmlCodeStr, 2);
|
||
htmlCodeStr = HtmlCodeMultiline(htmlCodeStr, 2);
|
||
htmlCodeStr = htmlCodeStr.replaceAll("图像文件*", "图像文件")
|
||
htmlCodeStr = htmlCodeStr.replaceAll("图像文件/*", "图像文件")
|
||
htmlCodeStr = htmlCodeStr.replaceAll("image/**", "image/*")
|
||
return htmlCodeStr;
|
||
}
|
||
//LableNameCode-需要进行替换的某匹配标签整体内容
|
||
//LableNameAttrArrData-匹配到该标签中某个属性的所有属性内容,例如:[xxxx="kkkk",ssssss="kkkk"]
|
||
//LableIndex-当前遍历的标签位置
|
||
//indexAttr-当前遍历的标签的属性位置
|
||
//CodeType-编译类别
|
||
//NameAttr-属性名称
|
||
function LableNameAttrArrDataCompiler(LableNameCode, LableNameAttrArrData, LableIndex, indexAttr, CodeType, NameAttr) {
|
||
for (let index = 0; index < LableNameAttrArrData.length; index++) {
|
||
let StrOg = LableNameAttrArrData[index];
|
||
for (let indexAttrData = 0; indexAttrData < JSON3_All[LableIndex]["children"][indexAttr]["children"].length; indexAttrData++) {
|
||
if (JSON3_All[LableIndex]["children"][indexAttr]["title_en"].indexOf(NameAttr) != -1 && StrOg.indexOf(NameAttr) != -1 || JSON3_All[LableIndex]["children"][indexAttr]["title"].indexOf(NameAttr) != -1 && StrOg.indexOf(NameAttr) != -1) {
|
||
if (NameAttr.toLowerCase() != "id") {
|
||
let indexAttrDataArr = [];
|
||
if (CodeType == 1) {
|
||
indexAttrDataArr = [JSON3_All[LableIndex]["children"][indexAttr]["children"][indexAttrData]["title"], JSON3_All[LableIndex]["children"][indexAttr]["children"][indexAttrData]["title_en"]]
|
||
} else {
|
||
indexAttrDataArr = [JSON3_All[LableIndex]["children"][indexAttr]["children"][indexAttrData]["title_en"], JSON3_All[LableIndex]["children"][indexAttr]["children"][indexAttrData]["title"]]
|
||
}
|
||
if (LableNameCode.indexOf("<meta") != -1 || LableNameCode.indexOf("<网页信息") != -1) {
|
||
LableNameCode = LableNameAttrArrDataCompilerMate(LableNameCode, indexAttrDataArr)
|
||
} else {
|
||
if (NameAttr.toLowerCase() != "name") {
|
||
let reg = new RegExp("[^0-9a-zA-Z\u4e00-\u9fa5_-]" + indexAttrDataArr[1] + "(?=[^0-9a-zA-Z\u4e00-\u9fa5_-])", "g");
|
||
let Original = LableNameAttrArrData[index];//*
|
||
let regCompilerCodeArr = [StrCodeUuid(indexAttrDataArr[0]), indexAttrDataArr[0]];
|
||
LableNameAttrArrData[index] = LableNameAttrArrData[index].replaceHack(reg, regCompilerCodeArr[0]);//*
|
||
let OriginalStrArr = Original.match(reg);
|
||
if (OriginalStrArr != undefined && OriginalStrArr != null) {
|
||
if (OriginalStrArr.length >= 1) {
|
||
for (let index_ = 0; index_ < OriginalStrArr.length; index_++) {
|
||
let FirstText = OriginalStrArr[index_].substring(0, 1);
|
||
LableNameAttrArrData[index] = LableNameAttrArrData[index].replaceHack(regCompilerCodeArr[0], FirstText + regCompilerCodeArr[1]);//*
|
||
}
|
||
}
|
||
}
|
||
LableNameCode = LableNameCode.replaceHack(StrOg, LableNameAttrArrData[index]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return LableNameCode;
|
||
}
|
||
function LableNameAttrArrDataCompilerMate(LableNameCode, indexAttrDataArr) {
|
||
LableNameCode = LableNameCode.replaceHack(" " + indexAttrDataArr[1] + " ", " " + indexAttrDataArr[0] + " ");
|
||
LableNameCode = LableNameCode.replaceHack("," + indexAttrDataArr[1] + " ", "," + indexAttrDataArr[0] + " ");
|
||
LableNameCode = LableNameCode.replaceHack("," + indexAttrDataArr[1] + ",", "," + indexAttrDataArr[0] + ",");
|
||
LableNameCode = LableNameCode.replaceHack(" " + indexAttrDataArr[1] + ",", " " + indexAttrDataArr[0] + ",");
|
||
LableNameCode = LableNameCode.replaceHack("\"" + indexAttrDataArr[1] + " ", "\"" + indexAttrDataArr[0] + " ");
|
||
LableNameCode = LableNameCode.replaceHack("'" + indexAttrDataArr[1] + " ", "'" + indexAttrDataArr[0] + " ");
|
||
LableNameCode = LableNameCode.replaceHack("'" + indexAttrDataArr[1] + ",", "'" + indexAttrDataArr[0] + ",");
|
||
LableNameCode = LableNameCode.replaceHack("\"" + indexAttrDataArr[1] + ",", "\"" + indexAttrDataArr[0] + ",");
|
||
LableNameCode = LableNameCode.replaceHack("\"" + indexAttrDataArr[1] + "\"", "\"" + indexAttrDataArr[0] + "\"");
|
||
LableNameCode = LableNameCode.replaceHack("'" + indexAttrDataArr[1] + "'", "'" + indexAttrDataArr[0] + "'");
|
||
LableNameCode = LableNameCode.replaceHack(" " + indexAttrDataArr[1] + "'", " " + indexAttrDataArr[0] + "'");
|
||
LableNameCode = LableNameCode.replaceHack(" " + indexAttrDataArr[1] + ",", " " + indexAttrDataArr[0] + ",");
|
||
LableNameCode = LableNameCode.replaceHack(" " + indexAttrDataArr[1] + "\"", " " + indexAttrDataArr[0] + "\"");
|
||
LableNameCode = LableNameCode.replaceHack("\"" + indexAttrDataArr[1] + "=", "\"" + indexAttrDataArr[0] + "=");
|
||
LableNameCode = LableNameCode.replaceHack("=" + indexAttrDataArr[1] + ",", "=" + indexAttrDataArr[0] + ",");
|
||
LableNameCode = LableNameCode.replaceHack("," + indexAttrDataArr[1] + "=", "," + indexAttrDataArr[0] + "=");
|
||
LableNameCode = LableNameCode.replaceHack("\" " + indexAttrDataArr[1] + "=", "\" " + indexAttrDataArr[0] + "=");
|
||
LableNameCode = LableNameCode.replaceHack("= " + indexAttrDataArr[1] + ",", "= " + indexAttrDataArr[0] + ",");
|
||
LableNameCode = LableNameCode.replaceHack(", " + indexAttrDataArr[1] + "=", ", " + indexAttrDataArr[0] + "=");
|
||
LableNameCode = LableNameCode.replaceHack("=" + indexAttrDataArr[1] + "\"", "=" + indexAttrDataArr[0] + "\"");
|
||
LableNameCode = LableNameCode.replaceHack("= " + indexAttrDataArr[1] + "\"", "= " + indexAttrDataArr[0] + "\"");
|
||
LableNameCode = LableNameCode.replaceHack(" =" + indexAttrDataArr[1] + "\"", " =" + indexAttrDataArr[0] + "\"");
|
||
LableNameCode = LableNameCode.replaceHack(" = " + indexAttrDataArr[1] + "\"", " = " + indexAttrDataArr[0] + "\"");
|
||
|
||
LableNameCode = LableNameCode.replaceHack("=" + indexAttrDataArr[1] + "'", "=" + indexAttrDataArr[0] + "'");
|
||
LableNameCode = LableNameCode.replaceHack("= " + indexAttrDataArr[1] + "'", "= " + indexAttrDataArr[0] + "'");
|
||
LableNameCode = LableNameCode.replaceHack(" =" + indexAttrDataArr[1] + "'", " =" + indexAttrDataArr[0] + "'");
|
||
LableNameCode = LableNameCode.replaceHack(" = " + indexAttrDataArr[1] + "'", " = " + indexAttrDataArr[0] + "'");
|
||
|
||
LableNameCode = LableNameCode.replaceHack(" = " + indexAttrDataArr[1] + "'", " = " + indexAttrDataArr[0] + "'");
|
||
LableNameCode = LableNameCode.replaceHack(" = " + indexAttrDataArr[1] + "\"", "= " + indexAttrDataArr[0] + "\"");
|
||
return LableNameCode;
|
||
}
|
||
//不参与编译的HTML相关数据
|
||
//1代表编译的代码,2代表类型【1是开头,2是结束】
|
||
function NoHTMLStrCompiler(HtmlCode, IfType) {
|
||
if (IfType == 1) {
|
||
HtmlCode = HtmlCode.replaceAll("<!--不翻译开始", "kkcoshtmlbegintihuan")
|
||
HtmlCode = HtmlCode.replaceAll("不翻译结束-->", "fanbeginkkcoshtmltihuan")
|
||
StringObj = TakeTheMiddleOfTheTextAll(HtmlCode, "kkcoshtmlbegintihuan", "fanbeginkkcoshtmltihuan")
|
||
if (StringObj != undefined && StringObj != null) {
|
||
if (StringObj.length >= 1) {
|
||
for (let index = 0; index < StringObj.length; index++) {
|
||
let StrCodeLs = [StrCodeUuid(StringObj[index]), StringObj[index]]
|
||
HtmlCode = HtmlCode.replaceHack(StringObj[index], StrCodeLs[0])
|
||
NOHtmlCodeJSonCompilerStr[NOHtmlCodeJSonCompilerStr.length] = StrCodeLs;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (IfType == 2) {
|
||
for (let index = 0; index < NOHtmlCodeJSonCompilerStr.length; index++) {
|
||
let StrCodeLs = NOHtmlCodeJSonCompilerStr[NOHtmlCodeJSonCompilerStr.length - index - 1]
|
||
HtmlCode = HtmlCode.replaceHack(StrCodeLs[0], StrCodeLs[1])
|
||
}
|
||
HtmlCode = HtmlCode.replaceAll("kkcoshtmlbegintihuan", "<!--不翻译开始")
|
||
HtmlCode = HtmlCode.replaceAll("fanbeginkkcoshtmltihuan", "不翻译结束-->")
|
||
}
|
||
return HtmlCode;
|
||
}
|
||
function HtmlCodeMultiline(htmlStr, ifStr = 1) {
|
||
if (ifStr == 1) {
|
||
htmlStr = htmlStr.replaceAll("\r\n", " KKCOSAPPFOFCODEIDE20131101315789 ");
|
||
htmlStr = htmlStr.replaceAll("\n", " KKCOSAPPFOFCODEIDE10131101315789 ");
|
||
return htmlStr;
|
||
}
|
||
htmlStr = htmlStr.replaceAll(" KKCOSAPPFOFCODEIDE20131101315789 ", "\r\n");
|
||
htmlStr = htmlStr.replaceAll(" KKCOSAPPFOFCODEIDE10131101315789 ", "\n");
|
||
return htmlStr;
|
||
}
|
||
//判断是否双引号或者单引号单数
|
||
function HtmlCountOccurrences(str) {
|
||
let syhLetInt = str.split("\"").length - 1;
|
||
if (syhLetInt >= 1) {
|
||
if (syhLetInt % 2 === 0) {
|
||
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
syhLetInt = str.split("'").length - 1;
|
||
if (syhLetInt >= 1) {
|
||
if (syhLetInt % 2 === 0) {
|
||
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
} |