table-sort-js
Advanced tools
Comparing version 1.12.0 to 1.12.1
{ | ||
"name": "table-sort-js", | ||
"version": "1.12.0", | ||
"version": "1.12.1", | ||
"description": "A JavaScript client-side HTML table sorting library with no dependencies required.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -180,26 +180,36 @@ /* | ||
function sortByRuntime(tableRows, columnData) { | ||
for (let [i, tr] of tableRows.entries()) { | ||
const regexMinutesAndSeconds = /^(\d+h)?\s?(\d+m)?\s?(\d+s)?$/i; | ||
let columnOfTd = tr | ||
.querySelectorAll("td") | ||
.item(columnIndex).textContent; | ||
let match = columnOfTd.match(regexMinutesAndSeconds); | ||
let [minutesInSeconds, hours, seconds, timeinSeconds] = [0, 0, 0, 0]; | ||
if (match) { | ||
const regexHours = match[1]; | ||
if (regexHours) { | ||
hours = Number(regexHours.replace("h", "")) * 60 * 60; | ||
try { | ||
for (let [i, tr] of tableRows.entries()) { | ||
const regexMinutesAndSeconds = /^(\d+h)?\s?(\d+m)?\s?(\d+s)?$/i; | ||
let columnOfTd = ""; | ||
// TODO: github actions runtime didn't like textContent, tests didn't like innerText? | ||
if (testingTableSortJS) { | ||
columnOfTd = tr | ||
.querySelectorAll("td") | ||
.item(columnIndex).textContent; | ||
} else { | ||
columnOfTd = tr.querySelectorAll("td").item(columnIndex).innerText; | ||
} | ||
const regexMinutes = match[2]; | ||
if (regexMinutes) { | ||
minutesInSeconds = Number(regexMinutes.replace("m", "")) * 60; | ||
let match = columnOfTd.match(regexMinutesAndSeconds); | ||
let [minutesInSeconds, hours, seconds, timeinSeconds] = [0, 0, 0, 0]; | ||
if (match) { | ||
const regexHours = match[1]; | ||
if (regexHours) { | ||
hours = Number(regexHours.replace("h", "")) * 60 * 60; | ||
} | ||
const regexMinutes = match[2]; | ||
if (regexMinutes) { | ||
minutesInSeconds = Number(regexMinutes.replace("m", "")) * 60; | ||
} | ||
const regexSeconds = match[3]; | ||
if (regexSeconds) { | ||
seconds = Number(regexSeconds.replace("s", "")); | ||
} | ||
timeinSeconds = hours + minutesInSeconds + seconds; | ||
} | ||
const regexSeconds = match[3]; | ||
if (regexSeconds) { | ||
seconds = Number(regexSeconds.replace("s", "")); | ||
} | ||
timeinSeconds = hours + minutesInSeconds + seconds; | ||
columnData.push(`${timeinSeconds}#${i}`); | ||
columnIndexAndTableRow[columnData[i]] = tr.innerHTML; | ||
} | ||
columnData.push(`${timeinSeconds}#${i}`); | ||
columnIndexAndTableRow[columnData[i]] = tr.innerHTML; | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
@@ -206,0 +216,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22062
408