From: Christopher Allan Webber Date: Sat, 21 Jan 2017 22:38:38 +0000 (-0600) Subject: Connect to the right url no matter where we connect from X-Git-Tag: fosdem-2017~104 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=7197e223d181722f6df49acb979c0d2f9f2c9551;p=mudsync.git Connect to the right url no matter where we connect from --- diff --git a/data/web-static/js/mudsync.js b/data/web-static/js/mudsync.js index 90f3daa..b926c14 100644 --- a/data/web-static/js/mudsync.js +++ b/data/web-static/js/mudsync.js @@ -27,9 +27,9 @@ function displayMessage(data, self_sent) { - stream_metabox.offsetHeight)) { should_scroll = true; } - document.getElementById("main-input").value = ""; if (self_sent) { new_entry.setAttribute("class", "stream-entry self-sent"); + document.getElementById("main-input").value = ""; } else { new_entry.setAttribute("class", "stream-entry"); } @@ -42,7 +42,8 @@ function displayMessage(data, self_sent) { function installWebsocket() { // TODO: Don't hardcode the websocket path; pull it from the DOM - var ws = new WebSocket("ws://127.0.0.1:8888"); + var address = "ws://".concat(window.location.hostname, ":", window.location.port); + var ws = new WebSocket(address); ws.onmessage = function(evt) { displayMessage(evt.data, false); };