From: <tob...@us...> - 2014-03-01 01:38:19
|
Revision: 7904 http://sourceforge.net/p/bigdata/code/7904 Author: tobycraig Date: 2014-03-01 01:38:15 +0000 (Sat, 01 Mar 2014) Log Message: ----------- #829 - Export query results to CSV Modified Paths: -------------- branches/RDR/bigdata-war/src/html/workbench.js Modified: branches/RDR/bigdata-war/src/html/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/workbench.js 2014-03-01 00:12:57 UTC (rev 7903) +++ branches/RDR/bigdata-war/src/html/workbench.js 2014-03-01 01:38:15 UTC (rev 7904) @@ -371,6 +371,23 @@ $('#query-explanation').hide(); }); +$('#query-export').click(function() { + // FIXME: escape commas + var csv = ''; + $('#query-response table tr').each(function(i, tr) { + $(tr).find('td').each(function(j, td) { + if(j > 0) { + csv += ','; + } + csv += td.textContent; + }); + csv += '\n'; + }); + var uri = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv); + $('<a id="download-link" download="export.csv" href="' + uri + '">').appendTo('body')[0].click(); + $('#download-link').remove(); +}); + function showQueryResults(data) { $('#query-response').empty(); var table = $('<table>').appendTo($('#query-response')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |