Commit f88a9c9a authored by flothoni's avatar flothoni Committed by Mathieu Giraud

clone.js, add button to download htmlinfo table as csv

Link to #3243
parent 55be5ac6
Pipeline #101832 failed with stages
in 50 seconds
......@@ -1296,7 +1296,8 @@ Clone.prototype = {
html += "<p>select <a class='button' onclick='m.selectCorrelated(" + this.index + ", 0.90); m.closeInfoBox();'>correlated</a> clones</p>"
html += "<p>select <a class='button' onclick='m.selectCorrelated(" + this.index + ", 0.99); m.closeInfoBox();'>strongly correlated</a> clones</p>"
html += "<p>Download table as <a class='button' id='download_info_"+ this.index +"'onclick='export_table_to_csv(" + this.index + ")'>CSV</a></p>"
//column
html += "<div id='info_window'><table id='clone_download_info_"+this.index+"'><tr><th>Files names</th>"
......
......@@ -763,3 +763,49 @@ function getNFirstSequences(data, n) {
}
function export_table_to_csv(cloneId) {
var csv = [];
var table = document.getElementById("clone_download_info_"+ cloneId)
var rows = table.querySelectorAll("table tr");
for (var i = 0; i < rows.length; i++) {
var row = [], cols = rows[i].querySelectorAll("td, th");
for (var j = 0; j < cols.length; j++)
row.push(cols[j].innerText);
csv.push(row.join(","));
}
// Download CSV
var filename = "information_clone_"+cloneId
download_csv(csv.join("\n"), filename);
}
function download_csv(csv, filename) {
var csvFile;
var downloadLink;
// CSV FILE
csvFile = new Blob([csv], {type: "text/csv"});
// Download link
downloadLink = document.createElement("a");
// File name
downloadLink.download = filename;
// We have to create a link to the file
downloadLink.href = window.URL.createObjectURL(csvFile);
// Make sure that the link is not displayed
downloadLink.style.display = "none";
// Add the link to your DOM
document.body.appendChild(downloadLink);
// Lanzamos
downloadLink.click();
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment