cropduster
Advanced tools
Comparing version 3.4.0 to 3.4.1
@@ -10,13 +10,25 @@ window.CD = { | ||
param: function(name) { | ||
return CD.params()[name]; | ||
}, | ||
params: function(name) { | ||
if(typeof(CD._urlParams) == "undefined") { | ||
CD._urlParams = {}; | ||
var match, | ||
search = /([^&=]+)=?([^&]*)/g, | ||
query = window.location.search.substring(1); | ||
var match; | ||
var search = /([^&=]+)=?([^&]*)/g; | ||
var query = CD._searchString(); | ||
while (match = search.exec(query)) | ||
CD._urlParams[decodeURIComponent(match[1])] = decodeURIComponent(match[2]); | ||
} | ||
return CD._urlParams[name]; | ||
if (name) { | ||
return CD._urlParams[name]; | ||
} else { | ||
return CD._urlParams; | ||
} | ||
}, | ||
_searchString: function() { | ||
return window.location.search.substring(1); | ||
}, | ||
autofill: function() { | ||
@@ -23,0 +35,0 @@ CD.param("init"); // inits CD._urlParams |
{ | ||
"name": "cropduster", | ||
"version": "3.4.0", | ||
"version": "3.4.1", | ||
"description": "Library for building web pages for use with Movable Ink Web Crops", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -164,2 +164,5 @@ # Cropduster | ||
### 3.4.1 | ||
* Adds `CD.params()`, returning an object with all parameters. | ||
### 3.4.0 | ||
@@ -166,0 +169,0 @@ * Exposes the `content-type` response header within the callback of `CD.get()`. |
@@ -6,2 +6,7 @@ var container = $("<div style='position: absolute; left: -5000px;'></div>").appendTo('body'); | ||
// Stub out search string | ||
CD._searchString = function() { | ||
return 'foo=bar&baz%20test=quux%20value'; | ||
}; | ||
var imageSuccessStub = function() { | ||
@@ -29,2 +34,14 @@ var self = this; | ||
QUnit.test("CD.param when parameter is found", function() { | ||
equal(CD.param('foo'), 'bar', "returns value"); | ||
}); | ||
QUnit.test("CD.params returns all query params", function() { | ||
deepEqual(CD.params(), {'baz test': 'quux value', foo: 'bar'}, "returns the url params"); | ||
}); | ||
QUnit.test("CD.params with argument returns that query param", function() { | ||
equal(CD.params('baz test'), 'quux value', "returns the url param"); | ||
}); | ||
// can't test CD.param returning query params from here, unfortunately... | ||
@@ -37,3 +54,2 @@ | ||
CD._urlParams = {foo: 'bar'}; | ||
CD.autofill(); | ||
@@ -40,0 +56,0 @@ equal(el.html(), 'bar', "auto-fills the query param into the element"); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87826
10
641
246