diff search.php @ 7:23dcd1b5e9c4 default tip

add keywords highlighting on searching result
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 16 Nov 2015 16:58:39 +0100
parents 4b9ae7d500f9
children
line wrap: on
line diff
--- a/search.php	Wed Oct 14 11:01:26 2015 +0200
+++ b/search.php	Mon Nov 16 16:58:39 2015 +0100
@@ -2,12 +2,14 @@
 include_once('config/Lib_mb_utf8.php');
 include_once('config/config.php');
 include_once('search_function.php');
+global $at_local;
 
-if ( isset($_POST['passwd']) ) {
+if ( isset($_POST['passwd']) || $at_local) {
 	$checkPasswd = 0;
 } else {
 	$checkPasswd = 1;
 }
+
 ?>
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
@@ -21,21 +23,18 @@
         
 		<script src="search.js" charset="utf-8"></script>
 		<script type="text/javascript">
-			// TODO: hide and show are not working here...
-			// after searching, the returning page still shows the popup
-
+			
 			// prompt to ask there password when open page
 			$(document).ready(function(){
 				initSection();
 
 				var checkPasswd = <?php echo $checkPasswd?>;
-				
 
 				if (checkPasswd == 1) {
 					$("#search").hide();
 					showPopup();			
 					console.log("showPopup");
-				} else {
+				} else if (checkPasswd == 0) {
 					$("#search").show();
 					closePopup();
 					console.log("closePopup");
@@ -45,16 +44,11 @@
     	</script>
 	</head>
 	<body>
-		
-
-    		
-
     	<div id="popup">
 		    <div>Enter Password:</div>
 		    <input id="pass" type="password" onKeyPress="return submitenter(event)"/>
 		    <button onclick="checkPassword()">OK</button>    
 		</div>
-
 		
 		<div id="search">
 			<form action='search.php' method='POST'>
@@ -65,22 +59,19 @@
 
 			</form>
 			<br>
-		
 			<div id="search_result">
 			<?php
 				if( isset($_POST['passwd']) && isset($_POST['search']) && $_POST['keyword']!='' && $_POST['filename']!=''){
-					
 					$keywordArray=trimKeyword($_POST['keyword']);
 					$array=search($keywordArray);
 					writeCsvFile($array,$_POST['filename']);
-					// write html to search_results folder
-					printTable($array,$keywordArray,$_POST['filename'],$NO_TAG);
+					printTable($array,$keywordArray,$_POST['filename'],$NO_TAG);	// also write html to search_results folder
 					
 				}			
 			?>
+
 			</div>
 		</div>
-	
 		
 	</body>
 </html>