Bladeren bron

Merge pull request #171 from visuddhinanda/master

优化reader
Bhikkhu-Kosalla 5 jaren geleden
bovenliggende
commit
364387f943
6 gewijzigde bestanden met toevoegingen van 109 en 106 verwijderingen
  1. 1 1
      app/public/js/notify.js
  2. 1 1
      app/public/lang/zh-cn.json
  3. 1 1
      app/public/lang/zh-tw.json
  4. 4 2
      app/reader/index.php
  5. 72 72
      app/reader/reader.js
  6. 30 29
      app/term/note.js

+ 1 - 1
app/public/js/notify.js

@@ -35,7 +35,7 @@ function ntf_show(msg, timeout = 8) {
       strHtml += strMsg;
       strHtml += "</div>";
     }
-    strHtml += "<button onclick='ntf_hide()' style='margin-left: 70%;'>" + gLocal.gui.I_know + "</button>"
+    strHtml += "<button onclick='ntf_hide()' style='margin-left: 70%;white-space: nowrap;'>" + gLocal.gui.I_know + "</button>"
     divNotify.innerHTML = strHtml;
     divNotify.style.display = "block";
     setTimeout("ntf_hide()", timeout * 1000);

+ 1 - 1
app/public/lang/zh-cn.json

@@ -84,7 +84,7 @@
 		"each_sentence": "逐句",
 		"eat": "进餐",
 		"edit": "编辑",
-		"edit_now": "转到译经楼中编辑",
+		"edit_now": "译经楼中编辑",
 		"edit1": "编辑:",
 		"edition": "版本:",
 		"editor": "编辑者",

+ 1 - 1
app/public/lang/zh-tw.json

@@ -84,7 +84,7 @@
 		"each_sentence": "逐句",
 		"eat": "進餐",
 		"edit": "編輯",
-		"edit_now": "轉至譯經樓中編輯",
+		"edit_now": "譯經樓中編輯",
 		"edit1": "編輯:",
 		"edition": "版次:",
 		"editor": "編輯",

+ 4 - 2
app/reader/index.php

