Преглед изворни кода

用户指南功能基本完成

visuddhinanda пре 5 година
родитељ
комит
e278e7fcbb

+ 1 - 59
app/dict/index.php

@@ -113,34 +113,7 @@ require_once "../pcdl/html_head.php";
 			border-radius: 99px;
 			cursor: pointer;
 		}
-		guide{
-			position: relative;
-			display:inline-block;
-			width:1.4em;
-			height:1.4em;
-			cursor: pointer;
-			background-color:gray;
-		}
-		guide:hover  .guide_contence{
-			display:inline-block;
-		}
-		.guide_contence {
-			position: absolute;
-			top:100%;
-			width:18em;
-			min-height:30em;
-			padding:10px;
-			background-color:white;
-			box-shadow: 0 0 10px rgba(0,0,0,0.15);
-			font-size:10pt;
-			text-align:left;
-			display:none;
-		}
 
-		.guide_contence  h1{
-			font-size:1.5em;
-			font-weight:700;
-		}
 	</style>
 	<!-- tool bar begin-->
 	<div id='search_toolbar' class="search_toolbar">
@@ -149,7 +122,7 @@ require_once "../pcdl/html_head.php";
 				<div>
 					<div>
 						<div>
-						<guide gid="comp_split"></guide><input id="dict_ref_search_input" type="input" placeholder="<?php echo $_local->gui->search;?>" onkeyup="dict_input_keyup(event,this)" style="    margin-left: 0.5em;width: 40em;max-width: 100%;font-size:140%;padding: 0.6em;color: var(--btn-hover-bg-color);background-color: var(--btn-color);" onfocus="dict_input_onfocus()" />
+						<guide gid="dict_search_input"></guide><input id="dict_ref_search_input" type="input" placeholder="<?php echo $_local->gui->search;?>" onkeyup="dict_input_keyup(event,this)" style="    margin-left: 0.5em;width: 40em;max-width: 100%;font-size:140%;padding: 0.6em;color: var(--btn-hover-bg-color);background-color: var(--btn-color);" onfocus="dict_input_onfocus()" />
 						</div>
 						<div id="word_parts">
 							<div id="input_parts" style="font-size: 1.1em;padding: 2px 1em;"></div>
@@ -253,38 +226,7 @@ function GetPageScroll()
     }
 	?>
 	
-	<script>
-		$("guide").each(function(){
-			if($(this).offset().left<$(document.body).width()/2){
-				$(this).append('<div  class="guide_contence" style="left: 0;"></div>');
-			}
-			else{
-				$(this).append('<div  class="guide_contence" style="right: 0;"></div>');
-			}
-		});
 
-		$("guide").mouseenter(function(){
-			if($(this).children(".guide_contence").first().html().length>0){
-				return;
-			}
-			let gid = $(this).attr("gid");
-			let guideObj = $(this);
-			$.get("../guide/get.php",
-				{
-					id:gid
-				},
-			function(data,status){
-				try{
-					let jsonGuide = JSON.parse(data);
-					$("guide[gid='"+jsonGuide.id+"']").find(".guide_contence").html(marked(jsonGuide.data));
-				}
-				catch(e){
-					console.error(e);
-				}
-			});
-		});
-
-	</script>
 <?php
 include "../pcdl/html_foot.php";
 ?>

+ 27 - 3
app/guide/get.php

@@ -1,9 +1,33 @@
 <?php
 require_once "../path.php";
 
-$filename = _DIR_USERS_GUIDE_."/en/".$_GET["id"].".md";
-$output["data"]  =  file_get_contents($filename) ;
-$output["id"]  =$_GET["id"];
+//获取用户界面语言
+if(isset($_COOKIE["language"])){
+    $lang = $_COOKIE["language"];
+}
+else{
+    $lang = "en";
+}
+//查找用户界面语言对应的文件
+$filename = _DIR_USERS_GUIDE_."/{$lang}/".$_GET["id"].".md";
+if(file_exists($filename)){
+    $output["data"]  =  file_get_contents($filename) ;
+    $output["id"]  =$_GET["id"];
+}
+else{
+    //如果用户界面不是英语,尝试使用英语文件
+    $filename = _DIR_USERS_GUIDE_."/en/".$_GET["id"].".md";
+    if($lang != "en" && file_exists($filename)){
+        $output["data"]  =  file_get_contents($filename) ;
+        $output["id"]  =$_GET["id"];
+    }
+    else{
+        //尝试使用英语文件不成功,报错
+        $output["data"]  =  "Error: Can't Find Item In Server. Item Id:{$_GET["id"]}  Language:{$lang}";
+        $output["id"]  =$_GET["id"];
+    }
+}
+
 echo json_encode($output,JSON_UNESCAPED_UNICODE);
 
 ?>

+ 43 - 0
app/guide/guide.css

@@ -0,0 +1,43 @@
+guide{
+    position: relative;
+    display:inline-block;
+    width:14px;
+    height:14px;
+    cursor: pointer;
+    background: url(guide_icon.svg);
+    background-repeat: no-repeat;
+    background-size: contain;
+    margin: 0 6px;
+}
+guide:hover  .guide_contence{
+    display:inline-block;
+}
+.guide_contence {
+    position: absolute;
+    top:100%;
+    width:18em;
+    min-height:30em;
+    padding:10px;
+    background-color:white;
+    box-shadow: 0 0 10px rgba(0,0,0,0.15);
+    font-size:10pt;
+    text-align:left;
+    display:none;
+}
+
+.guide_contence  h1{
+    font-size:1.5em;
+    font-weight:700;
+}
+.guide_contence  h2{
+    font-size:1.3em;
+    font-weight:700;
+}
+.guide_contence  h3{
+    font-size:1.1em;
+    font-weight:700;
+}
+.guide_contence  h4{
+    font-size:1em;
+    font-weight:700;
+}

