Connect to the right url no matter where we connect from
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 21 Jan 2017 22:38:38 +0000 (16:38 -0600)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 21 Jan 2017 22:38:38 +0000 (16:38 -0600)
data/web-static/js/mudsync.js

index 90f3daa4ef9af9d995cf1c0649a6c19ab1ff0c71..b926c146b8b8c84eda2af175aefe2398fc6a6c35 100644 (file)
@@ -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);
     };