@@ -168,10 +168,12 @@ require_once "../pcdl/html_head.php";
 }
 
 .language-para {
-    padding: 2px 8px;
+    padding: 2px 2px;
     position: absolute;
-    margin-left: -6em;
+    margin-top: 7px;
     border-bottom: 3px solid var(--link-color);
+	left: 0;
+	font-family: 'Noto Sans', 'Noto Sans SC', 'Noto Sans TC','Padauk', Arial, Verdana;
 }
 
 .level_0{

+ 72 - 72
app/reader/reader.js

@@ -1,8 +1,8 @@
-var _reader_view="sent";
-var _reader_book=-1;
+var _reader_view = "sent";
+var _reader_book = -1;
 var _reader_para = -1;
-var _reader_begin=-1;
-var _reader_end=-1;
+var _reader_begin = -1;
+var _reader_end = -1;
 var _channal = "";
 var _lang = "";
 var _author = "";
@@ -12,71 +12,71 @@ var _sent_data = new Array();
 
 palicanon_load_term();
 
-function reader_load(){
+function reader_load() {
     $.get(
         "../reader/get_para.php",
         {
-            view:_reader_view,
-            book:_reader_book,
-            para:_reader_para,
-            begin:_reader_begin,
-            end:_reader_end,
+            view: _reader_view,
+            book: _reader_book,
+            para: _reader_para,
+            begin: _reader_begin,
+            end: _reader_end,
         },
-        function(data){
+        function (data) {
             _sent_data = JSON.parse(data);
             let tpl = "";
-            let currPara=0;
+            let currPara = 0;
             $("#contents").html("");
-            if(_sent_data.sentences.length>0  ){
+            if (_sent_data.sentences.length > 0) {
                 for (const iterator of _sent_data.sentences) {
-                    if(currPara!=iterator.paragraph){
-                        tpl +="\n";
-                        currPara=iterator.paragraph;
+                    if (currPara != iterator.paragraph) {
+                        tpl += "\n";
+                        currPara = iterator.paragraph;
                         tpl += "```para\n";
-                        tpl += currPara+"\n";
+                        tpl += currPara + "\n";
                         tpl += "```\n";
-                    }                
-                    tpl += "{{"+iterator.book+"-"+iterator.paragraph+"-"+iterator.begin+"-"+iterator.end+"}}\n";
+                    }
+                    tpl += "{{" + iterator.book + "-" + iterator.paragraph + "-" + iterator.begin + "-" + iterator.end + "}}\n";
                 }
                 $("#contents").html(note_init(tpl));
-                note_refresh_new();      
+                note_refresh_new();
                 reader_draw_para_menu();
 
                 //右侧目录
-                let tocHtml="";
-                let tocNextMenu="";
-                if(_sent_data.toc.length>0){
+                let tocHtml = "";
+                let tocNextMenu = "";
+                if (_sent_data.toc.length > 0) {
                     let firstLevel = _sent_data.toc[0].level;
                     for (let index = 1; index < _sent_data.toc.length; index++) {
                         const element = _sent_data.toc[index];
-                        tocHtml+= "<div class='reader_right_toc level_"+(element.level-firstLevel)+"'><a href='#para_"+element.paragraph+"'>"+element.toc+"</a></div>";
-                        tocNextMenu +="<a href='../reader/?view=chapter&book="+_reader_book+"&para="+element.paragraph+"'>"+element.toc+"</a>";
-                    } 
+                        tocHtml += "<div class='reader_right_toc level_" + (element.level - firstLevel) + "'><a href='#para_" + element.paragraph + "'>" + element.toc + "</a></div>";
+                        tocNextMenu += "<a href='../reader/?view=chapter&book=" + _reader_book + "&para=" + element.paragraph + "'>" + element.toc + "</a>";
+                    }
                     $("#toc_content").html(tocHtml);
-                    if(tocNextMenu===""){
+                    if (tocNextMenu === "") {
                         $("#para_path_next_level").hide();
                     }
-                    else{
+                    else {
                         $("#toc_next_menu").html(tocNextMenu);
-                        $("#para_path_next_level").show();                       
+                        $("#para_path_next_level").show();
                     }
 
                 }
-                
+
             }
 
-            
-            if(_sent_data.head==1 || _sent_data.sentences.length==0){
+
+            if (_sent_data.head == 1 || _sent_data.sentences.length == 0) {
                 //渲染目录
                 tpl = "<h2>Table of Content</h2>";
-                if(_sent_data.toc.length>0){
+                if (_sent_data.toc.length > 0) {
                     let firstLevel = _sent_data.toc[0].level;
                     for (let index = 1; index < _sent_data.toc.length; index++) {
                         const element = _sent_data.toc[index];
-                        if(element.level<8){
-                            tpl+= "<div class='reader_main_toc level_"+(element.level-firstLevel)+"'><a href='../reader/?view=chapter&book="+_reader_book+"&para="+element.paragraph+"&display="+_display+"'>"+element.toc+"</a></div>";
+                        if (element.level < 8) {
+                            tpl += "<div class='reader_main_toc level_" + (element.level - firstLevel) + "'><a href='../reader/?view=chapter&book=" + _reader_book + "&para=" + element.paragraph + "&display=" + _display + "'>" + element.toc + "</a></div>";
                         }
-                    } 
+                    }
                 }
                 $("#contents_toc").html(tpl);
             }
@@ -86,64 +86,64 @@ function reader_load(){
     reader_get_path();
 }
 
-function reader_draw_para_menu(){
-    $(".language-para").each(function(){
-        let strPara =  $(this).text();
+function reader_draw_para_menu() {
+    $(".language-para").each(function () {
+        let strPara = $(this).text();
         $(this).addClass("case_dropdown");
-        let html="<a name='para_"+strPara+"'></a>";
-        html  +="<div class='case_dropdown-content para_menu'>";
-    if(typeof _reader_view !="undefined" &&  _reader_view != "para"){
-        html  +="<a onclick=\"junp_to_para('"+_reader_book+"','"+strPara+"')\">仅显示此段</a>";
-    }
-    html  +="<a onclick=\"edit_wbw('"+_reader_book+"','"+strPara+"')\">编辑逐词解析</a>";
-    html  +="<a onclick=\"copy_para_ref('"+_reader_book+"','"+strPara+"')\">复制引用</a>";
-    html  +="<a onclick=\"copy_text('"+_reader_book+"','"+strPara+"')\">复制文本</a>";
-    html  +="<a onclick=\"add_to_list('"+_reader_book+"','"+strPara+"')\">添加到选择列表</a>";
-    html  +="</div>";
-        $(this).append(html);        
+        let html = "<a name='para_" + strPara + "'></a>";
+        html += "<div class='case_dropdown-content para_menu'>";
+        if (typeof _reader_view != "undefined" && _reader_view != "para") {
+            html += "<a onclick=\"junp_to_para('" + _reader_book + "','" + strPara + "')\">仅显示此段</a>";
+        }
+        html += "<a onclick=\"edit_wbw('" + _reader_book + "','" + strPara + "')\">" + gLocal.gui.edit_now + "</a>";
+        html += "<a onclick=\"copy_para_ref('" + _reader_book + "','" + strPara + "')\">" + gLocal.gui.copy_link + "</a>";
+        html += "<a onclick=\"copy_text('" + _reader_book + "','" + strPara + "')\">" + gLocal.gui.copy + "“" + gLocal.gui.pāli + "”</a>";
+        html += "<a onclick=\"add_to_list('" + _reader_book + "','" + strPara + "')\">" + gLocal.gui.add_to_edit_list + "</a>";
+        html += "</div>";
+        $(this).append(html);
     });
 
 }
 
-function junp_to_para(book,para) {
-    let url = "../reader/?view=para&book="+book+"&para="+para+"&display=sent";
+function junp_to_para(book, para) {
+    let url = "../reader/?view=para&book=" + book + "&para=" + para + "&display=sent";
     location.assign(url);
 }
 
-function copy_para_ref(book,para) {
+function copy_para_ref(book, para) {
     let output = "";
     let currPara = para;
     for (const iterator of _sent_data.sentences) {
-        if(iterator.book==book && iterator.paragraph==para){
-            output +="{{"+book+"-"+para+"-"+iterator.begin+"-"+iterator.end+"}}\n";
+        if (iterator.book == book && iterator.paragraph == para) {
+            output += "{{" + book + "-" + para + "-" + iterator.begin + "-" + iterator.end + "}}\n";
         }
     }
-    output +="\n";
+    output += "\n";
     copy_to_clipboard(output)
 }
-function reader_get_path(){
+function reader_get_path() {
     $.get(
         "../reader/get_path.php",
         {
-            book:_reader_book,
-            para:_reader_para,
+            book: _reader_book,
+            para: _reader_para,
         },
-        function(data){
+        function (data) {
             $("#para_path").html(data);
-            $("chapter").each(function(){
+            $("chapter").each(function () {
                 let title = $(this).text();
-                let strLocalTitle="";
-                if( strLocalTitle = term_lookup_my(title,_channal.split()[0],getCookie("userid"),getCookie("language"))){
+                let strLocalTitle = "";
+                if (strLocalTitle = term_lookup_my(title, _channal.split()[0], getCookie("userid"), getCookie("language"))) {
                     $(this).html(strLocalTitle.word);
                 }
-                else if( strLocalTitle = term_lookup_my_a(title,_channal.split()[0],getCookie("userid"),getCookie("language"))){
-                    let newLocal = title.replace(strLocalTitle.word,strLocalTitle.meaning);
+                else if (strLocalTitle = term_lookup_my_a(title, _channal.split()[0], getCookie("userid"), getCookie("language"))) {
+                    let newLocal = title.replace(strLocalTitle.word, strLocalTitle.meaning);
                     $(this).html(newLocal);
                 }
             });
             let suttaTitle = $("chapter").last().html();
             $("#article_title").html(suttaTitle);
-            if(_reader_view=="chapter"){
+            if (_reader_view == "chapter") {
                 //$("chapter").last().hide();
             }
         }
@@ -154,9 +154,9 @@ function palicanon_load_term() {
     $.get(
         "../term/term.php",
         {
-            op:"my"
+            op: "my"
         },
-        function(data){
+        function (data) {
             arrMyTerm = JSON.parse(data);
         }
     );
@@ -176,12 +176,12 @@ function set_channal(channalid) {
     }
     if (_reader_end != -1) {
         url += "&end=" + _reader_end;
-    }   
+    }
     if (channalid != "") {
-      url += "&channal=" + channalid;
+        url += "&channal=" + channalid;
     }
     if (_display != "") {
-      url += "&display=" + _display;
+        url += "&display=" + _display;
     }
     location.assign(url);
-  }
+}

+ 30 - 29
app/term/note.js

@@ -146,8 +146,8 @@ function note_refresh_new() {
                         .parent()
                         .prepend(
                           "<div class='tran_div'  channal='" +
-                            iChannal +
-                            "'></div>"
+                          iChannal +
+                          "'></div>"
                         );
                     }
                   }
@@ -429,26 +429,26 @@ ref
 */
 function note_json_html(in_json) {
   let output = "";
-  output +='<div class="note_tool_bar" style=" position: relative;">';
-  output +='<div class="case_dropdown" style="position: absolute; right: 0;width:1.5em;">';
-  output  +="<svg class='icon' >";
-  output  +="<use xlink:href='../studio/svg/icon.svg#ic_more'></use>";
-  output  +="</svg>";
-  output  +="<div class='case_dropdown-content sent_menu'>";
-  if(typeof _reader_view !="undefined" && _reader_view != "sent"){
-      output  +="<a onclick='junp_to(this)'>跳转至此句</a>";
+  output += '<div class="note_tool_bar" style=" position: relative;">';
+  output += '<div class="case_dropdown" style="position: absolute; right: 0;width:1.5em;">';
+  output += "<svg class='icon' >";
+  output += "<use xlink:href='../studio/svg/icon.svg#ic_more'></use>";
+  output += "</svg>";
+  output += "<div class='case_dropdown-content sent_menu'>";
+  if (typeof _reader_view != "undefined" && _reader_view != "sent") {
+    output += "<a onclick='junp_to(this)'>跳转至此句</a>";
   }
-  output  +="<a onclick=\"copy_ref('"+in_json.book+"','"+in_json.para+"','"+in_json.begin+"','"+in_json.end+"')\">复制引用</a>";
-  output  +="<a onclick='copy_text(this)'>复制文本</a>";
-  output  +="<a onclick='add_to_list()'>添加到选择列表</a>";
-  output  +="</div>";
-  output +='</div>';
-  output +=' </div>';
+  output += "<a onclick=\"copy_ref('" + in_json.book + "','" + in_json.para + "','" + in_json.begin + "','" + in_json.end + "')\">" + gLocal.gui.copy_link + "</a>";
+  output += "<a onclick='copy_text(this)'>" + gLocal.gui.copy + "“" + gLocal.gui.pāli + "”</a>";
+  output += "<a onclick='add_to_list()'>" + gLocal.gui.add_to_edit_list + "</a>";
+  output += "</div>";
+  output += '</div>';
+  output += ' </div>';
   output += "<div class='palitext'>" + in_json.palitext + "</div>";
   for (const iterator of in_json.translation) {
-    output += "<div class='tran' lang='" + iterator.lang + "'>";
+    output += "<div class='tran' lang='" + iterator.lang + "'";
     output +=
-      "<span class='edit_button' onclick=\"note_edit_sentence('" +
+      " onclick=\"note_edit_sentence('" +
       in_json.book +
       "' ,'" +
       in_json.para +
@@ -458,7 +458,8 @@ function note_json_html(in_json) {
       in_json.end +
       "' ,'" +
       iterator.channal +
-      "')\"></span>";
+      "')\">";
+    output += "<span class='edit_button'></span>";
 
     output +=
       "<div class='text' id='tran_text_" +
@@ -590,15 +591,15 @@ function note_sent_save() {
         ntf_show("success");
         $(
           "#tran_text_" +
-            result.book +
-            "_" +
-            result.para +
-            "_" +
-            result.begin +
-            "_" +
-            result.end +
-            "_" +
-            result.channal
+          result.book +
+          "_" +
+          result.para +
+          "_" +
+          result.begin +
+          "_" +
+          result.end +
+          "_" +
+          result.channal
         ).html(
           marked(
             term_std_str_to_tran(
@@ -631,7 +632,7 @@ function note_sent_save() {
 }
 
 
-function copy_ref(book,para,begin,end) {
+function copy_ref(book, para, begin, end) {
   let strRef = "{{" + book + "-" + para + "-" + begin + "-" + end + "}}";
   copy_to_clipboard(strRef);
 }