Skip to content
Snippets Groups Projects
Commit 1c85af5c authored by Stuart John Watson's avatar Stuart John Watson
Browse files

Starting to hide uneeded site parts

parent 6f294366
No related branches found
No related tags found
1 merge request!1Major Rebuild: AJAX and working game info
No preview for this file type
...@@ -46,7 +46,8 @@ ...@@ -46,7 +46,8 @@
<span class="sr-only">Error:</span> <span class="sr-only">Error:</span>
<span id="loginError"></span> <span id="loginError"></span>
</div> </div>
<form method="post" class="form-login">
<form method="post" class="form-login" id="login">
<div class="form-group"> <div class="form-group">
<input type="text" name="username" placeholder="Username" class="form-control"> <input type="text" name="username" placeholder="Username" class="form-control">
</div> </div>
...@@ -56,17 +57,18 @@ ...@@ -56,17 +57,18 @@
<button type="submit" class="btn btn-success">Sign in</button> <button type="submit" class="btn btn-success">Sign in</button>
Login with your SUCS username or Student Number Login with your SUCS username or Student Number
</form> </form>
<form action="https://sucs.org/join" class="form-signup">
<p id="username">Hello $authdUser!</p>
<p id="loginMessage"></p>
<form action="https://sucs.org/join" class="form-signup" id="signup">
<input type="submit" value="Sign up" class="btn btn-warning"> <input type="submit" value="Sign up" class="btn btn-warning">
</form> </form>
<p id="username">Hello $authdUser!</p>
<p id="loginMessage">$loginMessage</p> <form method="post" id="logout">
<div> <input type="hidden" value="logout" name="username">
<form method="post"> <input type="submit" value="Log out" class="btn btn-danger">
<input type="hidden" value="logout" name="username"> </form>
<input type="submit" value="Log out" class="btn btn-danger">
</form>
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -130,8 +132,12 @@ ...@@ -130,8 +132,12 @@
"BAD_LOGIN":"You have entered invalid credentials.", "BAD_LOGIN":"You have entered invalid credentials.",
"MISSING_USERNAME_OR_PASSWORD":"Please enter a username and password.", "MISSING_USERNAME_OR_PASSWORD":"Please enter a username and password.",
"BANNED":"Sorry you are banned. For more information contact games@sucs.org", "BANNED":"Sorry you are banned. For more information contact games@sucs.org",
"ERR_UNKNOWN_AUTH_TYPE":"An unexpected error occoured - Bad Auth Type." "ERR_UNKNOWN_AUTH_TYPE":"An unexpected error occoured - Bad Auth Type.",
} "UNI_DISALLOWED":"Only SUCS members are currentlly allowed access."
},
SUCCESS = "You are now logged into the SUCS Game Server system, and can connect to any of the servers we have running by simply specifying the hostname/IP address 'games.sucs.org'. This page must be left open while you are playing. When you close this window, you will no longer have access to the games server, and will have to login again if you wish to play some more.",
SIGNUP_INFO = "Thank you for taking an interest in playing on the SUCS game server. Unfortunately the game server is currently only available to SUCS members, you can <a href=\"https://sucs.org/join\">sign up</a> to SUCS and get 24/7 access to the server plus all the other benefits that come with SUCS membership.";
function onPostResponse(response){ function onPostResponse(response){
console.log(response) console.log(response)
...@@ -139,17 +145,35 @@ ...@@ -139,17 +145,35 @@
error = response["loginError"], error = response["loginError"],
username = response["username"], username = response["username"],
onlineUsers = response["onlineUsers"]; onlineUsers = response["onlineUsers"];
//Display Username & logout if set
if (username){ if (username){
$("#username").show().text(username); $("#username").show().text("Hello "+username);
$("#login").hide();
$("#logout").show();
} else { } else {
$("#username").hide(); $("#username").hide();
$("#login").show();
$("#logout").hide();
} }
//Display error if there is one
if (error){ if (error){
$("#loginErrorWrap").show(); $("#loginErrorWrap").show();
$("#loginError").text(ERR_MAP[error]); $("#loginError").text(ERR_MAP[error]);
} else { } else {
$("#loginErrorWrap").hide(); $("#loginErrorWrap").hide();
} }
//Display the apporiate login Message & boxes
if (error == "UNI_DISALLOWED"){
$("#loginMessage").show().html(SIGNUP_INFO);
$("#signup").show()
} else if (!error) {
$("#loginMessage").show().html(SUCCESS);
$("#signup").hide()
} else {
$("#loginMessage").hide();
}
$("#onlineList").empty();
for(var i=0;i<onlineUsers.length;i++){ for(var i=0;i<onlineUsers.length;i++){
$("<ul>").text(onlineUsers[i]).appendTo("#onlineList"); $("<ul>").text(onlineUsers[i]).appendTo("#onlineList");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment