Browse Source

Changed timeout function for loading Google Docs so that it tries several times to get json ref #219

pull/246/head
Zach Wise 13 years ago
parent
commit
0bf00ea34c
  1. 30
      source/js/VMM.Timeline.DataObj.js

30
source/js/VMM.Timeline.DataObj.js

@ -166,24 +166,34 @@ if (typeof VMM.Timeline !== 'undefined' && typeof VMM.Timeline.DataObj == 'undef
googlespreadsheet: { googlespreadsheet: {
getData: function(raw) { getData: function(raw) {
var key, url, timeout; var getjsondata, key, url, timeout, tries = 0;
key = VMM.Util.getUrlVars(raw)["key"]; key = VMM.Util.getUrlVars(raw)["key"];
url = "https://spreadsheets.google.com/feeds/list/" + key + "/od6/public/values?alt=json"; url = "https://spreadsheets.google.com/feeds/list/" + key + "/od6/public/values?alt=json";
timeout = setTimeout(function() { timeout = setTimeout(function() {
trace("Google Docs timeout"); trace("Google Docs timeout");
VMM.fireEvent(global, VMM.Timeline.Config.events.messege, "Google Docs is not responding"); if (tries < 3) {
VMM.fireEvent(global, VMM.Timeline.Config.events.messege, "Still waiting on Google Docs, trying again " + tries);
tries ++;
requestJsonData();
} else {
VMM.fireEvent(global, VMM.Timeline.Config.events.messege, "Google Docs is not responding");
}
}, 6000); }, 6000);
VMM.getJSON(url, VMM.Timeline.DataObj.model.googlespreadsheet.buildData) function requestJsonData() {
.error(function(jqXHR, textStatus, errorThrown) { getjsondata = VMM.getJSON(url, VMM.Timeline.DataObj.model.googlespreadsheet.buildData)
trace("Google Docs ERROR"); .error(function(jqXHR, textStatus, errorThrown) {
trace("Google Docs ERROR: " + textStatus + " " + jqXHR.responseText); trace("Google Docs ERROR");
}) trace("Google Docs ERROR: " + textStatus + " " + jqXHR.responseText);
.success(function(d) { })
clearTimeout(timeout); .success(function(d) {
}); clearTimeout(timeout);
});
}
requestJsonData();
}, },
buildData: function(d) { buildData: function(d) {

Loading…
Cancel
Save