Parcourir la source

Merge pull request #378 from visuddhinanda/master

搜索结果支持翻页
visuddhinanda il y a 4 ans
Parent
commit
b5af4058a3

+ 8 - 1
app/palicanon/style.css

@@ -196,9 +196,16 @@ tag {
 }
 /*書標題特殊樣式*/
 .chapter_list .level_1 {
-	background: linear-gradient(45deg, #e89650 20%, transparent 90%);
 	color: whitesmoke;
 }
+.book_view .level_1 {
+	background: linear-gradient(45deg, #e89650 20%, transparent 90%);
+}
+/*当前选择書標題特殊樣式*/
+li.level_1.selected {
+	height: 250px;
+	background: linear-gradient(45deg, #e89650 20%, transparent 90%);
+}
 .progress_circle {
 	transform-origin: center;
 	transform: rotateZ(-90deg);

+ 6 - 1
app/reader/reader.js

@@ -1,5 +1,5 @@
 var _reader_view = "sent";
-var _reader_sent_id = 0;
+var _reader_sent_id = -1;
 var _reader_book = -1;
 var _reader_para = -1;
 var _reader_begin = -1;
@@ -8,6 +8,7 @@ var _channal = "";
 var _lang = "";
 var _author = "";
 var _display = "para";
+var _direction = "row";
 var arrMyTerm = new Array();
 var _sent_data = new Array();
 var link_str = "";
@@ -280,6 +281,10 @@ function edit_wbw(book, para) {
 
 function setMode(mode = "read") {
 	let url = "../reader/?view=" + _reader_view;
+
+	if (_reader_sent_id != -1) {
+		url += "&id=" + _reader_sent_id;
+	}
 	if (_reader_book != -1) {
 		url += "&book=" + _reader_book;
 	}

+ 29 - 5
app/search/paliword.js

@@ -2,7 +2,9 @@ var dict_pre_searching = false;
 var dict_pre_search_curr_word = "";
 var dict_search_xml_http = null;
 var _key_word = "";
+var _page = 0;
 var _filter_word = new Array();
+var _bookId = new Array();
 
 $(document).ready(function () {
 	paliword_search(_key_word);
@@ -16,6 +18,7 @@ function paliword_search(keyword, words = new Array(), book = new Array()) {
 			key: keyword,
 			words: JSON.stringify(words),
 			book: JSON.stringify(book),
+			page: _page,
 		},
 		function (data) {
 			let result = JSON.parse(data);
@@ -77,7 +80,12 @@ function render_word_result(worddata) {
 	let keyword = worddata.keyword;
 
 	html += "<div class='title'>";
-	html += "<a href='../reader/?view=chapter&book=" + worddata.book + "&para=" + worddata.para + "' target='_blank'>";
+	html +=
+		"<a href='../reader/?view=chapter&book=" +
+		worddata.book +
+		"&para=" +
+		worddata.para +
+		"&direction=col' target='_blank'>";
 	html += worddata.title + "</a></div>";
 
 	let newStr = highlightWords(worddata.palitext, keyword);
@@ -126,15 +134,18 @@ function word_search_filter() {
 	});
 	filter_cancel();
 	_filter_word = wordlist;
+	_page = 0;
 	paliword_search(_key_word, wordlist);
 }
 
 function word_select(wordid) {
 	_filter_word = [wordid];
+	_page = 0;
 	paliword_search(_key_word, [wordid]);
 }
 
 function case_filter_all() {
+	_page = 0;
 	paliword_search(_key_word);
 }
 
@@ -176,15 +187,23 @@ function render_nav(result) {
 	if (result["record_count"] > 20) {
 		let pages = parseInt(result["record_count"] / 20);
 		for (let index = 0; index < pages; index++) {
-			html += "<li >" + (index + 1) + "</li> ";
+			html += "<li ";
+			if (index == _page) {
+				html += "class='curr'";
+			}
+			html += " onclick=\"gotoPage('" + index + "')\"";
+			html += ">" + (index + 1) + "</li> ";
 		}
 	}
-	html += "<li >上一页</li> ";
-	html += "<li >下一页</li> ";
+	//html += "<li >上一页</li> ";
+	//html += "<li >下一页</li> ";
 	html += "</ul>";
 	return html;
 }
-
+function gotoPage(index) {
+	_page = index;
+	paliword_search(_key_word, _filter_word, _bookId);
+}
 function onWordFilterStart() {
 	$(".case_item").children().find(".filter").show();
 	$("#case_tools").children(".filter").show();
@@ -208,9 +227,13 @@ function search_book_filter(objid, type) {
 
 //选择需要过滤的书
 function book_select(bookid) {
+	_page = 0;
+
 	if (bookid == 0) {
+		_bookId = new Array();
 		paliword_search(_key_word, _filter_word);
 	} else {
+		_bookId = [bookid];
 		paliword_search(_key_word, _filter_word, [bookid]);
 	}
 }
@@ -222,6 +245,7 @@ function book_search_filter() {
 		}
 	});
 	book_filter_cancel();
+	_page = 0;
 	paliword_search(_key_word, _filter_word, booklist);
 }
 function onBookFilterStart() {

+ 3 - 1
app/search/paliword.php

@@ -133,7 +133,9 @@ include "../pcdl/html_head.php";
 		if(isset($_GET["key"])){
 			echo " _key_word = '{$_GET["key"]}';";
 		}
-		
+		if(isset($_GET["page"])){
+			echo " _page = '{$_GET["page"]}';";
+		}		
 		?>
 	</script>
 

+ 2 - 2
app/search/paliword_sc.php

@@ -209,8 +209,8 @@ $query = "SELECT count(*) from (SELECT book FROM word WHERE \"wordindex\" in $st
 $result["record_count"] = PDO_FetchOne($query);
 $result["time"][] = array("event" => "查询记录数", "time" => microtime(true) - $_start);
 
-$query = "SELECT book,paragraph, wordindex, sum(weight) as wt FROM word WHERE \"wordindex\" in $strQueryWordId $strQueryBookId GROUP BY book,paragraph ORDER BY wt DESC LIMIT 0,20";
-$Fetch = PDO_FetchAll($query);
+$query = "SELECT book,paragraph, wordindex, sum(weight) as wt FROM word WHERE \"wordindex\" in $strQueryWordId $strQueryBookId GROUP BY book,paragraph ORDER BY wt DESC LIMIT ?,?";
+$Fetch = PDO_FetchAll($query,array($_page * $_pagesize, $_pagesize));
 $result["time"][] = array("event" => "查询结束", "time" => microtime(true) - $_start);
 $out_data = array();
 

+ 2 - 1
app/search/search.css

@@ -27,7 +27,8 @@ highlight {
 	display: inline-block;
 	cursor: pointer;
 }
-.page_nav li:hover {
+.page_nav li:hover,
+.page_nav .curr {
 	background-color: var(--link-hover-color);
 	color: var(--btn-hover-color);
 }

+ 3 - 3
app/sync/sync.js

@@ -1,9 +1,9 @@
 var sync_db_list = [
+	{ script: "sync/table_channel.php", count: -1, finished: 0, enable: false },
 	{ script: "sync/table_article.php", count: -1, finished: 0, enable: false },
+	{ script: "sync/table_article_collect.php", count: -1, finished: 0, enable: false },
 	{ script: "sync/table_term_channel.php", count: -1, finished: 0, enable: false },
 	{ script: "sync/table_term_editor.php", count: -1, finished: 0, enable: false },
-	{ script: "sync/table_article_collect.php", count: -1, finished: 0, enable: false },
-	{ script: "sync/table_channel.php", count: -1, finished: 0, enable: false },
 	{ script: "sync/table_sentence.php", count: -1, finished: 0, enable: true },
 ];
 var isStop = false;
@@ -88,7 +88,7 @@ function sync_do_db(src, dest, time = 1) {
 					return;
 				}
 				let myDate = new Date();
-				myDate.setTime(result.time);
+				myDate.setTime(time);
 
 				$("#sync_log").html(
 					$("#sync_log").html() +

+ 10 - 1
app/sync/table_article_collect.php

@@ -59,6 +59,10 @@ if (isset($_GET["op"])) {
 }
 
 switch ($op) {
+	case "sync_count":
+		$result = do_sync($input);
+		echo json_encode($result, JSON_UNESCAPED_UNICODE);
+		break;
 	case "sync":
 		$result = do_sync($input);
 		echo json_encode($result, JSON_UNESCAPED_UNICODE);
@@ -106,7 +110,12 @@ switch ($op) {
 			$output["message"]=$collection->getError();
 		}
 		echo json_encode($result, JSON_UNESCAPED_UNICODE);
-	break;	
+	break;
+	default:
+		$output["error"]=1;
+		$output["message"]="错误的操作码";	
+		echo json_encode($result, JSON_UNESCAPED_UNICODE);
+	break;
 }
 
 

+ 1 - 1
app/sync/table_channel.php

@@ -30,7 +30,7 @@ $input = (object) [
 		'status',
 		'lang',
 		'modify_time'
-    ]    
+    ]
 ];
 
 $result = do_sync($input);