|
|
@@ -4,6 +4,9 @@ var _channal = "";
|
|
|
var _lang = "";
|
|
|
var _author = "";
|
|
|
|
|
|
+var _arrData;
|
|
|
+var _channalData;
|
|
|
+
|
|
|
/*
|
|
|
{{203-1654-23-45@11@en@*}}
|
|
|
<note>203-1654-23-45@11@en@*</note>
|
|
|
@@ -27,38 +30,32 @@ var _author = "";
|
|
|
<note id="guid" book=203 para=1654 begin=23 end=45 author=11 lang=en tag=*></note>
|
|
|
|
|
|
*/
|
|
|
-
|
|
|
+function note_create() {
|
|
|
+ $("#dialog").dialog({
|
|
|
+ autoOpen: false,
|
|
|
+ width: 550,
|
|
|
+ buttons: [
|
|
|
+ {
|
|
|
+ text: "Save",
|
|
|
+ click: function () {
|
|
|
+ note_sent_save();
|
|
|
+ $(this).dialog("close");
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "Cancel",
|
|
|
+ click: function () {
|
|
|
+ $(this).dialog("close");
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+}
|
|
|
function note_init(input) {
|
|
|
let output = "<div>";
|
|
|
let newString = input.replace(/\{\{/g, '<note info="');
|
|
|
newString = newString.replace(/\}\}/g, '"></note>');
|
|
|
output = marked(newString);
|
|
|
- /*
|
|
|
- let arrInput = input.split("\n");
|
|
|
- for (x in arrInput) {
|
|
|
- if (arrInput[x].slice(0, 2) == "==" && arrInput[x].slice(-2) == "==") {
|
|
|
- output += "</div></div>";
|
|
|
- output += '<div class="submenu1">';
|
|
|
- output +=
|
|
|
- '<p class="submenu_title1" onclick="submenu_show_detail(this)">';
|
|
|
- output += arrInput[x].slice(2, -2);
|
|
|
- output += '<svg class="icon" style="transform: rotate(45deg);">';
|
|
|
- output += '<use xlink:href="svg/icon.svg#ic_add"></use>';
|
|
|
- output += "</svg>";
|
|
|
- output += "</p>";
|
|
|
- output += '<div class="submenu_details1" >';
|
|
|
- } else {
|
|
|
- let row = arrInput[x];
|
|
|
- row = row.replace(/\{\{/g, '<note info="');
|
|
|
- row = row.replace(/\}\}/g, '"></note>');
|
|
|
- if (row.match("{") && row.match("}")) {
|
|
|
- row = row.replace("{", "<strong>");
|
|
|
- row = row.replace("}", "</strong>");
|
|
|
- }
|
|
|
- output += row;
|
|
|
- }
|
|
|
- }
|
|
|
- */
|
|
|
output += "</div>";
|
|
|
return output;
|
|
|
}
|
|
|
@@ -115,11 +112,12 @@ function note_refresh_new() {
|
|
|
function (data, status) {
|
|
|
if (status == "success") {
|
|
|
try {
|
|
|
- let arrData = JSON.parse(data);
|
|
|
- for (const iterator of arrData) {
|
|
|
+ _arrData = JSON.parse(data);
|
|
|
+ for (const iterator of _arrData) {
|
|
|
let id = iterator.id;
|
|
|
let strHtml = "<a name='" + id + "'></a>";
|
|
|
if (_display && _display == "para") {
|
|
|
+ //段落模式
|
|
|
let strPalitext =
|
|
|
"<pali book='" +
|
|
|
iterator.book +
|
|
|
@@ -145,12 +143,17 @@ function note_refresh_new() {
|
|
|
.children(".palitext")
|
|
|
.first()
|
|
|
.append(strPalitext);
|
|
|
- let htmlTran =
|
|
|
- "<span class='tran'>" +
|
|
|
- marked(term_std_str_to_tran(iterator.tran)) +
|
|
|
- "</span>";
|
|
|
+ let htmlTran = "";
|
|
|
+ for (const oneTran of iterator.translation) {
|
|
|
+ htmlTran +=
|
|
|
+ "<span class='tran'>" +
|
|
|
+ marked(term_std_str_to_tran(oneTran.text)) +
|
|
|
+ "</span>";
|
|
|
+ }
|
|
|
+
|
|
|
$("#" + id).html(htmlTran);
|
|
|
} else {
|
|
|
+ //句子模式
|
|
|
strHtml += note_json_html(iterator);
|
|
|
$("#" + id).html(strHtml);
|
|
|
}
|
|
|
@@ -214,12 +217,21 @@ function note_channal_list() {
|
|
|
function (data, status) {
|
|
|
if (status == "success") {
|
|
|
try {
|
|
|
- let arrData = JSON.parse(data);
|
|
|
+ _channalData = JSON.parse(data);
|
|
|
let strHtml = "";
|
|
|
- for (const iterator of arrData) {
|
|
|
+ for (const iterator of _channalData) {
|
|
|
strHtml += render_channal_list(iterator);
|
|
|
}
|
|
|
$("#channal_list").html(strHtml);
|
|
|
+ $("[channal_id]").change(function () {
|
|
|
+ let channal_list = new Array();
|
|
|
+ $("[channal_id]").each(function () {
|
|
|
+ if (this.checked) {
|
|
|
+ channal_list.push($(this).attr("channal_id"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ set_channal(channal_list.join());
|
|
|
+ });
|
|
|
} catch (e) {
|
|
|
console.error(e);
|
|
|
}
|
|
|
@@ -229,10 +241,27 @@ function note_channal_list() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function find_channal(id) {
|
|
|
+ for (const iterator of _channalData) {
|
|
|
+ if (id == iterator.id) {
|
|
|
+ return iterator;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
function render_channal_list(channalinfo) {
|
|
|
let output = "";
|
|
|
output += "<div class='list_with_head'>";
|
|
|
-
|
|
|
+ let checked = "";
|
|
|
+ if (_channal.indexOf(channalinfo.id) >= 0) {
|
|
|
+ checked = "checked";
|
|
|
+ }
|
|
|
+ output +=
|
|
|
+ '<div><input type="checkbox" ' +
|
|
|
+ checked +
|
|
|
+ " channal_id='" +
|
|
|
+ channalinfo.id +
|
|
|
+ "'></div>";
|
|
|
output += "<div class='head'>";
|
|
|
output += "<span class='head_img'>";
|
|
|
output += channalinfo.nickname.slice(0, 2);
|
|
|
@@ -290,10 +319,44 @@ ref
|
|
|
function note_json_html(in_json) {
|
|
|
let output = "";
|
|
|
output += "<div class='palitext'>" + in_json.palitext + "</div>";
|
|
|
- output +=
|
|
|
- "<div class='tran'>" +
|
|
|
- marked(term_std_str_to_tran(in_json.tran)) +
|
|
|
- "</div>";
|
|
|
+ for (const iterator of in_json.translation) {
|
|
|
+ output += "<div class='tran'>";
|
|
|
+ output +=
|
|
|
+ "<span class='edit_button' onclick=\"note_edit_sentence('" +
|
|
|
+ in_json.book +
|
|
|
+ "' ,'" +
|
|
|
+ in_json.para +
|
|
|
+ "' ,'" +
|
|
|
+ in_json.begin +
|
|
|
+ "' ,'" +
|
|
|
+ in_json.end +
|
|
|
+ "' ,'" +
|
|
|
+ iterator.channal +
|
|
|
+ "')\"></span>";
|
|
|
+
|
|
|
+ output +=
|
|
|
+ "<div class='text' id='tran_text_" +
|
|
|
+ in_json.book +
|
|
|
+ "_" +
|
|
|
+ in_json.para +
|
|
|
+ "_" +
|
|
|
+ in_json.begin +
|
|
|
+ "_" +
|
|
|
+ in_json.end +
|
|
|
+ "_" +
|
|
|
+ iterator.channal +
|
|
|
+ "'>";
|
|
|
+ if (iterator.text == "") {
|
|
|
+ //let channal = find_channal(iterator.channal);
|
|
|
+ output += "<span style='color:var(--border-line-color);'>新建译文</span>";
|
|
|
+ } else {
|
|
|
+ output += marked(term_std_str_to_tran(iterator.text));
|
|
|
+ }
|
|
|
+ output += "</div>";
|
|
|
+
|
|
|
+ output += "</div>";
|
|
|
+ }
|
|
|
+
|
|
|
output += "<div class='ref'>" + in_json.ref;
|
|
|
output +=
|
|
|
"<span class='sent_no'>" +
|
|
|
@@ -308,3 +371,112 @@ function note_json_html(in_json) {
|
|
|
"</div>";
|
|
|
return output;
|
|
|
}
|
|
|
+
|
|
|
+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 +=
|
|
|
+ "<div style='color:blue;'>" +
|
|
|
+ channalInfo.nickname +
|
|
|
+ "/" +
|
|
|
+ channalInfo.name +
|
|
|
+ "</div>";
|
|
|
+ html +=
|
|
|
+ "<textarea id='edit_dialog_text' sent_id='" +
|
|
|
+ tran.id +
|
|
|
+ "' book='" +
|
|
|
+ iterator.book +
|
|
|
+ "' para='" +
|
|
|
+ iterator.para +
|
|
|
+ "' begin='" +
|
|
|
+ iterator.begin +
|
|
|
+ "' end='" +
|
|
|
+ iterator.end +
|
|
|
+ "' channal='" +
|
|
|
+ tran.channal +
|
|
|
+ "' style='width:100%;min-height:260px;'>" +
|
|
|
+ tran.text +
|
|
|
+ "</textarea>";
|
|
|
+ $("#edit_dialog_content").html(html);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $("#dialog").dialog("open");
|
|
|
+}
|
|
|
+
|
|
|
+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 {
|
|
|
+ alert("成功");
|
|
|
+ $(
|
|
|
+ "#tran_text_" +
|
|
|
+ result.book +
|
|
|
+ "_" +
|
|
|
+ result.para +
|
|
|
+ "_" +
|
|
|
+ result.begin +
|
|
|
+ "_" +
|
|
|
+ result.end +
|
|
|
+ "_" +
|
|
|
+ result.channal
|
|
|
+ ).html(marked(result.text));
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+}
|