Browse Source

parse new format Google spreadsheet URLs correctly. Closes #597

pull/639/head
Joe Germuska 11 years ago
parent
commit
bed5780380
  1. 2
      source/js/Core/Embed/Embed.CDN.Generator.js
  2. 19
      source/js/VMM.Timeline.DataObj.js

2
source/js/Core/Embed/Embed.CDN.Generator.js

@ -81,7 +81,7 @@ function getLinkAndIframe() {
/* SOURCE KEY /* SOURCE KEY
================================================== */ ================================================== */
if (e_source.value.match("docs.google.com")) { if (e_source.value.match("docs.google.com")) {
source_key = getUrlVars(e_source.value)["key"]; source_key = VMM.Timeline.DataObj.model.googlespreadsheet.extractSpreadsheetKey(e_source.value);
} else { } else {
if (e_source.value == "") { if (e_source.value == "") {
source_key = "0Agl_Dv6iEbDadHdKcHlHcTB5bzhvbF9iTWwyMmJHdkE" source_key = "0Agl_Dv6iEbDadHdKcHlHcTB5bzhvbF9iTWwyMmJHdkE"

19
source/js/VMM.Timeline.DataObj.js

@ -171,11 +171,24 @@ if (typeof VMM.Timeline !== 'undefined' && typeof VMM.Timeline.DataObj == 'undef
model: { model: {
googlespreadsheet: { googlespreadsheet: {
extractSpreadsheetKey: function(url) {
var key = VMM.Util.getUrlVars(url)["key"];
if (!key) {
if (url.match("docs.google.com/spreadsheets/d/")) {
var pos = url.indexOf("docs.google.com/spreadsheets/d/") + "docs.google.com/spreadsheets/d/".length;
var tail = url.substr(pos);
key = tail.split('/')[0]
}
}
if (!key) { key = url}
return key;
},
getData: function(raw) { getData: function(raw) {
var getjsondata, key, worksheet, url, timeout, tries = 0; var getjsondata, key, worksheet, url, timeout, tries = 0;
key = VMM.Util.getUrlVars(raw)["key"]; // new Google Docs URLs can specify 'key' differently.
// that format doesn't seem to have a way to specify a worksheet.
key = VMM.Timeline.DataObj.model.googlespreadsheet.extractSpreadsheetKey(raw);
worksheet = VMM.Util.getUrlVars(raw)["worksheet"]; worksheet = VMM.Util.getUrlVars(raw)["worksheet"];
if (typeof worksheet == "undefined") worksheet = "od6"; if (typeof worksheet == "undefined") worksheet = "od6";
@ -297,7 +310,7 @@ if (typeof VMM.Timeline !== 'undefined' && typeof VMM.Timeline.DataObj == 'undef
getDataCells: function(raw) { getDataCells: function(raw) {
var getjsondata, key, url, timeout, tries = 0; var getjsondata, key, url, timeout, tries = 0;
key = VMM.Util.getUrlVars(raw)["key"]; key = VMM.Timeline.DataObj.model.googlespreadsheet.extractSpreadsheetKey(raw);
url = "https://spreadsheets.google.com/feeds/cells/" + key + "/od6/public/values?alt=json"; url = "https://spreadsheets.google.com/feeds/cells/" + key + "/od6/public/values?alt=json";
timeout = setTimeout(function() { timeout = setTimeout(function() {

Loading…
Cancel
Save