浏览代码

支持nissaya channel

visuddhinanda@gmail.com 4 年之前
父节点
当前提交
e4ad56e7e1
共有 3 个文件被更改,包括 112 次插入41 次删除
  1. 68 22
      public/app/term/note.js
  2. 12 0
      public/app/term/term.css
  3. 32 19
      public/app/usent/get.php

+ 68 - 22
public/app/term/note.js

@@ -720,10 +720,9 @@ function note_json_html(in_json) {
 	output += "</div>"; /**note_body end */
 
 	//工具栏开始
-	output += "<div class='other_tran_div' sent='";
-	output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end + "' >";
-	output += "<div class='tool_bar' sent='";
-	output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end + "' >";
+    let sent_id = in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end;
+	output += "<div class='other_tran_div' sent='" + sent_id + "' >";
+	output += "<div class='tool_bar' sent='" + sent_id + "' >";
 	output += "<span class='tool_left'>";
 	//第一个按钮
 	//新增译文按钮开始
@@ -738,13 +737,17 @@ function note_json_html(in_json) {
 	output += "</div>";
 	output += "</span>";
 	//新增译文按钮结束
+
+    //分隔线
 	output += "<span class='separate_line'></span>";
-	//第二个按钮
+
+	
 	output += "<span class='more_tran icon_expand'></span>";
-	//其他译文工具条
-	output += "<span class='other_bar'  >";
+
+	//第二个按钮其他译文
+	output += "<span class='other_bar' sent='"+sent_id+"' channel_type='translation'>";
 	output +=
-		"<span class='other_tran_span' title='🧲" +
+		"<span class='other_tran_span' title='" +
 		gLocal.gui.other +
 		gLocal.gui.translation +
 		"'>";
@@ -755,10 +758,31 @@ function note_json_html(in_json) {
 	output += "</span>";
 	output += "<span class='other_tran_num'></span>";
 	output += "</span>";
+    //第二个按钮结束
+
+    //分割线
+	output += "<span class='separate_line'></span>";
+
+    //nissaya
+	output += "<span class='other_bar' sent='"+sent_id+"' channel_type='nissaya' >";
+	output +=
+		"<span class='other_nissaya_span' title='" +
+		gLocal.gui.other +
+		gLocal.gui.translation +
+		"'>";
+	output += "<svg class='icon' style='fill: var(--box-bg-color1)'>";
+	output += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#sun'>";
+	output += "</svg>" ;
+	output += "Nissaya" ;
+	output += "</span>";
+	output += "<span class='other_tran_num'></span>";
+	output += "</span>";
+
+    //分割线
 	output += "<span class='separate_line'></span>";
 
 	//手工义注
-	output += "<span class='other_bar disable'>";
+	output += "<span class='other_bar'  sent='"+sent_id+"' channel_type='commentary' >";
 	output +=
 		"<span class='other_tran_span commentray' title='📔" +
 		gLocal.gui.vannana +
@@ -771,21 +795,23 @@ function note_json_html(in_json) {
 
 	//第三个按钮 相似句
 	if (parseInt(in_json.sim) > 0) {
-		output += "<span class='other_bar' >";
+		output += "<span class='sim_bar' >";
 		output +=
 			"<span class='similar_sent_span' onclick=\"note_show_pali_sim('" +
 			in_json.pali_sent_id +
 			"')\" title='" +
 			gLocal.gui.similar_sentences +
-			"'>🧬" +
-			gLocal.gui.similar +
-			"</span>";
+			"'>";
+        	output += "<svg class='icon' style='fill: var(--box-bg-color1)'>";
+            output += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#hdd-stack'>";
+            output += "</svg>" ;
+			output += gLocal.gui.similar + "</span>";
 		output += "<span class='similar_sent_num'>" + in_json.sim + "</span>";
 		output += "</span>";
 		output += "<span class='separate_line'></span>";
 	}
-
 	//第三个按钮 相似句结束
+
 	output += "</span>";
 
 	output += "<span class='tool_right'>";
@@ -964,6 +990,9 @@ function render_one_sent_tran_a(iterator, diff = false) {
 			tranText = note_init(term_std_str_to_tran(showText, iterator.channal, iterator.editor, iterator.lang));
 		}
 	}
+    if(iterator.type=='nissaya'){
+        tranText = renderNissayaPreview(iterator.text);
+    }
 	let html = "";
 	html += "<div class='sent_tran ";
 	if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
@@ -1211,7 +1240,21 @@ function render_one_sent_tran_a(iterator, diff = false) {
 	html += "</div>";
 	return html;
 }
-
+function renderNissayaPreview(str){
+    let html ="<div class='nissaya'>";
+    const sent = str.split("\n");
+    for (const iterator of sent) {
+        const word =  iterator.split("=");
+        if(word.length>1){
+            html += "<span class='org'>"+ my_to_roman(word[0])+"</span>";
+            html += "<span class='meaning'>"+ word[1]+"</span>";
+        }else{
+            html += iterator;
+        }
+    }
+    html += "</div>";
+    return html;
+}
 function tran_sent_textarea_event_init() {
 	let textarea = document.querySelectorAll(".tran_sent_textarea");
 	for (let iterator of textarea) {
@@ -1550,8 +1593,9 @@ function new_sentence(book, para, begin, end, channel, obj) {
 
 //显示更多译文按钮动作
 function set_more_button_display() {
-	$(".other_tran_div").each(function () {
+	$(".other_bar").each(function () {
 		const sentid = $(this).attr("sent").split("-");
+		const channelType = $(this).attr("channel_type");
 
 		const book = sentid[0];
 		const para = sentid[1];
@@ -1559,7 +1603,7 @@ function set_more_button_display() {
 		const end = sentid[3];
 		let count = 0;
 		for (const iterator of _channalData) {
-			if (iterator.final) {
+			if (iterator.final && iterator.type==channelType) {
 				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) {
@@ -1574,19 +1618,20 @@ function set_more_button_display() {
 			$(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().parent().attr("sent").split("-");
+					const sentid = $(this).attr("sent").split("-");
+		            const channelType = $(this).attr("channel_type");
 					const book = sentid[0];
 					const para = sentid[1];
 					const begin = sentid[2];
 					const end = sentid[3];
-					let sentId = $(this).parent().parent().attr("sent");
+					let sentId = $(this).attr("sent");
 					if ($(this).parent().parent().siblings(".other_tran").first().css("display") == "none") {
 						$(".other_tran_div[sent='" + sentId + "']")
 							.children(".other_tran")
 							.slideDown();
-						$(this).siblings(".more_tran ").css("transform", "unset");
+                        //加号复位
+						//$(this).siblings(".more_tran ").css("transform", "unset");
 						$.get(
 							"../usent/get.php",
 							{
@@ -1594,6 +1639,7 @@ function set_more_button_display() {
 								para: para,
 								begin: begin,
 								end: end,
+                                type:channelType,
 							},
 							function (data, status) {
 								let arrSent = JSON.parse(data);
@@ -1629,7 +1675,7 @@ function set_more_button_display() {
 		} else {
 			//隐藏自己
 			//$(this).hide();
-			$(this).find(".other_tran_span").addClass("disable"); //gLocal.gui.no + gLocal.gui.other + gLocal.gui.translation
+			$(this).addClass("disable");
 			//$(this).find(".more_tran").hide();
 		}
 	});

+ 12 - 0
public/app/term/term.css

@@ -1092,4 +1092,16 @@ pali>p {
 	margin:unset;
 	padding:unset;
 	background-color: var(--btn-border-color);
+}
+
+.preview .nissaya{
+    display:inline;
+}
+.preview .nissaya .org{
+    display:inline;
+    font-weight: 700;
+}
+.preview .nissaya .meaning{
+    display:inline;
+    font-weight: 500;
 }

+ 32 - 19
public/app/usent/get.php

@@ -53,28 +53,41 @@ if (isset($_GET["sentences"])) {
     $stmt->execute($arrSent);
 } else {
     $book = $_GET["book"];
-    $para = $_GET["para"];
+    if(isset($_GET["par"])){
+        $para = $_GET["par"];
+    }
+    if(isset($_GET["para"])){
+        $para = $_GET["para"];
+    }
+    
     $begin = $_GET["begin"];
     $end = $_GET["end"];
-    $query = "SELECT uid as id,
-					parent_uid as parent,
-					block_uid as block_id,
-					channel_uid as channal,
-					book_id as book,
-					paragraph,
-					word_start as begin,
-					word_end as end,
-					author,
-					editor_uid as editor,
-					content as text,
-					language,
-					version as ver,
-					status,
-					strlen,
-					modify_time
-					FROM "._TABLE_SENTENCE_." WHERE (book_id = ?  AND paragraph = ? AND word_start = ? AND word_end = ? and strlen >0 and (status = 30 {$channel_query} ) ) order by modify_time DESC  ";
+    if(isset($_GET["type"])){
+        $type = $_GET["type"];
+    }else{
+        $type = "translation";
+    }
+    
+    $query = "SELECT sent.uid as id,
+					sent.parent_uid as parent,
+					sent.block_uid as block_id,
+					sent.channel_uid as channal,
+					sent.book_id as book,
+					sent.paragraph,
+					sent.word_start as begin,
+					sent.word_end as end,
+					sent.author,
+					sent.editor_uid as editor,
+					sent.content as text,
+					sent.language,
+					sent.version as ver,
+					sent.status,
+					sent.strlen,
+					sent.modify_time,
+                    channel.type
+					FROM "._TABLE_SENTENCE_. " as sent LEFT JOIN "._TABLE_CHANNEL_." as channel ON sent.channel_uid=channel.uid  WHERE (channel.type= ? AND sent.book_id = ?  AND sent.paragraph = ? AND sent.word_start = ? AND sent.word_end = ? and sent.strlen >0 and (sent.status = 30 {$channel_query} ) ) order by sent.modify_time DESC  ";
     $stmt = $dbh->prepare($query);
-    $parm = array($book, $para, $begin, $end);
+    $parm = array($type,$book, $para, $begin, $end);
     $parm = array_merge_recursive($parm, $channal_list);
     $stmt->execute($parm);
 }