var arrTerm = new Array();
var arrTerm2 = new Array();
var arrMyTerm = new Array();
var arrAllMean = new Array();
var arrTermAllPali = new Array();
var arrWordIdTermId = new Array();
var strTermTanslationTmp = "[%mean%](%pali% %mean2% %mymean%)";
var strTermTanslationTmp2 = "[%mean%]";
var termCounter = new Array();
var noteCounter = 0; //正文内注释计数器
function note(noteId, strDef = "unkow") {
document.write("haha");
}
function note_replace(strIn) {
/*
*/
var output = strIn.replace("/*", "");
return (output);
}
function term_init() {
}
var str_term_fun_word_link = "term_show_win";
function term_word_link_fun(fun_name) {
str_term_fun_word_link = fun_name;
}
//将存储状态的字符串转换为预显示字符串
//设置状态为 0:未处理的原始状态
function term_std_str_to_tran(strIn) {
return (strIn.replace(/\[\[/g, "").replace(/\]\]/g, ""));
}
function term_std_str_to_edit(strIn) {
var arrText = strIn.split("/");
for (var i in arrText) {
//头尾是*
if (arrText[i].substring(0, 1) == "*" && arrText[i].substring(arrText[i].length - 1) == "*") {
var arrOneTermWord = arrText[i].split("@");
if (arrOneTermWord.length == 2) {
arrText[i] = "*" + arrOneTermWord[1];
}
}
}
return (arrText.join("/"));
}
function term_tran_edit_replace(strIn) {
var strEdit = strIn;
for (var x = 0; x < arrTerm2.length; x++) {
var strReplace = "strEdit=strEdit.replace(/" + arrTerm2[x].meaning + "/g,\"/*" + arrTerm2[x].meaning + "*/\")";
eval(strReplace);
}
//strEdit=strEdit.replace(/\/*\/*/g,"\/*");
//strEdit=strEdit.replace(/\*\/\*\//g,"*\/");
return (strEdit);
}
function term_edit_to_std_str(strIn) {
var arrText = strIn.split("/");
for (var i in arrText) {
//头尾是*
if (arrText[i].substring(0, 1) == "*" && arrText[i].substring(arrText[i].length - 1) == "*") {
var wordMeaning = arrText[i].substring(1, arrText[i].length - 1);
arrText[i] = "*" + term_get_std_str(wordMeaning) + "*";
}
}
return (arrText.join("/"));
}
function term_get_std_str(strMean) {
for (var x = 0; x < arrTerm2.length; x++) {
if (arrTerm2[x].meaning == strMean) {
return (arrTerm2[x].guid + "@" + strMean);
}
}
return ("unkow@" + strMean);
}
function term_get_my_std_str(strMean) {
for (var x in arrMyTerm) {
if (arrMyTerm[x].meaning == strMean) {
return (arrMyTerm[x].guid + "@" + strMean);
}
}
return ("unkow@" + strMean);
}
function note_lookup(word, showto) {
$("#" + showto).load("../term/term.php?op=search&word=" + word + "&username=" + getCookie("username"), function (responseTxt, statusTxt, xhr) {
if (statusTxt == "success") {
$(".term_note").each(function (index, element) {
$(this).html(note_init($(this).html()));
$(this).attr("status", 1);
note_refresh_new();
});
}
else if (statusTxt == "error") {
console.error("Error: " + xhr.status + ": " + xhr.statusText);
}
});
}
function note_lookup_guid_json(guid, showto) {
$.get("../term/term.php",
{
op: "load_id",
id: guid,
format: "json"
},
function (data, status) {
let html = "";
if (status == "success") {
try {
let result = JSON.parse(data)[0];
html = "
";
html += "
" + result.word + "
";
html += "
" + result.meaning + "
";
html += "
" + note_init(result.note) + "
";
html += "
";
$("#" + showto).html(html);
note_refresh_new();
}
catch (e) {
console.error("note_lookup_guid_json:" + e + " data:" + data);
}
}
});
}
var term_get_word_to_div_callback = null;
function term_get_word_to_div(strWord, div, callback) {
term_get_word_to_div_callback = callback;
$.get("../term/term.php",
{
op: "get",
word: strWord,
format: "json"
},
function (data, status) {
let html = "";
if (status == "success") {
try {
let result = JSON.parse(data);
let html = "";
if (result.length > 0) {
let type = new Array();
let authors = new Array();
for (x in result) {
if (result[x].tag == "") {
result[x].tag = "_null_";
}
if (type[result[x].tag] == null) {
type[result[x].tag] = new Array();
}
type[result[x].tag].push(result[x].meaning);
authors[result[x].owner] = 1;
}
html += "
";
html += "
";
html += result[0].word;
html += "
";
for (y in type) {
html += "
";
if (y != "_null_") {
html += y + ":";
}
for (k in type[y]) {
html += type[y][k];
}
html += "
";
}
html += "
贡献者:";
for (y in authors) {
html += "" + y + " "
}
html += "
";
html += "
";
for (x in result) {
html += "
";
html += "
";
html += "
";
html += "
";
html += result[x].owner.slice(0, 1);
html += "
";
html += "
";
html += "
" + result[x].meaning;
if (result[x].tag != "_null_") {
html += "" + result[x].tag + "";
}
html += "