From 0e941b498e295557d4aa390359672001682e648a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Sun, 29 Apr 2012 19:54:38 +0200 Subject: [PATCH] fix #677 --- src/static/js/admin/plugins.js | 13 ++++++++++++- src/static/js/pad.js | 3 +-- src/templates/pad.html | 6 +++++- src/templates/timeslider.html | 7 ++++++- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/static/js/admin/plugins.js b/src/static/js/admin/plugins.js index 6ae085c2a..f16cb8b49 100644 --- a/src/static/js/admin/plugins.js +++ b/src/static/js/admin/plugins.js @@ -1,5 +1,16 @@ $(document).ready(function () { - var socket = io.connect().of("/pluginfw/installer"); + + var socket, + loc = document.location, + port = loc.port == "" ? (loc.protocol == "https:" ? 443 : 80) : loc.port, + url = loc.protocol + "//" + loc.hostname + ":" + port + "/", + pathComponents = location.pathname.split('/'), + // Strip admin/plugins/ + baseURL = pathComponents.slice(0,pathComponents.length-3).join('/') + '/', + resource = baseURL.substring(1) + "socket.io"; + + //connect + socket = io.connect(url, {resource : resource}).of("/pluginfw/installer"); $('.search-results').data('query', { pattern: '', diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 9db1c5b93..d40af6e7d 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -203,8 +203,7 @@ function handshake() //create the url var url = loc.protocol + "//" + loc.hostname + ":" + port + "/"; //find out in which subfolder we are - var resource = exports.baseURL + "socket.io"; - + var resource = exports.baseURL.substring(1) + "socket.io"; //connect socket = pad.socket = io.connect(url, { resource: resource, diff --git a/src/templates/pad.html b/src/templates/pad.html index 3eced909f..b434099f7 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -280,8 +280,12 @@ var clientVars = {}; (function () { - var baseURL = '../'; + var pathComponents = location.pathname.split('/'); + + // Strip 'p' and the padname from the pathname and set as baseURL + var baseURL = pathComponents.slice(0,pathComponents.length-2).join('/') + '/'; + require.setRootURI(baseURL + "javascripts/src"); require.setLibraryURI(baseURL + "javascripts/lib"); require.setGlobalKeyPath("require"); diff --git a/src/templates/timeslider.html b/src/templates/timeslider.html index 5db11b8f2..8331062f5 100644 --- a/src/templates/timeslider.html +++ b/src/templates/timeslider.html @@ -134,7 +134,12 @@ var clientVars = {}; (function () { - var baseURL = '../../'; + + var pathComponents = location.pathname.split('/'); + + // Strip 'p', the padname and 'timeslider' from the pathname and set as baseURL + var baseURL = pathComponents.slice(0,pathComponents.length-3).join('/') + '/'; + require.setRootURI(baseURL + "javascripts/src"); require.setLibraryURI(baseURL + "javascripts/lib");