Skip to content

Commit

Permalink
- Refactor for consistent way to load tsv data
Browse files Browse the repository at this point in the history
  * Handled from util.js in timemachine submodule
  • Loading branch information
pdille committed Oct 2, 2019
1 parent e8e53f4 commit c0cf051
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 60 deletions.
20 changes: 1 addition & 19 deletions examples/webgl-timemachine/csvFileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,25 +505,7 @@ CsvFileLayer.prototype.loadLayers = function loadLayers(path) {
$("#csvlayers_table").empty();
that.layers = [];

if (path.endsWith(".tsv")) {
$.ajax({
url: path,
dataType: "text",
success: function(tsvdata) {
that.loadLayersFromTsv(tsvdata);
}
});
} else {
// If necessary, expand docTab share path
if (path.indexOf("http") != 0) {
path = docTabToGoogleSheetUrl(path);
}
// Load csv layers from Google Sheets style URL
org.gigapan.Util.gdocToJSON(path, function(tsvdata) {
that.loadLayersFromTsv(tsvdata);
});
}

org.gigapan.Util.loadTsvData(path, that.loadLayersFromTsv, that);
};

// Takes in UTC time, returns ISO string date format
Expand Down
40 changes: 2 additions & 38 deletions examples/webgl-timemachine/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@
<script type="text/javascript">
"use strict";

console.log('ZZZ index dot map');

jQuery.support.cors = true;
var UTIL = org.gigapan.Util;

Expand Down Expand Up @@ -1947,7 +1945,6 @@
}).prop('checked', showDscovrTimeMachineLayer);

$("#show-annual-pm25").on("click", function() {
console.log('TODO(RS): show-annual-pm25');
var $this = $(this);
if ($this.prop('checked')) {
annualGlobalPm25TimeMachineLayer.getTileView().handleTileLoading({layerDomId: $this[0].id});
Expand Down Expand Up @@ -4875,7 +4872,6 @@
tileUrl += '.tbox';
}
}
console.log('ZZZ index dot map tiles url', tileUrl);

var layerOptions = {
// In reality the tiles are served as 512x512, but by claiming 256x256 we load an
Expand Down Expand Up @@ -5069,24 +5065,7 @@
$(".dotmap").remove();
$('#custom_dotmaps_table').empty();

if (path.endsWith(".tsv")) {
$.ajax({
url: path,
dataType: "text",
success: function(csvdata) {
loadDotmapLayersFromTsv(csvdata);
}
});
} else {
// If necessary, expand docTab shared path
if (path.indexOf("http") != 0) {
path = docTabToGoogleSheetUrl(path);
}
// Load dotmaps from Google Sheets style URL
UTIL.gdocToJSON(path, function(tsvdata) {
loadDotmapLayersFromTsv(tsvdata);
});
}
UTIL.loadTsvData(path, loadDotmapLayersFromTsv, this);
}

function modifyWaypointSliderContent(keyframes, theme, story) {
Expand Down Expand Up @@ -5253,23 +5232,8 @@
if (waypointCollection) {
timelapse.loadSharedDataFromUnsafeURL(waypointCollection);
storiesInitialized = true;
} else if (path.endsWith(".tsv")) {
$.ajax({
url: path,
dataType: "text",
success: function(csvdata) {
loadWaypointSliderContentFromCSV(csvdata);
}
});
} else {
// If necessary, expand docTab shared path
if (path.indexOf("http") != 0) {
path = docTabToGoogleSheetUrl(path);
}
// Load waypoints from Google Sheets style URL
UTIL.gdocToJSON(path, function(csvdata) {
loadWaypointSliderContentFromCSV(csvdata);
});
UTIL.loadTsvData(path, loadWaypointSliderContentFromCSV, this);
}
}

Expand Down
7 changes: 5 additions & 2 deletions examples/webgl-timemachine/landing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,9 @@ <h4>{{story-authors}}</h4>
var themeTemplate = Handlebars.compile(themeTemplateSource);
Handlebars.registerPartial("story", storyPartialTemplateSource);
var html = "";
var path = EARTH_TIMELAPSE_CONFIG.waypointSliderContentPath;

UTIL.gdocToJSON(EARTH_TIMELAPSE_CONFIG.waypointSliderContentPath, function(tsvdata) {
var storiesLoadedHandler = function(tsvdata) {
var parsed = Papa.parse(tsvdata, {delimiter: '\t', header: true});
var waypointdefs = parsed['data'];
var storyCollection = [];
Expand Down Expand Up @@ -442,7 +443,9 @@ <h4>{{story-authors}}</h4>
html += themeTemplate({'theme': themeTitle, 'stories': stories});
}
$("#stories-list").html(html);
});
};

UTIL.loadTsvData(path, storiesLoadedHandler, this);

$("#stories").on("click", ".story", function() {
var storyName = $(this).attr("data-story-name");
Expand Down
2 changes: 1 addition & 1 deletion timemachine

0 comments on commit c0cf051

Please sign in to comment.