标签作为气泡注释
popup_init();
//刷新句子链接递归,有加层数限制。
note_refresh_new();
_arrData = _arrData.concat(sentData);
note_ref_init();
term_get_dict();
note_channal_list();
refresh_pali_script();
} catch (e) {
console.error(e);
}
}
}
);
} else {
//term_get_dict();
}
}
//生成channel列表
function note_channal_list() {
console.log("note_channal_list start");
let arrSentInfo = new Array();
$("note").each(function () {
let info = $(this).attr("info");
if (info && info != "") {
arrSentInfo.push({ id: "", data: info });
}
});
if (arrSentInfo.length > 0) {
$.post(
"../term/channal_list.php",
{
setting: "",
data: JSON.stringify(arrSentInfo),
},
function (data, status) {
if (status == "success") {
try {
let active = JSON.parse(data);
_channalData = active;
for (const iterator of _my_channal) {
let found = false;
for (const one of active) {
if (iterator.id == one.id) {
found = true;
break;
}
}
if (found == false) {
_channalData.push(iterator);
}
}
let strHtml = "";
for (const iterator of _channalData) {
if (_channal.indexOf(iterator.id) >= 0) {
strHtml += render_channal_list(iterator);
}
}
for (const iterator of _channalData) {
if (_channal.indexOf(iterator.id) == -1) {
strHtml += render_channal_list(iterator);
}
}
$("#channal_list").html(strHtml);
set_more_button_display();
} catch (e) {
console.error(e);
}
}
}
);
}
}
function find_channal(id) {
for (const iterator of _channalData) {
if (id == iterator.id) {
return iterator;
}
}
return false;
}
function render_channal_list(channalinfo) {
let output = "";
let checked = "";
let selected = "noselect";
if (_channal.indexOf(channalinfo.id) >= 0) {
checked = "checked";
selected = "selected";
}
output += "";
output +=
'
";
output += "
";
output += "";
output += channalinfo.nickname.slice(0, 2);
output += " ";
output += "
";
output += "
";
output += "
";
output += "
";
output += channalinfo["username"];
output += "
";
if (channalinfo["final"]) {
//进度
output += "
";
let article_len = channalinfo["article_len"];
let svg_width = article_len;
let svg_height = parseInt(article_len / 10);
output += '';
let curr_x = 0;
let allFinal = 0;
for (const iterator of channalinfo["final"]) {
let stroke_width = parseInt(iterator.len);
output += " ";
curr_x += stroke_width;
}
output +=
" ";
output +=
" ";
output += '';
output += channalinfo["count"] + "/" + channalinfo["all"];
output += " ";
output += "";
output += "
";
//进度结束
}
output += "
";
output += "
";
return output;
}
function onChannelMultiSelectStart() {
$(".channel_select").show();
}
function onChannelMultiSelectCancel() {
$(".channel_select").hide();
}
function onChannelChange() {
let channal_list = new Array();
$("[channal_id]").each(function () {
if (this.checked) {
channal_list.push($(this).attr("channal_id"));
}
});
set_channal(channal_list.join());
}
//点击引用 需要响应的事件
function note_ref_init() {
$("chapter").click(function () {
let bookid = $(this).attr("book");
let para = $(this).attr("para");
window.open("../reader/?view=chapter&book=" + bookid + "¶=" + para, "_blank");
});
$("para").click(function () {
let bookid = $(this).attr("book");
let para = $(this).attr("para");
window.open("../reader/?view=para&book=" + bookid + "¶=" + para, "_blank");
});
}
/*
id
palitext
tran
ref
*/
function note_json_html(in_json) {
let output = "";
output += '";
output += "" + in_json.palitext + "
";
output += "
";
output += "
";
//output += "";
for (const iterator of in_json.translation) {
output += render_one_sent_tran(in_json.book, in_json.para, in_json.begin, in_json.end, iterator);
}
//所选全部译文结束
//output += "
";
//未选择的其他译文开始
output += "";
output += "
";
output += " ";
//其他译文工具条
output += "";
output += "" + gLocal.gui.other + gLocal.gui.translation + " ";
output += " ";
output += " ";
output += " ";
//相似句工具条
output += "";
output +=
"" +
gLocal.gui.similar_sentences +
" ";
output += "" + in_json.sim + " ";
output += " ";
output += "
";
output += "
";
output += "
";
output += "
";
//未选择的其他译文开始
//新增译文按钮开始
output += "";
output += "
";
output += "
";
output += "
";
output += "
";
//新增译文按钮结束
//出处路径开始
output += "" + in_json.ref;
output +=
"" +
in_json.book +
"-" +
in_json.para +
"-" +
in_json.begin +
"-" +
in_json.end +
"" +
"
";
//出处路径结束
return output;
}
function render_one_sent_tran(book, para, begin, end, iterator) {
let output = "";
output += "";
//译文工具按钮开始
output += "
";
output +=
"
";
//译文工具栏开始
output += "
";
output += "
" +
' ';
output += gLocal.gui.edit + " ";
output += "" +
' ';
output += gLocal.gui.timeline + " ";
output +=
"" +
' ';
output += gLocal.gui.copy + " ";
output +=
"
" +
' ';
output += gLocal.gui.like + " ";
output +=
"" +
' ';
output += gLocal.gui.comment + " ";
output +=
"" +
' ';
output += gLocal.gui.digest + " ";
output +=
"
" +
' ';
output += gLocal.gui.share_to + " ";
output += "";
//译文工具栏结束
output += "
";
//译文工具按钮结束
//译文正文开始
output +=
"
";
if (iterator.text == "") {
output +=
"" +
iterator.channalinfo.name +
"-" +
iterator.channalinfo.lang +
" ";
} else {
//note_init处理句子链接
output += note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
}
output += "
";
//译文正文结束
output += "
";
//单个channal译文框结束
return output;
}
function add_new_tran_button_click(obj) {
let html = "";
for (const iterator of _my_channal) {
if (_channal.indexOf(iterator.id) < 0) {
html += '' + iterator.name + " ";
}
}
html += " ";
$(obj).parent().children(".tran_text_tool_bar").first().html(html);
if ($(obj).parent().children(".tran_text_tool_bar").css("display") == "block") {
$(obj).parent().children(".tran_text_tool_bar").first().hide();
} else {
$(obj).parent().children(".tran_text_tool_bar").first().show();
$(obj).parent().show();
}
}
function new_sentence(book, para, begin, end, channel, obj) {
let newsent = { id: "", text: "", lang: "", channal: channel };
for (let iterator of _arrData) {
if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
let found = false;
for (const tran of iterator.translation) {
if (tran.channal == channel) {
found = true;
break;
}
}
if (!found) {
iterator.translation.push(newsent);
}
}
}
if ($(obj).parent().parent().css("display") == "block") {
$(obj).parent().parent().hide();
}
note_edit_sentence(book, para, begin, end, channel);
}
//显示更多译文按钮动作
function set_more_button_display() {
$(".other_tran_div").each(function () {
const sentid = $(this).attr("sent").split("-");
const book = sentid[0];
const para = sentid[1];
const begin = sentid[2];
const end = sentid[3];
let count = 0;
for (const iterator of _channalData) {
if (iterator.final) {
for (const onesent of iterator.final) {
let id = onesent.id.split("-");
if (book == id[0] && para == id[1] && begin == id[2] && end == id[3] && onesent.final) {
if (_channal.indexOf(iterator.id) == -1) {
count++;
}
}
}
}
}
if (count > 0) {
$(this).find(".other_tran_num").html(count);
$(this).find(".other_tran_num").attr("style", "display:inline-flex;");
$(this)
.find(".other_bar")
.click(function () {
const sentid = $(this).parent().attr("sent").split("-");
const book = sentid[0];
const para = sentid[1];
const begin = sentid[2];
const end = sentid[3];
let sentId = book + "-" + para + "-" + begin + "-" + end;
if ($(this).parent().siblings(".other_tran").first().css("display") == "none") {
$(".other_tran_div[sent='" + sentId + "']")
.children(".other_tran")
.slideDown();
$(this).siblings(".more_tran ").css("transform", "unset");
$.get(
"../usent/get.php",
{
book: book,
para: para,
begin: begin,
end: end,
},
function (data, status) {
let arrSent = JSON.parse(data);
let html = "";
for (const iterator of arrSent) {
if (_channal.indexOf(iterator.channal) == -1) {
html += "" + marked(iterator.text) + "
";
}
}
let sentId =
arrSent[0].book +
"-" +
arrSent[0].paragraph +
"-" +
arrSent[0].begin +
"-" +
arrSent[0].end;
$(".other_tran_div[sent='" + sentId + "']")
.children(".other_tran")
.html(html);
}
);
} else {
$(".other_tran_div[sent='" + sentId + "']")
.children(".other_tran")
.slideUp();
$(this).siblings(".more_tran ").css("transform", "rotate(-90deg)");
}
});
} else {
//隐藏自己
//$(this).hide();
$(this)
.find(".other_tran_span")
.html(gLocal.gui.no + gLocal.gui.other + gLocal.gui.translation);
//$(this).find(".more_tran").hide();
}
});
}
function note_edit_sentence(book, para, begin, end, channal) {
let channalInfo;
for (const iterator of _channalData) {
if (iterator.id == channal) {
channalInfo = iterator;
break;
}
}
for (const iterator of _arrData) {
if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
for (const tran of iterator.translation) {
if (tran.channal == channal) {
let html = "";
html += "" + channalInfo.name + "@" + channalInfo.nickname + "
";
html +=
"";
$("#edit_dialog_content").html(html);
$("#note_sent_edit_dlg").dialog("open");
return;
}
}
}
}
alert("未找到句子");
}
function note_sent_save() {
let id = $("#edit_dialog_text").attr("sent_id");
let book = $("#edit_dialog_text").attr("book");
let para = $("#edit_dialog_text").attr("para");
let begin = $("#edit_dialog_text").attr("begin");
let end = $("#edit_dialog_text").attr("end");
let channal = $("#edit_dialog_text").attr("channal");
let text = $("#edit_dialog_text").val();
$.post(
"../usent/sent_post.php",
{
id: id,
book: book,
para: para,
begin: begin,
end: end,
channal: channal,
text: text,
lang: "zh",
},
function (data) {
let result = JSON.parse(data);
if (result.status > 0) {
alert("error" + result.message);
} else {
ntf_show("success");
if (result.text == "") {
let channel_info = "Empty";
let thisChannel = find_channal(result.channal);
if (thisChannel) {
channel_info = thisChannel.name + "-" + thisChannel.nickname;
}
$(
"#tran_text_" +
result.book +
"_" +
result.para +
"_" +
result.begin +
"_" +
result.end +
"_" +
result.channal
).html("" + channel_info + " ");
} else {
$(
"#tran_text_" +
result.book +
"_" +
result.para +
"_" +
result.begin +
"_" +
result.end +
"_" +
result.channal
).html(marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang)));
term_updata_translation();
for (const iterator of _arrData) {
if (
iterator.book == result.book &&
iterator.para == result.para &&
iterator.begin == result.begin &&
iterator.end == result.end
) {
for (const tran of iterator.translation) {
if (tran.channal == result.channal) {
tran.text = result.text;
break;
}
}
}
}
}
}
}
);
}
function copy_ref(book, para, begin, end) {
let strRef = "{{" + book + "-" + para + "-" + begin + "-" + end + "}}";
copy_to_clipboard(strRef);
}
function goto_nissaya(book, para) {
window.open("../nissaya/index.php?book=" + book + "¶=" + para, "nissaya");
}
function edit_in_studio(book, para, begin, end) {
wbw_channal_list_open(book, [para]);
}
function tool_bar_show(element) {
if ($(element).find(".tran_text_tool_bar").css("display") == "none") {
$(element).find(".tran_text_tool_bar").css("display", "flex");
$(element).find(".icon_expand").css("transform", "rotate(-180deg)");
$(element).css("background-color", "var(--btn-bg-color)");
$(element).css("visibility", "visible");
$(document).one("click", function () {
$(element).find(".tran_text_tool_bar").hide();
$(element).css("background-color", "var(--nocolor)");
$(element).find(".icon_expand").css("transform", "unset");
$(element).css("visibility", "");
});
event.stopPropagation();
} else {
$(element).find(".tran_text_tool_bar").hide();
$(element).css("background-color", "var(--nocolor)");
$(element).find(".icon_expand").css("transform", "unset");
$(element).css("visibility", "");
}
}
function setVisibility(key, value) {
switch (key) {
case "palitext":
if ($(value).is(":checked")) {
$(".palitext").show();
} else {
$(".palitext").hide();
}
break;
default:
break;
}
}
function note_show_pali_sim(SentId) {
pali_sim_dlg_open(SentId, 0, 20);
}
function set_pali_script(pos, script) {
if (script == "none") {
$(".palitext" + pos).html("");
} else {
$(".palitext" + pos).each(function () {
let html = $(this).siblings(".palitext_roma").first().html();
$(this).html(html);
});
$(".palitext" + pos)
.find("*")
.contents()
.filter(function () {
return this.nodeType != 1;
})
.wrap(" ");
$(".palitext" + pos)
.contents()
.filter(function () {
return this.nodeType != 1;
})
.wrap(" ");
$("pl" + pos).html(function (index, oldcontent) {
return roman_to_my(oldcontent);
});
}
}
function refresh_pali_script() {
if (_display && _display == "para") {
//段落模式
} else {
//句子模式
setting_get("lib.second_script", set_second_scrip);
}
}
function set_second_scrip(value) {
set_pali_script(2, value);
}
function slider_show(obj) {
$(obj).parent().parent().parent().parent().parent().toggleClass("slider_show_shell");
}