From 78380482230698c9dc1b20675af928ad864a0da7 Mon Sep 17 00:00:00 2001 From: mveril Date: Tue, 8 Dec 2020 13:42:47 +0100 Subject: [PATCH] Better csv (#11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix broken link * Fix bug in indexDB * Fix sourceFile for each geometry * Fix line break in methods for the csv * Repeat the cell instead of putting a blank cell when the row/column span of the cell is larger than one Co-authored-by: Mickaël Véril --- content/dataset.html | 8 ++++++-- static/js/tableToCSV.js | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/content/dataset.html b/content/dataset.html index e20b5271..f4f31ab0 100644 --- a/content/dataset.html +++ b/content/dataset.html @@ -403,7 +403,8 @@ draft: false Reflect.setPrototypeOf(key, method.prototype) th = $("", { scope: "column" }) const meth = key - th.clone().text(meth.toString("\n").split('-').join('\u2011')).appendTo(row) + const span = $("",{"data-csvtext":meth.toString()}).text(meth.toString("\n").split('-').join('\u2011')) + th.clone().append(span).appendTo(row) const noNanVals = (vals.every((v) => Number.isNaN(v))) ? vals : (vals.filter((v) => !Number.isNaN(v))) const avals = noNanVals.map(v => Math.abs(v)) th.clone().text(noNanVals.length).appendTo(row) @@ -588,7 +589,10 @@ draft: false var tbody = $("").appendTo(table) var th = $("", { scope: "column" }) head.append(["Molecule", "Transition"].map(x => th.clone().text(x))) - head.append(sortedMethods.map(x => th.clone().text(x.toString("\n").split('-').join('\u2011')))) + head.append(sortedMethods.map(x => { + const span = $("",{"data-csvtext":x.toString()}).text(x.toString("\n").split('-').join('\u2011')) + return th.clone().append(span) + })) adjustSticky(); datadic = new Map() for (const dat of paperdata) { diff --git a/static/js/tableToCSV.js b/static/js/tableToCSV.js index 1824d452..566420a5 100644 --- a/static/js/tableToCSV.js +++ b/static/js/tableToCSV.js @@ -40,13 +40,13 @@ function tableToCSV(table) { const rowIndex = cell.parentNode.rowIndex if (columnspan>1) { for (let i = 1; i < rowspan; i++) { - csv[rowIndex].splice(colindex,0,"") + csv[rowIndex].splice(colindex,0,csv[rowIndex][colindex]) } } if (rowspan>1) { for (let i = 0; i < columnspan; i++) { for (let j = 1; j < rowspan; j++) { - csv[rowIndex+j].splice(colindex,0,"") + csv[rowIndex+j].splice(colindex,0,csv[rowIndex][colindex]) } } }