diff --git a/website/frontend/js/search_encrypt.js b/website/frontend/js/search_encrypt.js index 86bdeae..a14d439 100644 --- a/website/frontend/js/search_encrypt.js +++ b/website/frontend/js/search_encrypt.js @@ -1,33 +1,35 @@ let rsa = new JSEncrypt({default_key_size: 1024}); -let is_started = true; +let is_generating = true; let public_key = get_with_expiry("public_key"); let private_key = get_with_expiry("private_key"); -if (public_key == null || private_key == null) { - rsa.getKey(function() { - let public_key = get_with_expiry("public_key"); - let private_key = get_with_expiry("private_key"); - - if (public_key == null) { - set_with_expiry("public_key", rsa.getPublicKey(), 3600 * 1000); //1 hour - } - if (private_key == null) { - set_with_expiry("private_key", rsa.getPrivateKey(), 3600 * 1000); //1 hour - } +function load() { + var title = document.getElementsByClassName("title")[0]; + title.innerHTML = "GENERATING..."; - set_with_expiry("public_key", rsa.getPublicKey(), 3600 * 1000); //1 hour - set_with_expiry("private_key", rsa.getPrivateKey(), 3600 * 1000); //1 hour + if (public_key == null || private_key == null) { + rsa.getKey(function() { + const expire_time = 3600 * 1000; //1 hour - is_started = false; + set_with_expiry("public_key", rsa.getPublicKey(), expire_time); + set_with_expiry("private_key", rsa.getPrivateKey(), expire_time); + + title.innerHTML = "librengine"; + is_generating = false; }); -} else { - is_started = false; + } else { + title.innerHTML = "librengine"; + is_generating = false; + } } function submit_form() { - if (is_started) return false; - is_started = true; + if (is_generating) { + return false; + } + + is_generating = true; let form = document.getElementById("search_widget"); let query = document.getElementById("q"); @@ -47,5 +49,6 @@ function submit_form() { key.value = btoa(public_key); form.submit(); + return false; -} \ No newline at end of file +} diff --git a/website/frontend/src/index.html b/website/frontend/src/index.html index d7b06e7..375dcc5 100644 --- a/website/frontend/src/index.html +++ b/website/frontend/src/index.html @@ -19,7 +19,7 @@ -
+