diff rlgterm.js @ 106:dc1414faee19

RLG-Web client: determine the host for WebSocket connections. Construct the URLs for WebSocket connections using window.location.host instead of hardcoding them.
author John "Elwin" Edwards <elwin@sdf.org>
date Sat, 14 Jul 2012 10:11:13 -0700
parents a9371002aecc
children 86a458080e80
line wrap: on
line diff
--- a/rlgterm.js	Sat Jul 14 09:46:26 2012 -0700
+++ b/rlgterm.js	Sat Jul 14 10:11:13 2012 -0700
@@ -75,8 +75,6 @@
   }
 };
 
-var wsHost = "localhost:8080";
-
 var session = {
   /* The session id assigned by the server. */
   id: null,
@@ -523,7 +521,7 @@
   }
   if (statsock)
     return; 
-  statsock = new WebSocket("ws://" + wsHost + "/status");
+  statsock = new WebSocket("ws://" + window.location.host + "/status");
   statsock.onmessage = function (ev) {
     var msg;
     try {
@@ -742,7 +740,7 @@
 }
 
 function wsWatch(gamenumber) {
-  var sockurl = "ws://" + wsHost + "/watch/" + String(gamenumber);
+  var sockurl = "ws://" + window.location.host + "/watch/" + String(gamenumber);
   var ws = new WebSocket(sockurl);
   ws.onopen = function (event) {
     session.id = true;