diff --git a/app/static/scripts/function.js b/app/static/scripts/function.js index 889209de5da910ba0eef8130129e2e621de8eae7..45f9def541f9367b1cf71e5207af96dfdb894bc9 100644 --- a/app/static/scripts/function.js +++ b/app/static/scripts/function.js @@ -3,7 +3,11 @@ function displayloading() { } function request_account() { - if (document.getElementById("signup").valid){ + if (document.getElementById("username").checkValidity() && + document.getElementById("fullname").checkValidity() && + document.getElementById("email").checkValidity() && + document.getElementById("reason").checkValidity()){ + socket.emit('request account', { username: document.getElementById("username").value, fullname: document.getElementById("fullname").value, @@ -13,6 +17,27 @@ function request_account() { } } +function autofill_form(username, fullname, email) { + let username_input = document.getElementById("username"); + let fullname_input = document.getElementById("fullname"); + let email_input = document.getElementById("email"); + + if ((username.localeCompare("None")) !== 0) { + username_input.value = username; + username_input.disabled = "true"; + } + + if ((fullname.localeCompare("None")) !== 0) { + fullname_input.value = fullname; + fullname_input.disabled = "true"; + } + + if ((email.localeCompare("None")) !== 0) { + email_input.value = email; + email_input.disabled = "true"; + } + } + function refresh() { document.location.reload(true); } diff --git a/app/templates/auth/SignUp.html b/app/templates/auth/SignUp.html index ba57b67b9875b5f6304e15c00b9c82fd24c9a839..4d08425c8fe74e8a98469fbd45c45eb6cd2831ae 100644 --- a/app/templates/auth/SignUp.html +++ b/app/templates/auth/SignUp.html @@ -10,30 +10,9 @@ console.info('Room ID: {{ room_id }}'); var socket = io.connect('http://' + document.domain + ':' + location.port); - function autofill_form() { - var username = document.getElementById("username"); - let fullname = document.getElementById("fullname"); - let email = document.getElementById("email"); - - if (('{{ username }}'.localeCompare("None")) !== 0) { - username.value = "{{ username }}"; - username.disabled = "true"; - } - - if (('{{ fullname }}'.localeCompare("None")) !== 0) { - fullname.value = "{{ fullname }}"; - fullname.disabled = "true"; - } - - if (('{{ email }}'.localeCompare("None")) !== 0) { - email.value = "{{ email }}"; - email.disabled = "true"; - } - } - socket.on( 'connect', function() { - autofill_form(); + autofill_form("{{ username }}", "{{ fullname }}", "{{ email }}"); socket.emit( 'join_room', { referrer: '{{ referrer }}' @@ -117,34 +96,40 @@ <div id="test"> - <form id="signup" action="." method="post" onsubmit="" class=".bg-light"> - <div class="signUpContainer"> - <label for="username">Blazer Id:</label>	<input id="username" class="form-control" - placeholder="Enter username" required><br> - - <label for="fullname">Full Name:</label>	<input id="fullname" class="form-control" - placeholder="Enter fullname"required><br> - - <label for="email">Email:</label>	<input id="email" class="form-control" - placeholder="Enter email"required><br> - - <label for="reason">Reason for Requesting Account:</label><br> + <form id="signup" data-toggle="validator" role="form"> + <div class="form-group"> + <label for="username" class="control-label">Blazer Id:</label>	<input id="username" class="form-control" + placeholder="Enter Username" required><br> + </div> + <div class="form-group"> + <label for="fullname" class="control-label">Full Name:</label>	<input id="fullname" class="form-control" + placeholder="Enter Full Name" required><br> + </div> + <div class="form-group"> + <label for="email" class="control-label">Email:</label>	<input id="email" class="form-control" + placeholder="Enter Email" required><br> + </div> + <div class="form-group"> + <label for="reason" class="control-label">Reason for Requesting Account:</label><br> <textarea class="form-control" id="reason" name="reason" placeholder="Enter Reason for Account Request" required></textarea> + </div> <div class="row-no-gutters"> <div class="col-lg-6"> - <input class="btn btn-danger btn-block" id="cancel" name="cancel" type="button" value="Cancel" onclick="window.location.replace('{{ cancel_url }}');"> + <div class="form-group"> + <button class="btn btn-danger btn-block" id="cancel" type="button" onclick="window.location.replace('{{ cancel_url }}');">Cancel</button> + </div> </div> <div class="col-lg-6"> - <input class="btn btn-primary btn-block" id="submit" name="submit" type="button" value="Submit" onclick="request_account()"> + <div class="form-group"> + <button class="btn btn-primary btn-block" id="submit" type="submit" onclick="request_account()">Submit</button> + </div> </div> </div> <div> <strong id="error" style="color: #be051b; text-align: center;"></strong> </div> - - </div> </form> </div> </div> diff --git a/run.py b/run.py index 83fb57cfc9c50ff2f0bc49bf7842345a995b967d..8bc38c1b992b2d1d53c9f1a68a8d609b2acf5af8 100644 --- a/run.py +++ b/run.py @@ -19,7 +19,6 @@ app.config['SECRET_KEY'] = vars.key socketio = SocketIO(app) - @socketio.on('join_room') def on_room(json):