Mercurial > hg > LGSearch
diff search.php @ 5:1cf7bb8db5dd
modify passwd popup
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 12 Oct 2015 15:36:13 +0200 |
parents | c3c31d031945 |
children | 4b9ae7d500f9 |
line wrap: on
line diff
--- a/search.php Thu Jun 25 18:29:48 2015 +0200 +++ b/search.php Mon Oct 12 15:36:13 2015 +0200 @@ -15,7 +15,10 @@ <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link href="search.css" type="text/css" rel="stylesheet"/> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> + + <script src="js/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> + <script src="js/jquery/jquery-ui.js" type="text/javascript"></script> + <script src="search.js" charset="utf-8"></script> </head> <body> @@ -23,16 +26,50 @@ // prompt to ask the password when open page var checkPasswd = <?php echo $checkPasswd?>; if (checkPasswd == 1) { - var password = "3333"; - var string = prompt("Please enter password", ""); - if(string!=password) { - alert("Wrong password!"); - window.location="http://localgazetteers.mpiwg-berlin.mpg.de"; - } + showPopup(); } + function done() { + var password = document.getElementById("pass").value; + $.ajax({ + url : 'search_function.php', + async : false, + type : 'POST', + data : 'func=checkPassword'+'&password='+password, + success: function (e) { + }, + error: function (e) { + alert("Internal error when checking password."); + } + }).done(function(result) { + console.log("password checking result: "+result); + if (result == 1) { + document.getElementById("popup").style.display = "none"; + } else { + // still showing popup + alert("Wrong password!"); + showPopup(); + } + }); + }; + + function showPopup() { + // clear previous input + if (document.getElementById("pass")) { + document.getElementById("pass").value = ""; + document.getElementById("popup").style.display = "block"; + } + } + + </script> + <div id="popup"> + <div>Enter Password:</div> + <input id="pass" type="password"/> + <button onclick="done()">OK</button> + </div> + <form action='search.php' method='POST'> 關鍵字: <input type="text" name="keyword" size="100"> (若要搜尋多筆關鍵字請用半型逗號,隔開)<br> 將結果輸出至: <input type="text" name="filename" size="40">.html (請用英文非空白字元命名)<br>