From 98c89f0702374d7883eb09673d058acb9aa35654 Mon Sep 17 00:00:00 2001 From: binaryDiv Date: Sun, 20 Jan 2019 02:06:30 +0100 Subject: [PATCH] Client: add global AppSettings object --- public_html/index.html | 1 + public_html/js/client.js | 7 +++---- public_html/js/settings.js | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 public_html/js/settings.js diff --git a/public_html/index.html b/public_html/index.html index bd0597e..c4cf468 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -11,6 +11,7 @@

InstantChat

+ diff --git a/public_html/js/client.js b/public_html/js/client.js index 9768bfc..974a5bd 100644 --- a/public_html/js/client.js +++ b/public_html/js/client.js @@ -1,6 +1,4 @@ -// Constants and variables -// const wsUri = "ws://localhost:32715"; -const wsUri = "wss://chat.glitch-in.space:443/ws/"; +"use strict"; class Client { constructor(wsUri) { @@ -17,7 +15,7 @@ class Client { // WebSocket event handlers onOpen(evt) { - console.log("Connected to " + wsUri); + console.log("Connected to " + this.wsUri); // Send init command containing chat ID and nickname this.sendInit(); @@ -83,5 +81,6 @@ class Client { // Run script after page is loaded $(function() { + const wsUri = AppSettings.serverWsUri; let client = new Client(wsUri); }); diff --git a/public_html/js/settings.js b/public_html/js/settings.js new file mode 100644 index 0000000..eec7552 --- /dev/null +++ b/public_html/js/settings.js @@ -0,0 +1,7 @@ +"use strict"; + +// Global settings object +const AppSettings = { + // serverWsUri: "ws://localhost:32715", + serverWsUri: "wss://chat.glitch-in.space:443/ws/", +};