From 84fb4214d7508a2becad6d562d5558974860cb3c Mon Sep 17 00:00:00 2001 From: calzoneman Date: Thu, 25 Apr 2013 23:57:46 -0500 Subject: [PATCH] Fix cross-domain issues --- api.js | 4 ++++ package.json | 2 +- server.js | 2 +- www/channellist.html | 3 ++- www/channelwidget.html | 5 ++--- www/login.html | 5 +++-- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/api.js b/api.js index bd5471dc..8e65c951 100644 --- a/api.js +++ b/api.js @@ -47,6 +47,7 @@ function handle(path, req, res) { } if(parts[0] == "json") { + res.callback = params.callback || false; if(!(parts[1] in jsonHandlers)) { res.end(JSON.stringify({ error: "Unknown endpoint: " + parts[1] @@ -63,6 +64,9 @@ exports.handle = handle; function sendJSON(res, obj) { var response = JSON.stringify(obj, null, 4); + if(res.callback) { + response = res.callback + "(" + response + ")"; + } var len = unescape(encodeURIComponent(response)).length; res.setHeader("Content-Type", "application/json"); diff --git a/package.json b/package.json index 5b1cdcec..5541e419 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "1.3.1", + "version": "1.3.2", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/server.js b/server.js index 56bc857e..0f08ed6e 100644 --- a/server.js +++ b/server.js @@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -const VERSION = "1.3.1"; +const VERSION = "1.3.2"; var fs = require("fs"); var Logger = require("./logger.js"); diff --git a/www/channellist.html b/www/channellist.html index 2c73d673..17ec27ae 100644 --- a/www/channellist.html +++ b/www/channellist.html @@ -43,6 +43,7 @@ + + +