Permalink
Browse files

Fix to handle multiple google spreadsheet requests

  • Loading branch information...
1 parent 0b498b1 commit 616d60a04192ee1f9baed6d167095a0e5c64b223 @mikeymckay committed Mar 3, 2011
Showing with 8 additions and 7 deletions.
  1. +1 −1 google-spreadsheet.coffee
  2. +7 −6 google-spreadsheet.js
View
2 google-spreadsheet.coffee
@@ -45,7 +45,7 @@ class GoogleSpreadsheet
@googleUrl = googleUrl
save: ->
- localStorage["GoogleSpreadsheet."+@type] = JSON.stringify(this)
+ localStorage["GoogleSpreadsheet."+@key] = JSON.stringify(this)
GoogleSpreadsheet.bless = (object) ->
result = new GoogleSpreadsheet()
View
13 google-spreadsheet.js
@@ -1,7 +1,7 @@
/*
Updated versions can be found at https://github.com/mikeymckay/google-spreadsheet-javascript
*/var GoogleSpreadsheet, GoogleUrl;
-GoogleUrl = function() {
+GoogleUrl = (function() {
function GoogleUrl(sourceIdentifier) {
this.sourceIdentifier = sourceIdentifier;
if (this.sourceIdentifier.match(/http(s)*:/)) {
@@ -19,8 +19,8 @@ GoogleUrl = function() {
this.jsonUrl = this.jsonCellsUrl;
}
return GoogleUrl;
-}();
-GoogleSpreadsheet = function() {
+})();
+GoogleSpreadsheet = (function() {
function GoogleSpreadsheet() {}
GoogleSpreadsheet.prototype.load = function(callback) {
var intervalId, jsonUrl, safetyCounter, url, waitUntilLoaded;
@@ -59,7 +59,7 @@ GoogleSpreadsheet = function() {
return localStorage["GoogleSpreadsheet." + this.type] = JSON.stringify(this);
};
return GoogleSpreadsheet;
-}();
+})();
GoogleSpreadsheet.bless = function(object) {
var key, result, value;
result = new GoogleSpreadsheet();
@@ -100,7 +100,7 @@ GoogleSpreadsheet.find = function(params) {
return null;
};
GoogleSpreadsheet.callbackCells = function(data) {
- var cell, googleSpreadsheet, googleUrl, _i, _len, _ref, _results;
+ var cell, googleSpreadsheet, googleUrl;
googleUrl = new GoogleUrl(data.feed.id.$t);
googleSpreadsheet = GoogleSpreadsheet.find({
jsonUrl: googleUrl.jsonUrl
@@ -110,14 +110,15 @@ GoogleSpreadsheet.callbackCells = function(data) {
googleSpreadsheet.googleUrl(googleUrl);
}
googleSpreadsheet.data = (function() {
+ var _i, _len, _ref, _results;
_ref = data.feed.entry;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
cell = _ref[_i];
_results.push(cell.content.$t);
}
return _results;
- }());
+ })();
googleSpreadsheet.save();
return googleSpreadsheet;
};

0 comments on commit 616d60a

Please sign in to comment.