Add loading animation when searching pubkey

This commit is contained in:
poka 2019-11-07 23:39:33 +01:00
parent 30ecfb23c8
commit 659a86eba4
3 changed files with 39 additions and 0 deletions

View File

@ -103,6 +103,38 @@ header.header img {
margin: 5px auto; margin: 5px auto;
text-align: center; text-align: center;
} }
/******************************************************************/
/* LOADING PUBKEY */
/******************************************************************/
/*.loadingPubkey {
// display: none;
position: fixed;
z-index: 1000;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: rgba( 255, 255, 255, .8 )
url('http://i.stack.imgur.com/FhHRx.gif')
50% 50%
no-repeat;
}*/
.loadingPubkey {
display: none;
height: 20px;
width: 20px;
content:url('../images/ajax-loader.gif')
}
body.loading .loadingPubkey {
overflow: hidden;
display: block;
}
/******************************************************************/ /******************************************************************/
/* POUR MOBILES */ /* POUR MOBILES */
/******************************************************************/ /******************************************************************/

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

View File

@ -6,6 +6,7 @@
<form action="{{ path('account.signup') }}" method="post"> <form action="{{ path('account.signup') }}" method="post">
{{ csrf_input() }} {{ csrf_input() }}
{{ field('username', user.username, "Pseudo") }} {{ field('username', user.username, "Pseudo") }}
<div class="loadingPubkey"></div>
<div id="livesearch-pubkey"></div> <div id="livesearch-pubkey"></div>
<div id=cle_pub>{{ field('pubkey', user.pubkey, "Clé publique") }}</div> <div id=cle_pub>{{ field('pubkey', user.pubkey, "Clé publique") }}</div>
{{ field('firstname', user.firstname, "Prénom") }} {{ field('lastname', user.lastname, "Nom") }} {{ field('firstname', user.firstname, "Prénom") }} {{ field('lastname', user.lastname, "Nom") }}
@ -22,6 +23,9 @@
var textInput = document.getElementById('username'); var textInput = document.getElementById('username');
var timeout = null; var timeout = null;
$body = $("body");
noPubKey("hide")
textInput.onkeyup = function (e) { textInput.onkeyup = function (e) {
clearTimeout(timeout); clearTimeout(timeout);
timeout = setTimeout(function () { timeout = setTimeout(function () {
@ -38,12 +42,14 @@ textInput.onkeyup = function (e) {
(pubkeyIsNull) ? noPubKey("block") : noPubKey("hide"); (pubkeyIsNull) ? noPubKey("block") : noPubKey("hide");
} }
} }
$body.addClass("loading");
xmlhttp.open("GET","/ajax/getG1PubKey.php?vendeur="+textInput.value,true); xmlhttp.open("GET","/ajax/getG1PubKey.php?vendeur="+textInput.value,true);
xmlhttp.send(); xmlhttp.send();
}, 800); }, 800);
}; };
function noPubKey(state) { function noPubKey(state) {
$body.removeClass("loading");
var textMbr = document.getElementById("cle_pub"); var textMbr = document.getElementById("cle_pub");
if (state == "hide"){ if (state == "hide"){
textMbr.style.display = "none"; textMbr.style.display = "none";
@ -52,6 +58,7 @@ function noPubKey(state) {
} }
} }
</script> </script>
{% endblock %} {% endblock %}