Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sheetsByTag: function(tag, callback) {
// Returns a list of public sheets matching a given tag.
var sheets = this._sheetsByTag[tag];
if (sheets) {
if (callback) { callback(sheets); }
} else {
var url = "/api/sheets/tag/" + tag;
$.getJSON(url, function(data) {
this._sheetsByTag[tag] = data.sheets;
if (callback) { callback(data.sheets); }
}.bind(this));
}
return sheets;
},
_userSheets: {},
_api: function(url, callback) {
// Manage API calls and callbacks to prevent duplicate calls
if (url in this._apiCallbacks) {
this._apiCallbacks[url].push(callback);
return this._ajaxObjects[url];
} else {
this._apiCallbacks[url] = [callback];
var ajaxobj = $.getJSON(url, function(data) {
var callbacks = this._apiCallbacks[url];
for (var i = 0; i < callbacks.length; i++) {
callbacks[i](data);
}
delete this._apiCallbacks[url];
delete this._ajaxObjects[url];
}.bind(this));
this._ajaxObjects[url] = ajaxobj;
return ajaxobj;
}
}
});