Browse Source

增加句子消息在编辑框上端显示功能

visuddhinanda 5 years ago
parent
commit
f0253a2c59
5 changed files with 201 additions and 49 deletions
  1. 0 3
      app/pcdl/reader.php
  2. 18 0
      app/studio/js/data.js
  3. 11 0
      app/studio/js/message.js
  4. 170 44
      app/studio/js/render.js
  5. 2 2
      documents/development/functions.md

+ 0 - 3
app/pcdl/reader.php

@@ -703,9 +703,6 @@ else{
 	echo "</div>";
 		
 	}
-
-
-
 ?>
 
 

+ 18 - 0
app/studio/js/data.js

@@ -690,3 +690,21 @@ _blocks.push(newblock)
 
 }
 */
+
+function doc_msg_get_trans(book, para, begin, end) {
+  let output = new Array();
+
+  for (const it of gDocMsgList) {
+    if (it.type == 2) {
+      //let end = obj.data.end;
+      if (
+        book == it.data.book &&
+        para == it.data.para &&
+        begin == it.data.begin
+      ) {
+        output.push(it);
+      }
+    }
+  }
+  return output;
+}

+ 11 - 0
app/studio/js/message.js

@@ -354,6 +354,17 @@ function msg_apply_data(obj) {
             "']"
         ).html(obj.data.text);
 
+        $(
+          "[pcds='sent-net-div'][book='" +
+            book +
+            "'][para='" +
+            para +
+            "'][begin='" +
+            begin +
+            "']"
+        )
+          .find(".author")
+          .html(obj.sender);
         let tranBlock = doc_tran("#" + obj.data.id);
         if (tranBlock == null) {
           tranBlock = doc_tran("#" + obj.data.id, true);

+ 170 - 44
app/studio/js/render.js

@@ -429,7 +429,7 @@ function updataHeadingBlockInHtml(book, par) {
   }
 }
 
-function renderBlock() { }
+function renderBlock() {}
 /*
 重绘翻译数据块
 */
@@ -634,7 +634,7 @@ function renderTranslateParBlockInner(elementBlock) {
   return output;
 }
 
