From d24bc122966845bfc793c46aa268529f086af58f Mon Sep 17 00:00:00 2001 From: TrueKuehli Date: Mon, 1 Oct 2018 20:55:14 +0200 Subject: Added Game Page, currently with a chat Redirects to the game page after login, keeping the connection intact --- .../NodeJSServer/src/modules/ui/login-modal.js | 21 +++++++++++++-------- .../NodeJSServer/src/modules/ui/server-listing.js | 3 +-- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'WebInterface/NodeJSServer/src/modules/ui') diff --git a/WebInterface/NodeJSServer/src/modules/ui/login-modal.js b/WebInterface/NodeJSServer/src/modules/ui/login-modal.js index d2a88c4..0bfd70d 100644 --- a/WebInterface/NodeJSServer/src/modules/ui/login-modal.js +++ b/WebInterface/NodeJSServer/src/modules/ui/login-modal.js @@ -86,10 +86,10 @@ export default class LoginModal extends Modal { */ registerLoginBtn() { let eventListener; - let loginCallBack = (result, client) => { + let loginCallBack = (result, connection) => { console.log(result); if (result == 0) { - this.redirectToPlay(client); + this.redirectToPlay(connection); this.close(); } else if (result == 1) { this.invalid('Name'); @@ -107,11 +107,11 @@ export default class LoginModal extends Modal { eventListener = () => { this.invalid(); // Remove 'invalid' messages this.loginButton.removeEventListener('click', eventListener); - let userName = this.nameInput.value; + this.userName = this.nameInput.value; this.passwordInput.value.getHash() .then((result) => { this.serverClient.sendLogin(this.serverName, result, - userName, loginCallBack); + this.userName, loginCallBack); }); }; this.loginButton.addEventListener('click', eventListener); @@ -145,17 +145,18 @@ export default class LoginModal extends Modal { /** * Loads play site - * @param {ServerClient} serverClient Main server client + * @param {HubConnection} connection Connection to the server */ - redirectToPlay(serverClient) { + redirectToPlay(connection) { window.history.pushState('object or string', 'Game Page', 'play#game=' + this.serverName); fetch('play').then((response) => { response.text().then((htmlString) => { htmlString = htmlString.replace(/\.\.\//g, './'); htmlString = htmlString.replace(/