var _id = "";
var _word = "";
var _channel = "";
var _lang = "";
var _author = "";
var _active = "";
var _term_list;
function wiki_index_init() {}
function term_render_word_to_div(strWord,eDiv) {
let word = [{ pali: strWord, channal: "", editor: "", lang: "" }];
$.post(
"../term/term_get.php",
{
words: JSON.stringify(word),
},
function (data, status) {
let html = "";
if (status == "success") {
try {
let result = JSON.parse(data);
if (result.length > 0) {
_term_list = result;
//生成头部信息
let type = new Array();
let authors = new Array();
//计算所有贡献者
for (const iterator of result) {
if (iterator.tag == "") {
iterator.tag = "_null_";
}
if (type[iterator.tag] == null) {
type[iterator.tag] = new Array();
}
type[iterator.tag].push(iterator.meaning);
authors[iterator.owner] = iterator.user;
}
html += "
";
html += "
";
html += result[0].word;
$("#page_title").text(result[0].word + "-" + gLocal.gui.encyclopedia);
html += "
";
for (y in type) {
html += "
";
if (y != "_null_") {
html += y + ":";
}
for (k in type[y]) {
html += type[y][k];
}
html += "
";
}
html += "
" + gLocal.gui.contributor + ":";
for (y in authors) {
if (authors[y].nickname != "") {
html += '' + authors[y].nickname + " ";
} else {
html += '' + y + " ";
}
}
html += "
";
html += "
";
$("#wiki_head").html(html);
// end of term_word_head
html = "";
html += "
";
html += "
";
for (const iterator of result) {
if (iterator.tag == "_null_") {
iterator.tag = "";
}
html += "
";
html += "
";
html += "
";
html += "
";
html += iterator.user.nickname.slice(0, 1);
html += "
";
html += "
";
html += "
" + iterator.user.nickname + "
";
html += "
" + iterator.meaning;
if (iterator.tag != "_null_") {
html += "" + iterator.tag + "";
}
html += "
";
html += "
";
html += "
";
html += "
";
html += "";
if (!iterator.readonly) {
html +=
"";
}
html += "";
html +=
"";
html += "
";
html += "
";
//term_block_bar 结束
html +=
"
" +
note_init(iterator.note) +
"
";
html += "";
//html += "
";
}
html += "
";
//end of right
html += "
";
// end of term_list_div
} else {
if (_active != "new"){
html = "词条尚未创建 现在创建";
}
else{
html = "无";
}
}
$("#"+eDiv).html(html);
note_refresh_new();
document.title = result[0].word + "[" + result[0].meaning + "]-圣典百科";
} catch (e) {
console.error("term_render_word_to_div:" + e + " data:" + data);
}
} else {
console.error("term error:" + data);
}
}
);
}
function wiki_term_edit(id) {
for (const iterator of _term_list) {
if (iterator.guid == id) {
$("#term_edit_" + id).html(render_term_form(iterator));
$("#term_edit_" + id).show();
$(".term_note[guid='" + id + "']").hide();
return id;
}
}
return false;
}
function term_edit_cancel() {
$(".term_edit").hide();
$(".term_edit").html("");
$(".term_note").show();
}
function render_term_form(item) {
let html = "";
html += "";
html += "";
if (item.guid != "") {
html += "";
}
return html;
}
function term_render_new_word(title, word) {
let html = "";
html += "
" + title + "
";
$("#wiki_head").html(html);
html = render_term_form({
guid: "",
word: word,
meaning: "",
other_meaning: "",
owner: "",
channel: _channel,
language: "",
tag: "",
note: "",
});
html += "
其他解释
"
html += "
loading……
"
$("#wiki_body_left").html(html);
term_render_word_to_div(word,"term_list");
}
function term_save() {
if ($("#form_word").val() == "") {
alert(gLocal.gui.pali_word + " 不能为空");
return;
}
if ($("#form_mean").val() == "") {
alert(gLocal.gui.first_choice_word + "不能为空");
return;
}
if ($("#form_lang").val() == "") {
alert(gLocal.gui.language + "不能为空");
return;
}
$.ajax({
type: "POST", //方法类型
dataType: "json", //预期服务器返回的数据类型
url: "../term/term_post.php", //url
data: $("#form_term").serialize(),
success: function (result) {
console.log(result); //打印服务端返回的数据(调试用)
if (result.status == 0) {
alert(result.message + gLocal.gui.saved + gLocal.gui.successful);
window.location.assign("../wiki/wiki.php?word=" + result.message);
} else {
alert("error:" + result.message);
}
},
error: function (data, status) {
alert("异常!" + data.responseText);
switch (status) {
case "timeout":
break;
case "error":
break;
case "notmodified":
break;
case "parsererror":
break;
default:
break;
}
},
});
}
function wiki_load_id(guid) {
note_create();
note_lookup_guid_json(guid, "wiki_body_left");
}
function wiki_load_word(word) {
note_create();
if (_active == "new") {
term_render_new_word(gLocal.gui.new_technic_term, word);
}else{
term_render_word_to_div(word,"wiki_body_left");
}
}
function wiki_goto_word(guid, strWord) {
window.open("wiki.php?word=" + strWord, "_blank");
}
function wiki_word_loaded(wordlist) {
$("#doc_title").text(wordlist[0].word + "[" + wordlist[0].meaning + "]-圣典百科");
}
function term_show_win(guid, word) {
window.location.assign("wiki.php?word=" + word);
}
function wiki_search_keyup(e, obj) {
var keynum;
var keychar;
var numcheck;
if ($("#wiki_search_input").val() == "") {
$("#search_result").html("");
return;
}
if (window.event) {
// IE
keynum = e.keyCode;
} else if (e.which) {
// Netscape/Firefox/Opera
keynum = e.which;
}
var keychar = String.fromCharCode(keynum);
if (keynum == 13) {
window.location.assign("wiki.php?word=" + obj.value);
} else {
wiki_pre_search(obj.value);
}
}
function wiki_pre_search(keyword) {
$.get(
"../term/term.php",
{
op: "pre",
word: keyword,
format: "json",
},
function (data, status) {
let result = JSON.parse(data);
let html = "
";
if (result.length > 0) {
for (x in result) {
html +=
"