Last active
December 28, 2015 16:49
-
-
Save nathanathan/7531312 to your computer and use it in GitHub Desktop.
Macro for downloading [spectral workbench](http://spectralworkbench.org/) curves as csvs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setup: function() { | |
$('#myModal').remove(); | |
$('body').append('<div class="modal fade" id="myModal" role="dialog"><div class="modal-content dl-btns"></div></div>'); | |
$.each($W.data, function(idx, data){ | |
var $dlBtn = $('<a class="btn btn-success dl-btn">Download ' + (data.label || "") + ' csv<a>'); | |
$dlBtn.css('margin', 5); | |
$('.dl-btns').append($dlBtn); | |
var csv = $.map(data.data, function(row, idx){ | |
return row.join(','); | |
}).join('\n'); | |
console.log(csv); | |
$dlBtn.attr('href', window.URL.createObjectURL(new Blob([csv]))); | |
$dlBtn.attr('download', (data.label || "data") + ".csv"); | |
}); | |
$('#myModal').modal('show'); | |
}, | |
draw: function() { | |
// code to run every frame | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment