Ver código fonte

Merge pull request #553 from visuddhinanda/master

逐词解析 channel 全选或全不选
visuddhinanda 4 anos atrás
pai
commit
e4cb234751

+ 173 - 2
app/article/article.js

@@ -109,6 +109,7 @@ function articel_load_article_list(articleId,collectionId) {
 					if (result) {
 						let article_list = JSON.parse(result.article_list);
 						render_article_list(article_list,collectionId,articleId);
+						articleFillFootNavButton(article_list,articleId);
 						let strTitle = "<a href='../article/?view=collection&collection=" + result.id + "'>" + result.title + "</a> / ";
 						for (const iterator of tocActivePath) {
 							strTitle += "<a href='../article/?view=article&id="+iterator.key+"&collection=" + result.id + "'>" + iterator.title + "</a> / ";
@@ -124,6 +125,91 @@ function articel_load_article_list(articleId,collectionId) {
 		}
 	);
 }
+var prevArticle=0,nextArticle=0;
+function articleFillFootNavButton(article_list,curr_article){
+	for (let index = 0; index < article_list.length; index++) {
+		const element = article_list[index];
+		if(element.article==curr_article){
+			if(index!=0){
+				$("#contents_nav_left").html(article_list[index-1].title);
+				prevArticle = article_list[index-1].article;
+			}else{
+				$("#contents_nav_left").html("无");
+			}
+			if(index!=article_list.length-1){
+				$("#contents_nav_right").html(article_list[index+1].title);
+				nextArticle = article_list[index+1].article;
+			}else{
+				$("#contents_nav_right").html("无");
+			}
+		}
+	}
+}
+function goto_prev() {
+	switch (_view) {
+		case "article":
+			if(prevArticle==0){
+				alert("已经到达开始");
+			}else{
+				gotoArticle(prevArticle);
+			}
+			break;
+		case "collection":
+
+		break;
+		case "sent":
+		case "para":
+			gotoPara(_par-1);
+		case "chapter":
+			if(prevChapter>0){
+				gotoChapter(prevChapter);
+			}else{
+				alert("已经到达开始");
+			}
+			break;
+		case "book":
+		case "series":
+		break;
+		case "simsent":
+		case "sim":
+			break;
+		default:
+			break;
+	}
+}
+function goto_next() {
+	switch (_view) {
+		case "article":
+			if(nextArticle==0){
+				alert("已经到达最后");
+			}else{
+				gotoArticle(nextArticle);
+			}
+			break;
+		case "collection":
+		break;
+		case "sent":
+		case "para":
+			gotoPara(_par+1);
+			break;
+		case "chapter":
+			if(nextChapter>0){
+				gotoChapter(nextChapter);
+			}else{
+				alert("已经到达最后");
+			}
+			
+			break;
+		case "book":
+		case "series":
+		break;
+		case "simsent":
+		case "sim":
+			break;
+		default:
+			break;
+	}
+}
 
 //在collect 中 的article列表
 function render_article_list(article_list,collectId="",articleId="") {
@@ -385,7 +471,8 @@ function to_article(){
 		content:_sent_data.content,
 	});
 }
-
+var prevChapter=0,nextChapter=0;
+var strPrevChapter,strNextChapter;
 function render_toc(){
 	$.getJSON(
 		"../api/pali_text.php",
@@ -398,6 +485,10 @@ function render_toc(){
 	).done(function (data) {
 			let arrToc = new Array();
 			for (const it of data.data) {
+				if(_par==it.paragraph){
+					nextChapter = it.next_chapter;
+					prevChapter = it.prev_chapter;
+				}
 				arrToc.push({article:it.paragraph,title:it.toc,level:it.level});
 			}
 			$("#toc_content").fancytree({
@@ -408,16 +499,96 @@ function render_toc(){
 					return false;
 				}
 			});
+			switch (_view) {
+				case "chapter":
+					fill_chapter_nav();
+					break;
+				case "para":
+					fill_para_nav();
+					break;
+				case "sent":
+					fill_sent_nav();
+				default:
+					fill_default_nav();
+					break;
+			}
+			
 	});
 }
+function fill_sent_nav(){
+	$("#contents_nav_left").hide();
+	$("#contents_nav_right").hide();
+}
+function fill_sent_nav(){
+	$("#contents_nav_left").html("");
+	$("#contents_nav_right").html("");
+}
+function fill_para_nav(){
+	$("#contents_nav_left").html(_par-1);
+	$("#contents_nav_right").html(_par+1);
+}
+function fill_chapter_nav(){
+	if(prevChapter>0){
+		$.getJSON(
+			"../api/pali_text.php",
+			{
+				_method:"show",
+				view:"toc",
+				book: _book,
+				par: prevChapter,
+			}
+		).done(function (data) {
+			$("#contents_nav_left").html(data.data.toc);
+		});		
+	}else{
+		$("#contents_nav_left").html("无");
+	}
+	if(nextChapter>0){
+		$.getJSON(
+			"../api/pali_text.php",
+			{
+				_method:"show",
+				view:"toc",
+				book: _book,
+				par: nextChapter,
+			}
+		).done(function (data) {
+			$("#contents_nav_right").html(data.data.toc);
+		});		
+	}else{
+		$("#contents_nav_right").html("无");
+
+	}
+}
 
-//跳转到另外一个文章
+//跳转到另外一个章
 function gotoChapter(paragraph) {
 	let url = "../article/index.php?view=chapter";
 
 	url += "&book=" + _book;
 	url += "&par=" + paragraph;
 
+	if (_channal != "") {
+		url += "&channal=" + _channal;
+	}
+	if (_display != "") {
+		url += "&display=" + _display;
+	}
+	if (_mode != "") {
+		url += "&mode=" + _mode;
+	}
+	if (_direction != "") {
+		url += "&direction=" + _direction;
+	}
+	location.assign(url);
+}
+//跳转到另外一个章节
+function gotoPara(paragraph) {
+	let url = "../article/index.php?view=para";
+
+	url += "&book=" + _book;
+	url += "&par=" + paragraph;
+
 	if (_channal != "") {
 		url += "&channal=" + _channal;
 	}

+ 2 - 2
app/article/index.php

@@ -343,8 +343,8 @@ function set_toc_visible(isVisible){
 			</div>
 			<div id="contents_foot">
 				<div id="contents_nav" style="display:flex;justify-content: space-between;">
-					<div id="contents_nav_left"></div>
-					<div id="contents_nav_right"></div>
+					<div id="contents_nav_left" class="nav_bnt nav_left" onclick="goto_prev()">上一个</div>
+					<div id="contents_nav_right"  class="nav_bnt nav_right" onclick="goto_next()">下一个</div>
 				</div>
 				<div id="contents_dicuse">
 				

+ 7 - 0
app/article/mobile.css

@@ -84,4 +84,11 @@ note:hover .ref {
     border: unset;
     border-radius: unset;
     border-bottom: 1px solid var(--border-line-color);
+}
+
+#contents_nav{
+	flex-direction: column-reverse;
+}
+.nav_bnt{
+	width: 100%;
 }

+ 22 - 0
app/article/style.css

@@ -274,4 +274,26 @@ img {
 
 #head_nav_right{
 	display: flex;
+}
+
+.nav_bnt{
+	min-width: 20em;
+    padding: 15px;
+    border: 1px solid var(--border-line-color);
+    border-radius: 5px;
+	cursor: pointer;
+	margin: 10px;
+}
+.nav_right{
+	text-align: right;
+}
+
+.nav_bnt:hover {
+    background-color: var(--tool-link-hover-color);
+    color: var(--btn-hover-color);
+}
+
+#contents_nav{
+	display: flex;
+    justify-content: space-between;
 }

+ 16 - 2
app/db/pali_text.php

@@ -20,12 +20,12 @@ class PaliText extends Table
 					# code...
 					$parent = $this->medoo->get(
 					$this->table,
-					["parent","paragraph","chapter_len"],
+					["parent","paragraph","chapter_len","next_chapter","prev_chapter"],
 					["book"=>$book,"paragraph"=>$par]
 					);
 					$par = $parent["parent"];
 				} while ($parent["parent"] > -1);