-function renderTranslateParBlockInnerPreview(strText) { }
+function renderTranslateParBlockInnerPreview(strText) {}
 function updateTranslationPreview_a(blockId, text) {
   var out = "";
   var newText = text;
@@ -1282,11 +1282,24 @@ function render_sent_tool_bar(elementBlock, begin) {
   let sentIdString = abook + "-" + aparagraph + "-" + iBegin + "-" + iEnd;
   let sentIdStringLink = "{{" + sentIdString + "}}";
   let sentReaderLink = "";
-  if (_display_sbs == 0) {//逐段模式
-    sentReaderLink = "https://www.wikipali.org/app/pcdl/reader.php?view=para&book=" + abook + "&para=" + aparagraph;
-  }
-  else {//逐句模式
-    sentReaderLink = "https://www.wikipali.org/app/pcdl/reader.php?view=sent&book=" + abook + "&para=" + aparagraph + "&begin=" + iBegin + "&end=" + iEnd;
+  if (_display_sbs == 0) {
+    //逐段模式
+    sentReaderLink =
+      "https://www.wikipali.org/app/pcdl/reader.php?view=para&book=" +
+      abook +
+      "&para=" +
+      aparagraph;
+  } else {
+    //逐句模式
+    sentReaderLink =
+      "https://www.wikipali.org/app/pcdl/reader.php?view=sent&book=" +
+      abook +
+      "&para=" +
+      aparagraph +
+      "&begin=" +
+      iBegin +
+      "&end=" +
+      iEnd;
   }
   output +=
     "<span>" +
@@ -1297,11 +1310,26 @@ function render_sent_tool_bar(elementBlock, begin) {
   output += gLocal.gui.copy_to_clipboard;
   output += "]</a></span>";
   //	output += "<span>"+abook+"-"+aparagraph+"-"+iBegin+"-"+iEnd+"</span>";
-  if (_display_sbs == 0) {//逐段模式
-    output += "<a href='../pcdl/reader.php?view=para&book=" + abook + "&para=" + aparagraph + "' target='_blank'>";
-  }
-  else {//逐句模式
-    output += "<a href='../pcdl/reader.php?view=sent&book=" + abook + "&para=" + aparagraph + "&begin=" + iBegin + "&end=" + iEnd + "' target='_blank'>";
+  if (_display_sbs == 0) {
+    //逐段模式
+    output +=
+      "<a href='../pcdl/reader.php?view=para&book=" +
+      abook +
+      "&para=" +
+      aparagraph +
+      "' target='_blank'>";
+  } else {
+    //逐句模式
+    output +=
+      "<a href='../pcdl/reader.php?view=sent&book=" +
+      abook +
+      "&para=" +
+      aparagraph +
+      "&begin=" +
+      iBegin +
+      "&end=" +
+      iEnd +
+      "' target='_blank'>";
   }
   output += "[" + gLocal.gui.scan_in_reader + "]";
   output += "</a>";
@@ -1504,6 +1532,51 @@ function renderWordParBlockInner(elementBlock) {
         sent_begin = word_id;
         output += "</div>";
         output += "<div class='translate_sent_head_content'>";
+        //句子预览
+        output += "<div class='trans_text_block'>";
+        output +=
+          "<div class='trans_text_content'  pcds='sent-net' book='" +
+          book +
+          "' para='" +
+          paragraph +
+          "' begin='" +
+          sent_begin +
+          "' end=''>";
+        let netSent = doc_msg_get_trans(book, paragraph, sent_begin, 0);
+        let sender = "";
+        if (netSent.length > 0) {
+          output += netSent[netSent.length - 1].data.text;
+          sender = netSent[netSent.length - 1].sender;
+        }
+        output += "</div>";
+        output +=
+          "<div class='trans_text_info'>" +
+          "<span><span>过滤</span><span class='author'>" +
+          sender +
+          "</span><span class='tag'>tag</span></span>" +
+          "<span class='tools'>" +
+          "<button>采纳</button>" +
+          "<button onclick=\"show_tran_net('" +
+          book +
+          "','" +
+          paragraph +
+          "','" +
+          sent_begin +
+          "','" +
+          word_id +
+          "')\">更多</button>" +
+          "</span>" +
+          "</div>";
+        output += "</div>";
+        //句子预览结束
+        output +=
+          "<div class='trans_text_content'  pcds='sent-net' book='" +
+          book +
+          "' para='" +
+          paragraph +
+          "' begin='" +
+          sent_begin +
+          "' end=''></div>";
         output += "</div>";
         output += "</div>";
         output += "<div id='sent_" + wID + "' class='translate_sent_content'>";
@@ -1544,7 +1617,16 @@ function renderWordParBlockInner(elementBlock) {
           "')\">[";
         output += gLocal.gui.copy_to_clipboard;
         output += "]</a></span>";
-        output += "<a href='../pcdl/reader.php?view=sent&book=" + book + "&para=" + paragraph + "&begin=" + nextBegin + "&end=" + nextEnd + "' target='_blank'>";
+        output +=
+          "<a href='../pcdl/reader.php?view=sent&book=" +
+          book +
+          "&para=" +
+          paragraph +
+          "&begin=" +
+          nextBegin +
+          "&end=" +
+          nextEnd +
+          "' target='_blank'>";
         output += "[" + gLocal.gui.scan_in_reader + "]";
         output += "</a>";
         output += "<guide gid='sent_func' style='margin:unset;'></guide>";
@@ -1579,6 +1661,51 @@ function renderWordParBlockInner(elementBlock) {
     "')\"><span id='' class=\"word_msg\">issue</span></span>";
   output += "</div>";
   output += "<div class='translate_sent_head_content'>";
+
+  output +=
+    "<div class='trans_text_block' pcds='sent-net-div' book='" +
+    book +
+    "' para='" +
+    paragraph +
+    "' begin = '" +
+    sent_begin +
+    "' >";
+  output +=
+    "<div class='trans_text_content'  pcds='sent-net' book='" +
+    book +
+    "' para='" +
+    paragraph +
+    "' begin='" +
+    sent_begin +
+    "' end=''>";
+  let netSent = doc_msg_get_trans(book, paragraph, sent_begin, 0);
+  let sender = "";
+  if (netSent.length > 0) {
+    output += netSent[netSent.length - 1].data.text;
+    sender = netSent[netSent.length - 1].sender;
+  }
+  output += "</div>";
+  output +=
+    "<div class='trans_text_info'>" +
+    "<span><span>过滤</span><span class='author'>" +
+    sender +
+    "</span><span class='tag'>tag</span></span>" +
+    "<span class='tools'>" +
+    "<button>赞<span >0</span></button>" +
+    "<button>采纳</button>" +
+    "<button onclick=\"show_tran_net('" +
+    book +
+    "','" +
+    paragraph +
+    "','" +
+    sent_begin +
+    "','" +
+    word_id +
+    "')\">更多</button>" +
+    "</span>" +
+    "</div>";
+  output += "</div>";
+
   output += "</div>";
   output += "</div>";
   output += "<div id='sent_" + wID + "' class='translate_sent_content'>";
@@ -2343,12 +2470,12 @@ function renderWordDetailByElement(xmlElement) {
             ) {
               arrMeaning.push(
                 g_DictWordList[iDict].dictID +
-                "$" +
-                arrMeaning.length +
-                "$$" +
-                arrMean[i] +
-                "$" +
-                g_DictWordList[iDict].Language
+                  "$" +
+                  arrMeaning.length +
+                  "$$" +
+                  arrMean[i] +
+                  "$" +
+                  g_DictWordList[iDict].Language
               );
             }
           }
@@ -2398,12 +2525,12 @@ function renderWordDetailByElement(xmlElement) {
               ) {
                 arrMeaning.push(
                   g_DictWordList[iDict].dictID +
-                  "$" +
-                  arrMeaning.length +
-                  "$*$" +
-                  getLocalParentFormulaStr(wordGramma0, arrMean[i]) +
-                  "$" +
-                  g_DictWordList[iDict].Language
+                    "$" +
+                    arrMeaning.length +
+                    "$*$" +
+                    getLocalParentFormulaStr(wordGramma0, arrMean[i]) +
+                    "$" +
+                    g_DictWordList[iDict].Language
                 );
               }
             }
@@ -2453,12 +2580,12 @@ function renderWordDetailByElement(xmlElement) {
               ) {
                 arrMeaning.push(
                   g_DictWordList[iDict].dictID +
-                  "$" +
-                  arrMeaning.length +
-                  "$**$" +
-                  getLocalParentFormulaStr(wordGramma1, arrMean[i]) +
-                  "$" +
-                  g_DictWordList[iDict].Language
+                    "$" +
+                    arrMeaning.length +
+                    "$**$" +
+                    getLocalParentFormulaStr(wordGramma1, arrMean[i]) +
+                    "$" +
+                    g_DictWordList[iDict].Language
                 );
               }
             }
@@ -2933,7 +3060,7 @@ function renderWordDetailByElement(xmlElement) {
   return _txtOutDetail;
 }
 
-function renderWordNoteDivByParaNo(book, paragraph) { }
+function renderWordNoteDivByParaNo(book, paragraph) {}
 /*
 paragraph word note
 */
@@ -3128,12 +3255,11 @@ function updateWordNote(element) {
       output += "<strong>" + paliword + ":</strong>";
     }
     output += wnote;
-
     $("#wnn_" + id).html(output);
   }
 }
 
-function updateWordCommentary(element) { }
+function updateWordCommentary(element) {}
 
 //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
 //返回 无
@@ -3256,13 +3382,13 @@ function prev_page() {
   gVisibleParEndOld = gVisibleParEnd;
   if (
     g_allparlen_array[gVisibleParEnd - 1] -
-    g_allparlen_array[gVisibleParBegin - 1] <=
+      g_allparlen_array[gVisibleParBegin - 1] <=
     gDisplayCapacity
   ) {
     gVisibleParBegin -= 1;
   } else if (
     g_allparlen_array[gVisibleParEnd + 1] -
-    g_allparlen_array[gVisibleParBegin - 1] >
+      g_allparlen_array[gVisibleParBegin - 1] >
     gDisplayCapacity
   ) {
     gVisibleParBegin -= 1;
@@ -3289,13 +3415,13 @@ function next_page() {
 
   if (
     g_allparlen_array[gVisibleParEnd + 1] -
-    g_allparlen_array[gVisibleParBegin + 1] <=
+      g_allparlen_array[gVisibleParBegin + 1] <=
     gDisplayCapacity
   ) {
     gVisibleParEnd += 1;
   } else if (
     g_allparlen_array[gVisibleParEnd + 1] -
-    g_allparlen_array[gVisibleParBegin + 1] >
+      g_allparlen_array[gVisibleParBegin + 1] >
     gDisplayCapacity
   ) {
     gVisibleParBegin += 1;
@@ -3732,12 +3858,12 @@ function refreshNoteNumber() {
     let id = $(this).attr("wid");
     $(this).html(
       "<a href='#word_note_root_" +
-      id +
-      "' name=\"word_note_" +
-      id +
-      '">[' +
-      (index + 1) +
-      "]</a>"
+        id +
+        "' name=\"word_note_" +
+        id +
+        '">[' +
+        (index + 1) +
+        "]</a>"
     );
   });
 

+ 2 - 2
documents/development/functions.md

@@ -29,7 +29,7 @@ citta:nt. 心;缤纷;
 - **公共版权** 有版权的信息与前两条原则违背。所以,一切在本平台公开的数据都应使用公共版权。
 - **平等的发言权** 每个平台的使用者都有权发表自己的观点。平台不应以人工的方式评价观点的正确性或给予排名靠前或靠后的操作。但是平台应该记录和向所有人提供信息发布者的使用经验数值(如:使用平台时间,发表信息量,被点赞量等)供阅读者自己判断信息的可用性。对没有实质内容的信息(如:“很好”;“太差了”),管理员应根据过滤规则,将信息隐藏。在读者选择“查看隐藏的内容”时展示。
 
-# 程序架构设计原则
+# 程序架构设计
 
 - 除了对安全性和性能要求较高的部分以外。业务逻辑应尽量放在前端。
 - 所有前端业务逻辑功能应该由扩展(extension)提供。
@@ -39,7 +39,7 @@ citta:nt. 心;缤纷;
 - 任何人创建的扩展应该由创建者在平台上注册和上传,供用户自行选择使用。
 - 平台的创建者应提供最基本的扩展。
 - 所有后端功能不使用公开上传的方式扩展功能。应使用 pr and review 方式。
-- 扩展程序只能包含 js css setting.json 少量图片
+- 扩展程序只能包含 js css setting.json 少量图片
 
 # 平台结构 map