summaryrefslogtreecommitdiff
path: root/static/js/pad2.js
diff options
context:
space:
mode:
authorPeter 'Pita' Martischka <petermartischka@googlemail.com>2011-07-05 20:16:45 +0200
committerPeter 'Pita' Martischka <petermartischka@googlemail.com>2011-07-05 20:16:45 +0200
commit973d73ebee77fba60e8ca6baa85c55afbf5ace15 (patch)
tree42a11b5eb8df4829e80583320ba76e4a98a49327 /static/js/pad2.js
parentee2c8f4524329dd766a1fb19c72eb145cb0e921d (diff)
downloadetherpad-lite-973d73ebee77fba60e8ca6baa85c55afbf5ace15.zip
ensure all paths are relative
Diffstat (limited to 'static/js/pad2.js')
-rw-r--r--static/js/pad2.js11
1 files changed, 10 insertions, 1 deletions
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);