-				$this->_index(["book","paragraph","level","toc","next_chapter","parent"],["level[<]"=>8,"book"=>$book,"paragraph[>]"=>$parent["paragraph"],"paragraph[<]"=>$parent["paragraph"]+$parent["chapter_len"]]);
+				$this->_index(["book","paragraph","level","toc","next_chapter","prev_chapter","parent"],["level[<]"=>8,"book"=>$book,"paragraph[>]"=>$parent["paragraph"],"paragraph[<]"=>$parent["paragraph"]+$parent["chapter_len"]]);
 				echo json_encode($this->result, JSON_UNESCAPED_UNICODE);
 				break;
 			default:
@@ -33,7 +33,21 @@ class PaliText extends Table
 				break;
 		}
 	}
+	public function show(){
+		$output = $this->medoo->get(
+			$this->table,
+			["book","paragraph","level","toc","text"],
+			["book"=>$_GET["book"],"paragraph"=>$_GET["par"]]
+		);
+		if($this->medoo->error){
+			$this->result["ok"]=false;
+			$this->result["message"]=$this->medoo->error;
+		}else{
+			$this->result["data"] = $output;
+		}
+		echo json_encode($this->result, JSON_UNESCAPED_UNICODE);
 
+	}
 	public function getTitle($book,$para)
 	{
 		if (isset($book) && isset($para)) {

+ 6 - 5
app/studio/editor.php

@@ -85,13 +85,14 @@ else{$currDevice="computer";}
 	<script src="../usent/usent.js"></script>
 	<script src="../fileindex/file_info.js"></script>
 
-
 	<script  src="../channal/channal.js"></script>
 	<script>
 		get_channel_list_callback = function(){
-			let html ="<ul>";
-			html += "<li><input type='checkbox' checked channel_id='0' onclick=\"channelDisplay(this)\" />其他</li>"
 
+			let html ="";
+			html += "<input type='checkbox' id='layout_channel_display_all' checked channel_id='-1' onclick=\"channelDisplayAll(this)\" />全选</li>"
+			html +="<ul id='layout_channel_display'>";
+			html += "<li><input type='checkbox' checked channel_id='0' onclick=\"channelDisplay(this)\" />其他</li>"
 			if (_my_channal != null) {
 				for (const iterator of _my_channal) {
 					html += "<li><input type='checkbox' checked channel_id='"+iterator.id+"' onclick=\"channelDisplay(this)\" />"+iterator.name+"</li>"
@@ -100,9 +101,9 @@ else{$currDevice="computer";}
 				$("#layout_channel").html(html);
 			}		
 		}
-	</script>	
-	
+	</script>
 
+	
 	<script language="javascript">
 	<?php 
 	//加载js语言包

+ 22 - 1
app/studio/plugin/system_layout/module_function.js

@@ -262,8 +262,29 @@ function layout_wbw_auto_cut() {
 		}
 	}
 }
-
+//channel显示隐藏
 function channelDisplay(obj) {
 	let id = $(obj).attr("channel_id");
 	$(".trans_text_block[channel_id='" + id + "']").toggle();
+	let allLen = $(obj).parent().parent().children("li").length;
+	let checkLen = $(obj).parent().parent().children("li").children("input:checked").length;
+	if(checkLen==0){
+		$("#layout_channel_display_all").prop("checked",false);
+
+	}else if(allLen===checkLen){
+		$("#layout_channel_display_all").prop("checked",true);
+	}else{
+		$("#layout_channel_display_all").prop({checked:false,indeterminate:true});
+	}
 }
+//全选或全不选
+function channelDisplayAll(obj) {
+	let all = $(obj).prop("checked");
+	if(all){
+		$("#layout_channel_display").children("li").children("input").prop("checked",true);
+		$(".trans_text_block").show();
+	}else{
+		$("#layout_channel_display").children("li").children("input").prop("checked",false);
+		$(".trans_text_block").hide();
+	}
+}

+ 1 - 0
app/term/note.js

@@ -407,6 +407,7 @@ function lang_changed(obj){
 	_lang = $(obj).val();
 	render_edition_list(_lang);
 }
+//顶部的版本列表
 function render_edition_list(lang=""){
 	let firstChannel="";
 	if(_channal!=""){