Don't hardcode port for websocket url

This commit is contained in:
Stephen McQuay 2015-08-26 19:58:59 -07:00
parent 6859c9418d
commit b633898ef4

View File

@ -28,7 +28,11 @@ $(function(){
function setupWS() { function setupWS() {
a = document.createElement("a"); a = document.createElement("a");
a.href = document.URL; a.href = document.URL;
url = "ws://" + a.hostname + ":8000/ws/"; url = "ws://" + a.hostname;
if (a.port) {
url = url + ":" + a.port;
}
url = url + "/ws/";
websocket = new WebSocket(url); websocket = new WebSocket(url);
websocket.onopen = function(evt) { onOpen(evt) }; websocket.onopen = function(evt) { onOpen(evt) };
websocket.onclose = function(evt) { onClose(evt) }; websocket.onclose = function(evt) { onClose(evt) };