标签作为气泡注释
popup_init();
//刷新句子链接递归,有加层数限制。
note_refresh_new();
_arrData = _arrData.concat(sentData);
note_ref_init();
term_get_dict();
note_channal_list();
} 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 += "";
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 += "";
for (const iterator of in_json.translation) {
output += "";
//译文工具按钮开始
output += "";
output +=
"";
//译文工具栏开始
output += "";
//译文工具栏结束
output += "";
//译文工具按钮结束
//译文正文开始
output +=
"";
if (iterator.text == "") {
output +=
"" +
iterator.channalinfo.name +
"-" +
iterator.channalinfo.lang +
"";
} else {
//note_init处理句子链接 marked不处理
//output += marked(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
output += note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
}
output += "";
//译文正文结束
output += "";
//单个channal译文框结束
}
//所选全部译文结束
//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 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(".tool_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).siblings(".other_tran").first().css("display") == "none") {
$(".other_tran_div[sent='" + sentId + "']")
.children(".other_tran")
.slideDown();
$(this).children(".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).children(".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 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", "");
}
}