From 973d73ebee77fba60e8ca6baa85c55afbf5ace15 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Tue, 5 Jul 2011 20:16:45 +0200 Subject: ensure all paths are relative --- static/js/pad2.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'static/js/pad2.js') diff --git a/static/js/pad2.js b/static/js/pad2.js index e359b044..24aa182b 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -60,7 +60,16 @@ function randomString() { function handshake() { - socket = io.connect(); + var loc = document.location; + //get the correct port + var port = loc.port == "" ? (loc.protocol == "https:" ? 443 : 80) : loc.port; + //create the url + var url = loc.protocol + "//" + loc.hostname + ":" + port + "/"; + //find out in which subfolder we are + var resource = loc.pathname.substring(0,loc.pathname.indexOf("/p/")) + "/socket.io"; + + //connect + socket = io.connect(url, {resource: resource}); socket.on('connect', function(){ var padId= document.URL.substring(document.URL.lastIndexOf("/")+1); -- cgit v1.2.3