Browse Source

搜索实现书过滤

visuddhinanda 5 years ago
parent
commit
5e83f60d94
4 changed files with 47 additions and 14 deletions
  1. 16 6
      app/search/paliword.js
  2. 2 0
      app/search/paliword.php
  3. 16 1
      app/search/paliword_sc.php
  4. 13 7
      app/search/search.css

+ 16 - 6
app/search/paliword.js

@@ -112,9 +112,17 @@ function word_search_filter() {
 	_filter_word = wordlist;
 	paliword_search(_key_word, wordlist);
 }
+
+function word_select(wordid) {
+	_filter_word = [wordid];
+	paliword_search(_key_word, [wordid]);
+}
+
 function case_filter_all() {
 	paliword_search(_key_word);
 }
+
+//渲染书标签过滤
 function render_book_tag(data) {
 	let html = "";
 	html += "<div class='fileter_item book_tag'>";
@@ -126,14 +134,19 @@ function render_book_tag(data) {
 	html += "</div>";
 	return html;
 }
-
+//渲染书列表
 function render_book_list(data) {
 	let html = "";
 	let bookid = data.book;
+	let classSelected = "selected";
 	html += "<div class='fileter_item book_item'>";
-	html += "<div class='spell'>";
+	html += "<div class='spell ";
+	if (data.selected) {
+		html += classSelected;
+	}
+	html += "'>";
 	html += "<input book='" + bookid + "' class='book_list filter' type='checkbox' checked  />";
-	html += '<a onclick="dict_bold_word_select({$i})">';
+	html += '<a onclick="book_select(' + bookid + ')">';
 	html += data.title;
 	html += "</a>";
 	html += "</div>";
@@ -166,9 +179,6 @@ function filter_cancel() {
 	$("#case_tools").children(".select_button").show();
 }
 function search_filter() {}
-function word_select(wordid) {
-	paliword_search(_key_word, [wordid]);
-}
 
 function search_book_filter(objid, type) {
 	if (document.getElementById(objid).checked == true) {

+ 2 - 0
app/search/paliword.php

@@ -73,6 +73,8 @@ include "../pcdl/html_head.php";
 	#pre_search_word_content{
 		display:block;
 	}
+
+
     </style>
     <style  media="screen and (max-width:800px)">
 		#index_list{

+ 16 - 1
app/search/paliword_sc.php

@@ -130,15 +130,17 @@ switch($op){
 			}
 			else{
 				foreach ($aInputWordList as $key => $value) {
-					$aInputWordList[$key] = true;
+					//$aInputWordList[$key] = true;
 				}
 			}
 		}
+		/*
 		else{
 			foreach ($aInputWordList as $key => $value) {
 				$aInputWordList[$key] = true;
 			}
 		}
+		*/
 		$strQueryWordId=mb_substr($strQueryWordId, 0,mb_strlen($strQueryWordId,"UTF-8")-1,"UTF-8");
 		$strQueryWordId.=")";
 
@@ -184,13 +186,26 @@ switch($op){
 		$strQueryBookId=" ";
 		if(isset($_GET["book"])){
 			$book_selected = json_decode($_GET["book"]);
+			$bookSelected = array();
 			if(count($book_selected)>0){
 				$strQueryBookId=" AND book IN (";
 				foreach ($book_selected as $key => $value) {
 					$strQueryBookId.="'{$value}',";
+					$bookSelected[$value]=1;
 				}
 				$strQueryBookId=mb_substr($strQueryBookId, 0,mb_strlen($strQueryBookId,"UTF-8")-1,"UTF-8");
 				$strQueryBookId.=")";
+
+				foreach ($result["book_list"] as $bookindex => $bookvalue) {
+					# code...
+					$bookid = $bookvalue["book"];
+					if(isset($bookSelected["{$bookid}"])){
+						$result["book_list"][$bookindex]["selected"]=true;
+					}
+					else{
+						$result["book_list"][$bookindex]["selected"]=false;
+					}
+				}
 			}
 		}
 

+ 13 - 7
app/search/search.css

@@ -36,7 +36,7 @@ highlight {
 	border-bottom: 1px;
 	display: flex;
 	justify-content: space-between;
-	padding: 3px 0;
+	padding: 3px;
 }
 .fileter_item > .tag {
 	background-color: gray;
@@ -64,21 +64,27 @@ highlight {
 	background-color: var(--link-hover-color);
 	color: var(--bg-color);
 }
-.fileter_item > .invalid a,
-.fileter_item > .invalid a:link,
-.fileter_item > .invalid a:visited {
+.fileter_item > .spell {
+	padding: 4px;
+}
+.fileter_item > .spell a,
+.fileter_item > .spell a:link,
+.fileter_item > .spell a:visited {
 	color: var(--box-bg-color1);
 }
-.fileter_item:hover > .invalid a,
-.fileter_item:hover > .invalid a:link,
-.fileter_item:hover > .invalid a:visited {
+.fileter_item:hover > .spell a,
+.fileter_item:hover > .spell a:link,
+.fileter_item:hover > .spell a:visited {
 	color: var(--bg-color);
 }
 
 .fileter_item > .selected {
+	border-left: 4px solid var(--link-hover-color);
 }
 .fileter_item > .selected a,
 .fileter_item > .selected a:link,
 .fileter_item > .selected a:visited {
 	font-weight: 700;
 }
+.book_item > .selected {
+}