build/src/transistor.js in transistor-0.1.1 vs build/src/transistor.js in transistor-0.1.2

- old
+ new

@@ -12,11 +12,11 @@ * * JSONP.get( 'someUrl.php', {param1:'123', param2:'456'}, function(data){ * //do something with data, which is the JSON object you should retrieve from someUrl.php * }); */ -var JSONP = (function(){ +var JSONP = function(){ var counter = 0, head, window = this, config = {}; function load(url, pfnError) { var script, done, errorHandler; script = document.createElement('script'); @@ -80,11 +80,11 @@ } return { get:jsonp, init:setDefaults }; -}()); +}; /*global JSONP, Faye */ if (window.Transistor === undefined) { window.Transistor = {}; } @@ -92,19 +92,21 @@ (function (transistor) { var Radio = (function () { return function (station_finder, station_uid, token, cache) { - var init_url, bayeux, listeners, turnOn, error, tune, build_channel_path; + var jsonp, init_url, bayeux, listeners, turnOn, error, tune, build_channel_path; + jsonp = JSONP(); + init_url = station_finder + '/init/' + station_uid + '/' + token; listeners = []; turnOn = function () { var initial_value; - JSONP.get(init_url, {}, function (init) { + jsonp.get(init_url, {}, function (init) { if (init.error !== undefined) { error(init); } bayeux = new Faye.Client(init.aerial_url, { retry: 3 }); @@ -270,12 +272,14 @@ (function (transistor) { var Control = (function () { return function (broadcaster, station_uid, token) { - var set, insert, update, remove, command_url, send; + var jsonp, set, insert, update, remove, command_url, send; + jsonp = JSONP(); + set = function (channel, collection, cb) { send(command_url('set', channel), {collection: collection}, cb); }; insert = function (channel, entry, cb) { @@ -304,12 +308,12 @@ if (cb === undefined) { cb = function (result) {}; } if (data === undefined) { - JSONP.get(command_url, {}, cb); + jsonp.get(command_url, {}, cb); } else { - JSONP.get(command_url, {data: JSON.stringify(data)}, cb); + jsonp.get(command_url, {data: JSON.stringify(data)}, cb); } }; return { set: set,