From 36ba716ad808fa946ce3e724384cd7a50de3ea2e Mon Sep 17 00:00:00 2001 From: binaryDiv Date: Sun, 20 Jan 2019 05:01:58 +0100 Subject: [PATCH] Client: add ui.js; create Client object from ui.js --- public_html/index.html | 3 ++- public_html/js/client.js | 6 ------ public_html/js/settings.js | 5 ++++- public_html/js/ui.js | 10 ++++++++++ 4 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 public_html/js/ui.js diff --git a/public_html/index.html b/public_html/index.html index c4cf468..0c9aec9 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -5,7 +5,7 @@ InstantChat - + @@ -13,6 +13,7 @@ + diff --git a/public_html/js/client.js b/public_html/js/client.js index 8a19005..5b90372 100644 --- a/public_html/js/client.js +++ b/public_html/js/client.js @@ -99,9 +99,3 @@ 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 index eec7552..1d61ebc 100644 --- a/public_html/js/settings.js +++ b/public_html/js/settings.js @@ -1,7 +1,10 @@ "use strict"; -// Global settings object +/** + * Global settings object. + */ const AppSettings = { + // Alternative WebSocket URI for local testing: // serverWsUri: "ws://localhost:32715", serverWsUri: "wss://chat.glitch-in.space:443/ws/", }; diff --git a/public_html/js/ui.js b/public_html/js/ui.js new file mode 100644 index 0000000..1afd0d0 --- /dev/null +++ b/public_html/js/ui.js @@ -0,0 +1,10 @@ +"use strict"; + +// Global object for debugging purposes +let client; + +// Execute this on start (wrapped in an anonymous function) +(function() { + const wsUri = AppSettings.serverWsUri; + client = new Client(wsUri); +})();