Mercurial > hg > LGSearch
comparison 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 |
comparison
equal
deleted
inserted
replaced
6:4b9ae7d500f9 | 7:23dcd1b5e9c4 |
---|---|
1 <?php | 1 <?php |
2 include_once('config/Lib_mb_utf8.php'); | 2 include_once('config/Lib_mb_utf8.php'); |
3 include_once('config/config.php'); | 3 include_once('config/config.php'); |
4 include_once('search_function.php'); | 4 include_once('search_function.php'); |
5 global $at_local; | |
5 | 6 |
6 if ( isset($_POST['passwd']) ) { | 7 if ( isset($_POST['passwd']) || $at_local) { |
7 $checkPasswd = 0; | 8 $checkPasswd = 0; |
8 } else { | 9 } else { |
9 $checkPasswd = 1; | 10 $checkPasswd = 1; |
10 } | 11 } |
12 | |
11 ?> | 13 ?> |
12 | 14 |
13 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | 15 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
14 <html> | 16 <html> |
15 <head> | 17 <head> |
19 <script src="js/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> | 21 <script src="js/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> |
20 <script src="js/jquery/jquery-ui.js" type="text/javascript"></script> | 22 <script src="js/jquery/jquery-ui.js" type="text/javascript"></script> |
21 | 23 |
22 <script src="search.js" charset="utf-8"></script> | 24 <script src="search.js" charset="utf-8"></script> |
23 <script type="text/javascript"> | 25 <script type="text/javascript"> |
24 // TODO: hide and show are not working here... | 26 |
25 // after searching, the returning page still shows the popup | |
26 | |
27 // prompt to ask there password when open page | 27 // prompt to ask there password when open page |
28 $(document).ready(function(){ | 28 $(document).ready(function(){ |
29 initSection(); | 29 initSection(); |
30 | 30 |
31 var checkPasswd = <?php echo $checkPasswd?>; | 31 var checkPasswd = <?php echo $checkPasswd?>; |
32 | |
33 | 32 |
34 if (checkPasswd == 1) { | 33 if (checkPasswd == 1) { |
35 $("#search").hide(); | 34 $("#search").hide(); |
36 showPopup(); | 35 showPopup(); |
37 console.log("showPopup"); | 36 console.log("showPopup"); |
38 } else { | 37 } else if (checkPasswd == 0) { |
39 $("#search").show(); | 38 $("#search").show(); |
40 closePopup(); | 39 closePopup(); |
41 console.log("closePopup"); | 40 console.log("closePopup"); |
42 } | 41 } |
43 }); | 42 }); |
44 | 43 |
45 </script> | 44 </script> |
46 </head> | 45 </head> |
47 <body> | 46 <body> |
48 | |
49 | |
50 | |
51 | |
52 <div id="popup"> | 47 <div id="popup"> |
53 <div>Enter Password:</div> | 48 <div>Enter Password:</div> |
54 <input id="pass" type="password" onKeyPress="return submitenter(event)"/> | 49 <input id="pass" type="password" onKeyPress="return submitenter(event)"/> |
55 <button onclick="checkPassword()">OK</button> | 50 <button onclick="checkPassword()">OK</button> |
56 </div> | 51 </div> |
57 | |
58 | 52 |
59 <div id="search"> | 53 <div id="search"> |
60 <form action='search.php' method='POST'> | 54 <form action='search.php' method='POST'> |
61 關鍵字: <input type="text" name="keyword" size="100"> (若要搜尋多筆關鍵字請用半型逗號,隔開)<br> | 55 關鍵字: <input type="text" name="keyword" size="100"> (若要搜尋多筆關鍵字請用半型逗號,隔開)<br> |
62 將結果輸出至: <input type="text" name="filename" size="40">.html (請用英文非空白字元命名)<br> | 56 將結果輸出至: <input type="text" name="filename" size="40">.html (請用英文非空白字元命名)<br> |
63 <input type="submit" name="search" value="搜尋"> | 57 <input type="submit" name="search" value="搜尋"> |
64 <input type="hidden" name="passwd"> | 58 <input type="hidden" name="passwd"> |
65 | 59 |
66 </form> | 60 </form> |
67 <br> | 61 <br> |
68 | |
69 <div id="search_result"> | 62 <div id="search_result"> |
70 <?php | 63 <?php |
71 if( isset($_POST['passwd']) && isset($_POST['search']) && $_POST['keyword']!='' && $_POST['filename']!=''){ | 64 if( isset($_POST['passwd']) && isset($_POST['search']) && $_POST['keyword']!='' && $_POST['filename']!=''){ |
72 | |
73 $keywordArray=trimKeyword($_POST['keyword']); | 65 $keywordArray=trimKeyword($_POST['keyword']); |
74 $array=search($keywordArray); | 66 $array=search($keywordArray); |
75 writeCsvFile($array,$_POST['filename']); | 67 writeCsvFile($array,$_POST['filename']); |
76 // write html to search_results folder | 68 printTable($array,$keywordArray,$_POST['filename'],$NO_TAG); // also write html to search_results folder |
77 printTable($array,$keywordArray,$_POST['filename'],$NO_TAG); | |
78 | 69 |
79 } | 70 } |
80 ?> | 71 ?> |
72 | |
81 </div> | 73 </div> |
82 </div> | 74 </div> |
83 | |
84 | 75 |
85 </body> | 76 </body> |
86 </html> | 77 </html> |
87 | 78 |