diff --git a/README.md b/README.md
index be7e8ce6..fc65ceb0 100755
--- a/README.md
+++ b/README.md
@@ -35,6 +35,8 @@ Possible breaking changes:
* State only stores backend (name) and dataset url (in url field) rather than entire dataset object
* Backends heavily reorganized
+* Rename Document -> Record
+* Rename DataExplorer view to MultiView
### v0.4 - April 26th 2012
diff --git a/app/index.html b/app/index.html
index d38b71b2..39e65a98 100644
--- a/app/index.html
+++ b/app/index.html
@@ -49,7 +49,6 @@
-
diff --git a/app/js/app.js b/app/js/app.js
index 7de2ee58..fb8d375e 100755
--- a/app/js/app.js
+++ b/app/js/app.js
@@ -21,7 +21,7 @@ var ExplorerApp = Backbone.View.extend({
this.router.route(/explorer/, 'explorer', this.viewExplorer);
Backbone.history.start();
- var state = recline.Util.parseQueryString(decodeURIComponent(window.location.search));
+ var state = recline.View.parseQueryString(decodeURIComponent(window.location.search));
if (state) {
_.each(state, function(value, key) {
try {
@@ -145,7 +145,7 @@ var ExplorerApp = Backbone.View.extend({
},
makePermaLink: function(state) {
- var qs = recline.Util.composeQueryString(state.toJSON());
+ var qs = recline.View.composeQueryString(state.toJSON());
return window.location.origin + window.location.pathname + qs;
},
diff --git a/src/util.js b/src/util.js
deleted file mode 100644
index dbba7b0e..00000000
--- a/src/util.js
+++ /dev/null
@@ -1,79 +0,0 @@
-/*jshint multistr:true */
-
-this.recline = this.recline || {};
-this.recline.Util = this.recline.Util || {};
-
-(function(my) {
-// ## Miscellaneous Utilities
-
-var urlPathRegex = /^([^?]+)(\?.*)?/;
-
-// Parse the Hash section of a URL into path and query string
-my.parseHashUrl = function(hashUrl) {
- var parsed = urlPathRegex.exec(hashUrl);
- if (parsed === null) {
- return {};
- } else {
- return {
- path: parsed[1],
- query: parsed[2] || ''
- };
- }
-};
-
-// Parse a URL query string (?xyz=abc...) into a dictionary.
-my.parseQueryString = function(q) {
- if (!q) {
- return {};
- }
- var urlParams = {},
- e, d = function (s) {
- return unescape(s.replace(/\+/g, " "));
- },
- r = /([^&=]+)=?([^&]*)/g;
-
- if (q && q.length && q[0] === '?') {
- q = q.slice(1);
- }
- while (e = r.exec(q)) {
- // TODO: have values be array as query string allow repetition of keys
- urlParams[d(e[1])] = d(e[2]);
- }
- return urlParams;
-};
-
-// Parse the query string out of the URL hash
-my.parseHashQueryString = function() {
- q = my.parseHashUrl(window.location.hash).query;
- return my.parseQueryString(q);
-};
-
-// Compse a Query String
-my.composeQueryString = function(queryParams) {
- var queryString = '?';
- var items = [];
- $.each(queryParams, function(key, value) {
- if (typeof(value) === 'object') {
- value = JSON.stringify(value);
- }
- items.push(key + '=' + encodeURIComponent(value));
- });
- queryString += items.join('&');
- return queryString;
-};
-
-my.getNewHashForQueryString = function(queryParams) {
- var queryPart = my.composeQueryString(queryParams);
- if (window.location.hash) {
- // slice(1) to remove # at start
- return window.location.hash.split('?')[0].slice(1) + queryPart;
- } else {
- return queryPart;
- }
-};
-
-my.setHashQueryString = function(queryParams) {
- window.location.hash = my.getNewHashForQueryString(queryParams);
-};
-})(this.recline.Util);
-
diff --git a/src/view.multiview.js b/src/view.multiview.js
index 7f818a91..56eb8b69 100644
--- a/src/view.multiview.js
+++ b/src/view.multiview.js
@@ -258,7 +258,7 @@ my.MultiView = Backbone.View.extend({
_setupState: function(initialState) {
var self = this;
// get data from the query string / hash url plus some defaults
- var qs = recline.Util.parseHashQueryString();
+ var qs = my.parseHashQueryString();
var query = qs.reclineQuery;
query = query ? JSON.parse(query) : self.model.queryState.toJSON();
// backwards compatability (now named view-graph but was named graph)
@@ -372,5 +372,77 @@ my.MultiView.restore = function(state) {
return explorer;
}
+
+// ## Miscellaneous Utilities
+var urlPathRegex = /^([^?]+)(\?.*)?/;
+
+// Parse the Hash section of a URL into path and query string
+my.parseHashUrl = function(hashUrl) {
+ var parsed = urlPathRegex.exec(hashUrl);
+ if (parsed === null) {
+ return {};
+ } else {
+ return {
+ path: parsed[1],
+ query: parsed[2] || ''
+ };
+ }
+};
+
+// Parse a URL query string (?xyz=abc...) into a dictionary.
+my.parseQueryString = function(q) {
+ if (!q) {
+ return {};
+ }
+ var urlParams = {},
+ e, d = function (s) {
+ return unescape(s.replace(/\+/g, " "));
+ },
+ r = /([^&=]+)=?([^&]*)/g;
+
+ if (q && q.length && q[0] === '?') {
+ q = q.slice(1);
+ }
+ while (e = r.exec(q)) {
+ // TODO: have values be array as query string allow repetition of keys
+ urlParams[d(e[1])] = d(e[2]);
+ }
+ return urlParams;
+};
+
+// Parse the query string out of the URL hash
+my.parseHashQueryString = function() {
+ q = my.parseHashUrl(window.location.hash).query;
+ return my.parseQueryString(q);
+};
+
+// Compse a Query String
+my.composeQueryString = function(queryParams) {
+ var queryString = '?';
+ var items = [];
+ $.each(queryParams, function(key, value) {
+ if (typeof(value) === 'object') {
+ value = JSON.stringify(value);
+ }
+ items.push(key + '=' + encodeURIComponent(value));
+ });
+ queryString += items.join('&');
+ return queryString;
+};
+
+my.getNewHashForQueryString = function(queryParams) {
+ var queryPart = my.composeQueryString(queryParams);
+ if (window.location.hash) {
+ // slice(1) to remove # at start
+ return window.location.hash.split('?')[0].slice(1) + queryPart;
+ } else {
+ return queryPart;
+ }
+};
+
+my.setHashQueryString = function(queryParams) {
+ window.location.hash = my.getNewHashForQueryString(queryParams);
+};
+
})(jQuery, recline.View);
diff --git a/test/index.html b/test/index.html
index b38518d8..cacc7319 100644
--- a/test/index.html
+++ b/test/index.html
@@ -27,7 +27,6 @@
-
diff --git a/test/util.test.js b/test/util.test.js
index c4d7f930..6490d6dd 100644
--- a/test/util.test.js
+++ b/test/util.test.js
@@ -2,7 +2,7 @@
module("Util");
test('parseHashUrl', function () {
- var out = recline.Util.parseHashUrl('graph?x=y');
+ var out = recline.View.parseHashUrl('graph?x=y');
equal(out.path, 'graph');
equal(out.query, '?x=y');
var out = recline.Util.parseHashUrl('graph');
@@ -15,7 +15,7 @@ test('composeQueryString', function () {
x: 'y',
a: 'b'
};
- var out = recline.Util.composeQueryString(params);
+ var out = recline.View.composeQueryString(params);
equal(out, '?x=y&a=b');
});