+ 29 - 0
app/guide/guide.js

@@ -1,3 +1,32 @@
 function guide_init() {
+    $("guide").each(function () {
+        if ($(this).offset().left < $(document.body).width() / 2) {
+            $(this).append('<div  class="guide_contence" style="left: 0;"></div>');
+        }
+        else {
+            $(this).append('<div  class="guide_contence" style="right: 0;"></div>');
+        }
+    });
+
+    $("guide").mouseenter(function () {
+        if ($(this).children(".guide_contence").first().html().length > 0) {
+            return;
+        }
+        let gid = $(this).attr("gid");
+        let guideObj = $(this);
+        $.get("../guide/get.php",
+            {
+                id: gid
+            },
+            function (data, status) {
+                try {
+                    let jsonGuide = JSON.parse(data);
+                    $("guide[gid='" + jsonGuide.id + "']").find(".guide_contence").html(marked(jsonGuide.data));
+                }
+                catch (e) {
+                    console.error(e);
+                }
+            });
+    });
 
 }

+ 0 - 30
app/guide/guide_icon.svg

@@ -5,34 +5,4 @@
 	 width="14px" height="14px" viewBox="0 0 14 14" style="enable-background:new 0 0 14 14;" xml:space="preserve">
 <path d="M7,0C3.134,0,0,3.134,0,7s3.134,7,7,7s7-3.134,7-7S10.866,0,7,0z M7,2c0.552,0,1,0.447,1,1S7.552,4,7,4S6,3.553,6,3
 	S6.448,2,7,2z M9,11H5v-1h1V6H5V5h3v5h1V11z"/>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
-<g>
-</g>
 </svg>

+ 6 - 1
app/pcdl/html_foot.php

@@ -48,7 +48,12 @@
 </div>S
 	
 <div class="foot_div">
-wikipali @2020
+	<div>wikipali @2020</div>
+	<div>Powered by PCD Suite</div>
 </div>
+
+<script>
+	guide_init();
+</script>
 </body>
 </html>

+ 5 - 0
app/pcdl/html_head.php

@@ -27,11 +27,16 @@ else{
     <link type="text/css" rel="stylesheet" href="../pcdl/css/basic_style.css"/>
     <link type="text/css" rel="stylesheet" href="../pcdl/css/color_day.css" id="colorchange" />
     <link type="text/css" rel="stylesheet" href="../pcdl/css/style_mobile.css" media="screen and (max-width:767px)">
+
+	<link type="text/css" rel="stylesheet" href="../guide/guide.css"/>
+
     <title>圣典</title>
 
 	<script src="../public/js/jquery.js"></script>
 	<script src="../public/js/comm.js"></script>
 	<script src="../studio/js/fixedsticky.js"></script>
+	<script src="../guide/guide.js"></script>
+	
 	<script >
 	<?php require_once '../public/load_lang_js.php';?>
 	</script>

+ 2 - 1
app/ucenter/user.php

@@ -31,10 +31,11 @@
 		text-align:right;
 	}
 	#user_bar{
-		border: 2px solid var(--btn-border-color);
+		border: 1px solid var(--btn-border-color);
 		border-radius: 99px;
 		color: var(--btn-color);
 		padding: 2px 2px 2px 15px;
+		height: min-content;
 	}
 	</style>
 		<div style="margin:auto;" class="dropdown" onmouseover="switchMenu(this,'user_info')" onmouseout="hideMenu()">

+ 3 - 2
documents/users_guide/en/comp_split.md

@@ -1,2 +1,3 @@
-# 强力复合词拆分
-这是基于语料库的复合词自动拆分程序。点击数字选择更多选项。
+# 强大的复合词拆分
+
+这是基于语料库的复合词自动拆分程序。程序会进行深度切分和搜索,给出可能性比较高的一些可能。点击组分后面的数字选择其他的可能。

+ 6 - 0
documents/users_guide/en/dict_search_input.md

@@ -0,0 +1,6 @@
+## Smart Dictionary
+
+You can put the plus(+)between parts in the compone word, and than click one part(under the search input) lookup dictionary.
+
+### Example:
+citta+kamma

+ 3 - 0
documents/users_guide/zh-cn/comp_split.md

@@ -0,0 +1,3 @@
+# 强大的复合词拆分
+
+这是基于语料库的复合词自动拆分程序。程序会进行深度切分和搜索,给出可能性比较高的一些可能。点击组分后面的数字选择其他的可能。

+ 6 - 0
documents/users_guide/zh-cn/dict_search_input.md

@@ -0,0 +1,6 @@
+## 聪明的单词搜索
+
+您可以在输入框中的复合词中加入加号(+)用以分隔单词的各个组成部分。利用搜索框下方的组分列表查询组分的意思。
+
+### 例如:
+citta+kamma

+ 3 - 0
documents/users_guide/zh-tw/comp_split.md

@@ -0,0 +1,3 @@
+# 强大的复合词拆分
+
+这是基于语料库的复合词自动拆分程序。程序会进行深度切分和搜索,给出可能性比较高的一些可能。点击组分后面的数字选择其他的可能。

+ 3 - 0
documents/users_guide/zh-tw/dict_search_input.md

@@ -0,0 +1,3 @@
+## 聪明的单词搜索
+
+您可以在输入的复合词中加入加号(+)。利用搜索框下方的组分列表查询组分的意思。