Mercurial > hg > LGSearch
diff search.js @ 6:4b9ae7d500f9
add example page, modify password popup
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Wed, 14 Oct 2015 11:01:26 +0200 |
parents | c9363a90b8b5 |
children | 23dcd1b5e9c4 |
line wrap: on
line diff
--- a/search.js Mon Oct 12 15:36:13 2015 +0200 +++ b/search.js Wed Oct 14 11:01:26 2015 +0200 @@ -1,6 +1,4 @@ -$(document).ready(function(){ - initSection(); -}); + function initSection(){ //Hide sections if there are more than 5 $("td div.section").hide(); for(var i=1; i<=5; i++){ @@ -29,3 +27,57 @@ } }); } + +function submitenter(e) +{ + var keycode; + if (window.event) keycode = window.event.keyCode; + else if (e) keycode = e.which; + else return true; + + if (keycode == 13) { + checkPassword(); + return false; + } else { + return true; + } +} + +function checkPassword() { + 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) { + closePopup(); + $("#search").show(); + } else { + // still showing popup + alert("Wrong password!"); + showPopup(); + $("#search").hide(); + } + }); +}; + +function showPopup() { + // clear previous input + if (document.getElementById("pass")) { + document.getElementById("pass").value = ""; + document.getElementById("popup").style.display = "block"; + } +} +function closePopup() { + if (document.getElementById("pass")) { + document.getElementById("popup").style.display = "none"; + } +} \ No newline at end of file