diff --git a/index.html b/index.html index 6820c37..3b2ab4e 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -

Manual testing of table sort js

Last NameFirst NameBirth DateEmployee IDDepartmentRuntimeFile Sizedata-sort daysdates in dd/mm/yyyyfile version
FranklinBenjamin1706-1-171k-level1h 1m 17s10bTuesday17/6/19781.18.1
da VinciZarlo1452-4-15130001m 45s192038998987021bWednesday18/10/2027239.123.23
StathamJason1967-7-26HR11m 40s134809bFriday4/9/20083423.342.34
MichealAngelo1958-8-2154Marketing29s30980980bThursday2/3/1879890.93.908
Ben1994/9/23134Marketing41s902938402398bMonday8/6/19782/3/1879

Testing table containing colspan and data-sort and multiple tbodies

CategoryShowOverallOn Our DatesOn Our DatesFirst Sold Out
ComedyShow 118/2572%3/475%21999-7-30
MusicShow 26/1060%3/4875%1999-8-04
TheatreShow 37/1547%3/475%2.121999-7-19
Comedy410/1567%2/367%2.131999-7-19
Comedy59/1275%1/250%2.831999-7-29
Comedy616/2467%2/450%2.831999-7-26
Comedy716/2662%2/450%2.032022-7-31
Last NameFirst NameBirth DateEmployee IDDepartmentRuntimeFile Sizedata-sort daysdates in dd/mm/yyyy
FranklinBenjamin1706-1-171,000.00k-level1h 1m 17s10bTuesday17/6/1978
da VinciZarlo1452-4-15-9,000.211m 45s192038998987021bWednesday18/10/2027
StathamJason1967-7-2655,990.23HR11m 40s134809bFriday4/9/2008
MichealAngelo1958-8-211,000,000.23Marketing29s30980980bThursday2/3/1879
Ben1994/9/2390102Marketing41s902938402398bMonday8/6/1978
Last NameFirst NameBirth DateEmployee IDDepartmentRuntimeFile Sizedata-sort daysdates in dd/mm/yyyy
FranklinBenjamin1706-1-171k-level1h 1m 17s10bTuesday17/6/1978
da VinciZarlo1452-4-15130001m 45s192038998987021bWednesday18/10/2027
StathamJason1967-7-26HR11m 40s134809bFriday4/9/2008
MichealAngelo1958-8-2154Marketing29s30980980bThursday2/3/1879
Ben1994/9/23134Marketing41s902938402398bMonday8/6/1978
\ No newline at end of file +

Manual testing of table sort js

Last NameFirst NameBirth DateEmployee IDDepartmentRuntimeFile Sizedata-sort daysdates in dd/mm/yyyyfile version
FranklinBenjamin1706-1-171k-level1h 1m 17s10bTuesday17/6/19781.18.1
da VinciZarlo1452-4-15130001m 45s192038998987021bWednesday18/10/2027239.123.23
StathamJason1967-7-26HR11m 40s134809bFriday4/9/20083423.342.34
MichealAngelo1958-8-2154Marketing29s30980980bThursday2/3/1879890.93.908
Ben1994/9/23134Marketing41s902938402398bMonday8/6/19782/3/1879

Testing table containing colspan and data-sort and multiple tbodies

CategoryShowOverallOn Our DatesOn Our DatesFirst Sold Out
ComedyShow 118/2572%3/475%21999-7-30
MusicShow 26/1060%3/4875%1999-8-04
TheatreShow 37/1547%3/475%2.121999-7-19
Comedy410/1567%2/367%2.131999-7-19
Comedy59/1275%1/250%2.831999-7-29
Comedy616/2467%2/450%2.831999-7-26
Comedy716/2662%2/450%2.032022-7-31
Last NameFirst NameBirth DateEmployee IDDepartmentRuntimeFile Sizedata-sort daysdates in dd/mm/yyyy
FranklinBenjamin1706-1-171,000.00k-level1h 1m 17s10bTuesday17/6/1978
da VinciZarlo1452-4-15-9,000.211m 45s192038998987021bWednesday18/10/2027
StathamJason1967-7-2655,990.23HR11m 40s134809bFriday4/9/2008
MichealAngelo1958-8-211,000,000.23Marketing29s30980980bThursday2/3/1879
Ben1994/9/2390102Marketing41s902938402398bMonday8/6/1978
Last NameFirst NameBirth DateEmployee IDDepartmentRuntimeFile Sizedata-sort daysdates in dd/mm/yyyy
FranklinBenjamin1706-1-171k-level1h 1m 17s10bTuesday17/6/1978
da VinciZarlo1452-4-15130001m 45s192038998987021bWednesday18/10/2027
StathamJason1967-7-26HR11m 40s134809bFriday4/9/2008
MichealAngelo1958-8-2154Marketing29s30980980bThursday2/3/1879
Ben1994/9/23134Marketing41s902938402398bMonday8/6/1978
\ No newline at end of file diff --git a/table-sort.js b/table-sort.js index 54aca82..300da8b 100644 --- a/table-sort.js +++ b/table-sort.js @@ -82,7 +82,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { break; } const tableColumn = tr - .querySelectorAll("td") + .querySelectorAll("* > th , * > td") .item( column.span[columnIndex] === 1 ? column.spanSum[columnIndex] - 1 @@ -125,11 +125,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { headers: [], }; for (let index of table.theads.keys()) { - if (table.theads.item(index).querySelectorAll("th").length == 0) { - table.headers.push(table.theads.item(index).querySelectorAll("td")); - } else { - table.headers.push(table.theads.item(index).querySelectorAll("th")); - } + table.headers.push( + table.theads.item(index).querySelectorAll("* > th , * > td") + ); } for (let index of table.bodies.keys()) { if (table.bodies.item(index) == null) { @@ -200,7 +198,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { }; const numberWithUnitType = /([.0-9]+)\s?(B|KB|KiB|MB|MiB|GB|GiB|TB|TiB)/i; for (let [i, tr] of table.visibleRows.entries()) { - let fileSizeTd = tr.querySelectorAll("td").item(columnIndex).textContent; + let fileSizeTd = tr + .querySelectorAll("* > th , * > td") + .item(columnIndex).textContent; let match = fileSizeTd.match(numberWithUnitType); if (match) { let number = parseFloat(match[1]); @@ -465,7 +465,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { "NaN" ); } - tr.querySelectorAll("td").item(columnIndex).innerHTML = fileSizeInBytesHTML; + tr.querySelectorAll("* > th , * > td").item(columnIndex).innerHTML = + fileSizeInBytesHTML; return table.hasClass.cellsSort ? tr.innerHTML : tr.outerHTML; } @@ -532,7 +533,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { const column = { getColumn: function getColumn(tr, colSpanSum, colSpanData) { return tr - .querySelectorAll("td") + .querySelectorAll("* > th , * > td") .item( colSpanData[columnIndex] === 1 ? colSpanSum[columnIndex] - 1