urb.js block scope fix

Will inspect more thoroughly.
This commit is contained in:
Anton Dyudin 2014-08-18 01:41:01 -07:00
parent 4ac0c678d5
commit 3c0161d5b6

View File

@ -4,10 +4,11 @@ window.urb.cabs = {}
window.urb.send = function(params,cb) { window.urb.send = function(params,cb) {
if(!params) if(!params)
throw new Error("You must supply params to urb.send.") throw new Error("You must supply params to urb.send.")
if(!params.appl) if(!params.appl) {
if(!urb.appl) if(!urb.appl)
throw new Error("You must specify an appl for urb.send.") throw new Error("You must specify an appl for urb.send.")
params.appl = urb.appl params.appl = urb.appl
}
if(!params.data) { params.data = {}; } if(!params.data) { params.data = {}; }
var method, perm, url, $this var method, perm, url, $this
@ -35,10 +36,11 @@ window.urb.subscribe = function(params,cb) {
throw new Error("You must supply a callback to urb.subscribe.") throw new Error("You must supply a callback to urb.subscribe.")
if(!params) if(!params)
throw new Error("You must supply params to urb.subscribe.") throw new Error("You must supply params to urb.subscribe.")
if(!params.appl) if(!params.appl) {
if(!urb.appl) if(!urb.appl)
throw new Error("You must specify an appl for urb.subscribe.") throw new Error("You must specify an appl for urb.subscribe.")
params.appl = urb.appl params.appl = urb.appl
}
if(!params.path) if(!params.path)
throw new Error("You must specify a path for urb.subscribe.") throw new Error("You must specify a path for urb.subscribe.")
params.ship = params.ship ? params.ship : this.ship params.ship = params.ship ? params.ship : this.ship
@ -66,10 +68,11 @@ window.urb.subscribe = function(params,cb) {
window.urb.unsubscribe = function(params,cb) { window.urb.unsubscribe = function(params,cb) {
if(!params) if(!params)
throw new Error("You must supply params to urb.unsubscribe.") throw new Error("You must supply params to urb.unsubscribe.")
if(!params.appl) if(!params.appl) {
if(!urb.appl ) if(!urb.appl)
throw new Error("You must specify an appl for urb.unsubscribe.") throw new Error("You must specify an appl for urb.unsubscribe.")
params.appl = urb.appl params.appl = urb.appl
}
if(!params.path) if(!params.path)
throw new Error("You must specify a path for urb.unsubscribe.") throw new Error("You must specify a path for urb.unsubscribe.")
params.ship = params.ship ? params.ship : this.ship params.ship = params.ship ? params.ship : this.ship