Browse Source

增加用户指南功能

visuddhinanda 5 years ago
parent
commit
3410c87331
5 changed files with 56 additions and 17 deletions
  1. 41 17
      app/dict/index.php
  2. 9 0
      app/guide/get.php
  3. 0 0
      app/guide/guide.css
  4. 3 0
      app/guide/guide.js
  5. 3 0
      app/path.php

+ 41 - 17
app/dict/index.php

@@ -1,5 +1,5 @@
 <?PHP
-include "../pcdl/html_head.php";
+require_once "../pcdl/html_head.php";
 ?>
 <body>
 
@@ -114,20 +114,31 @@ include "../pcdl/html_head.php";
 			cursor: pointer;
 		}
 		guide{
+			position: relative;
 			display:inline-block;
 			width:1.4em;
 			height:1.4em;
 			cursor: pointer;
 			background-color:gray;
 		}
-		#guide {
+		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);
-		}		
-		#guide h1{
-			font-size:2em;
+			font-size:10pt;
+			text-align:left;
+			display:none;
+		}
+
+		.guide_contence  h1{
+			font-size:1.5em;
 			font-weight:700;
 		}
 	</style>
@@ -138,7 +149,7 @@ include "../pcdl/html_head.php";
 				<div>
 					<div>
 						<div>
-							<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="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()" />
 						</div>
 						<div id="word_parts">
 							<div id="input_parts" style="font-size: 1.1em;padding: 2px 1em;"></div>
@@ -241,25 +252,38 @@ function GetPageScroll()
         echo "</script>";
     }
 	?>
-	<div id="guide" style="position:absolute;"></div>
+	
 	<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(){
-			let id = $(this).attr("gid");
-			var guideObj = $(this);
-			$.get("../../documents/users_guide/en/"+id+".md",
+			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){
-				$("#guide").html(marked(data));
-				$("#guide").appendTo(guideObj);
-				//$("#guide").show();
+				try{
+					let jsonGuide = JSON.parse(data);
+					$("guide[gid='"+jsonGuide.id+"']").find(".guide_contence").html(marked(jsonGuide.data));
+				}
+				catch(e){
+					console.error(e);
+				}
 			});
 		});
 
-		$("guide").mouseout(function(){
-			//$("#guide").hide();
-		});
-
 	</script>
 <?php
 include "../pcdl/html_foot.php";

+ 9 - 0
app/guide/get.php

@@ -0,0 +1,9 @@
+<?php
+require_once "../path.php";
+
+$filename = _DIR_USERS_GUIDE_."/en/".$_GET["id"].".md";
+$output["data"]  =  file_get_contents($filename) ;
+$output["id"]  =$_GET["id"];
+echo json_encode($output,JSON_UNESCAPED_UNICODE);
+
+?>

+ 0 - 0
app/guide/guide.css


+ 3 - 0
app/guide/guide.js

@@ -0,0 +1,3 @@
+function guide_init() {
+
+}

+ 3 - 0
app/path.php

@@ -14,6 +14,9 @@ define("_DIR_DICT_SYSTEM_" , __DIR__."/../appdata/dict/system");
 define("_DIR_DICT_3RD_" , __DIR__."/../appdata/dict/3rd");
 define("_DIR_DICT_REF_" , __DIR__."/../appdata/dict/ref");
 
+define("_DIR_USERS_GUIDE_" , __DIR__."/../documents/users_guide");
+
+
 define("_FILE_DB_REF_"  , __DIR__."/../appdata/dict/system/ref.db");
 define("_FILE_DB_REF_INDEX_"  , __DIR__."/../appdata/dict/system/ref1.db");
 define("_FILE_DB_part_"  , __DIR__."/../appdata/dict/system/part.db3");