gmarche/src/Account/views/signup.twig

73 lines
2.3 KiB
Twig

{% extends 'layout.twig' %}
{% block body %}
<div class="container" style="background-color: lightgray;opacity: 0.9;margin: 1rem;padding:1rem;">
<form action="{{ path('account.signup') }}" method="post">
{{ csrf_input() }}
{{ field('username', user.username, "Pseudo") }}
{{ field('pubkey', user.pubkey, "Clé publique") }}
<!--<input type="text" size="30" onkeyup="showResult(this.value)">-->
<input type="text" id="vendeur-input" />
<div id="livesearch"></div>
{{ field('firstname', user.firstname, "Prénom") }} {{ field('lastname', user.lastname, "Nom") }}
{{ field('email', user.email, "Email", {type: 'email'}) }}
{{ field('password', null, "Mot de passe", {type: 'password'}) }}
{{ field('password_confirm', null, "Confirmez le mot de passe", {type: 'password'}) }}
{{ field('created_at', date(), null, {type: 'hidden'}) }}
<button class="btn btn-primary">S'inscrire</button>
</form>
</div>
<script>
function showResult(str) {
if (str.length==0) {
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.border="0px";
return;
}
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (this.readyState==4 && this.status==200) {
document.getElementById("livesearch").innerHTML=this.responseText;
document.getElementById("livesearch").style.border="1px solid #A5ACB2";
}
}
xmlhttp.open("GET","/ajax/getG1PubKey.php?vendeur="+str,true);
xmlhttp.send();
}
</script>
<script>
var textInput = document.getElementById('vendeur-input');
var timeout = null;
textInput.onkeyup = function (e) {
clearTimeout(timeout);
// Make a new timeout set to go off in 800ms
timeout = setTimeout(function () {
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (this.readyState==4 && this.status==200) {
document.getElementById("livesearch").innerHTML=this.responseText;
document.getElementById("livesearch").style.border="1px solid #A5ACB2";
}
}
xmlhttp.open("GET","/ajax/getG1PubKey.php?vendeur="+textInput.value,true);
xmlhttp.send();
}, 1000);
};
</script>
{% endblock %}