Permalink
Browse files

Fixed the javascript getting of the port

  • Loading branch information...
1 parent 933109f commit 0b7e59b31dbe980a53dd57a9aa59648a98117904 @nisbus committed Nov 2, 2012
Showing with 13 additions and 1 deletion.
  1. +13 −1 priv/index.html
View
@@ -86,8 +86,20 @@
console.log("connecting");
connect();
});
+ function getPort(){
+ if(location.port != ''){
+ return location.port;
+ }
+ else if(location.protocol== 'http'){
+ return 80;
+ }
+ else if(location.protocol== 'https'){
+ return 443;
+ }
+ }
function connect(){
- window.socket = new WebSocket("ws://localhost:8080/ws");
+ var port = getPort();
+ window.socket = new WebSocket("ws://localhost:"+port+"/ws");
window.socket.onopen = function(){
console.log("open");
message('<p>'+ready_state_to_string(socket.readyState));

0 comments on commit 0b7e59b

Please sign in to comment.