Skip to content

Commit

Permalink
NPM 1.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-wannacott committed May 30, 2023
1 parent 94cf1a8 commit 08c2239
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 277 deletions.
2 changes: 1 addition & 1 deletion browser-extensions/chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"author": "Lee Wannacott",
"name": "table-sort-js",
"version": "1.17.0",
"version": "1.17.1",
"description": "Makes tables sortable using table-sort-js: https://github.com/LeeWannacott/table-sort-js",
"icons": { "48": "icons/t.png" },
"browser_action": {
Expand Down
Binary file modified browser-extensions/chrome/table-sort-js.zip
Binary file not shown.
51 changes: 18 additions & 33 deletions browser-extensions/chrome/table-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ Instructions:

function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
function getHTMLTables() {
if (testingTableSortJS === true) {
const getTagTable = domDocumentWindow.getElementsByTagName("table");
return [getTagTable];
} else {
const getTagTable = document.getElementsByTagName("table");
return [getTagTable];
}
const getTagTable = !testingTableSortJS
? document.getElementsByTagName("table")
: domDocumentWindow.getElementsByTagName("table");
return [getTagTable];
}

const [getTagTable] = getHTMLTables();
Expand All @@ -35,12 +32,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
}

function createMissingTableHead(sortableTable) {
let createTableHead;
if (testingTableSortJS === true) {
createTableHead = domDocumentWindow.createElement("thead");
} else {
createTableHead = document.createElement("thead");
}
let createTableHead = !testingTableSortJS
? document.createElement("thead")
: domDocumentWindow.createElement("thead");
createTableHead.appendChild(sortableTable.rows[0]);
sortableTable.insertBefore(createTableHead, sortableTable.firstChild);
}
Expand All @@ -49,8 +43,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
if (sortableTable.getElementsByTagName("thead").length === 0) {
createMissingTableHead(sortableTable);
if (sortableTable.querySelectorAll("tbody").length > 1) {
// Why index 1?; I don't remember
return sortableTable.querySelectorAll("tbody")[1];
// don't select empty tbody that the browser creates
return sortableTable.querySelectorAll("tbody:not(:nth-child(2))");
} else {
return sortableTable.querySelectorAll("tbody");
}
Expand Down Expand Up @@ -85,8 +79,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
let foundMatch = false;
for (let key of Object.keys(inferableClasses)) {
let classRegexp = inferableClasses[key].regexp;
if (tableColumn.innerText) {
if (tableColumn.innerText.match(classRegexp) !== null) {
if (tableColumn?.innerText !== undefined) {
if (tableColumn.innerText.match(classRegexp)) {
foundMatch = true;
inferableClasses[key].count++;
}
Expand Down Expand Up @@ -114,21 +108,21 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
rows: [],
headers: [],
};
for (let index of table.theads.keys()) {
table.headers.push(table.theads.item(index).querySelectorAll("th"));
}
for (let index of table.bodies.keys()) {
if (table.bodies.item(index) == null) {
return;
}
table.headers.push(table.theads.item(index).querySelectorAll("th"));
table.rows.push(table.bodies.item(index).querySelectorAll("tr"));
}

table.hasClass = {
noClassInfer: sortableTable.classList.contains("no-class-infer"),
cellsSort: sortableTable.classList.contains("cells-sort"),
tableArrows: sortableTable.classList.contains("table-arrows"),
rememberSort: sortableTable.classList.contains("remember-sort"),
};

for (
let headerIndex = 0;
headerIndex < table.theads.length;
Expand Down Expand Up @@ -244,19 +238,10 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
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 = column.getColumn(
tr,
column.spanSum,
column.span
).textContent;
} else {
columnOfTd = column.getColumn(
tr,
column.spanSum,
column.span
).innerText;
}
columnOfTd = column.getColumn(tr, column.spanSum, column.span);
columnOfTd = testingTableSortJS
? columnOfTd.textContent
: columnOfTd.innerText;
let match = columnOfTd.match(regexMinutesAndSeconds);
let [minutesInSeconds, hours, seconds] = [0, 0, 0];
let timeinSeconds = columnOfTd;
Expand Down
2 changes: 1 addition & 1 deletion browser-extensions/firefox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"author": "Lee Wannacott",
"name": "table-sort-js",
"version": "1.17.0",
"version": "1.17.1",
"description": "Makes tables sortable using table-sort-js: https://github.com/LeeWannacott/table-sort-js",
"icons": { "48": "icons/t.png" },
"browser_action": {
Expand Down
Binary file modified browser-extensions/firefox/table-sort-js.zip
Binary file not shown.
51 changes: 18 additions & 33 deletions browser-extensions/firefox/table-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ Instructions:

function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
function getHTMLTables() {
if (testingTableSortJS === true) {
const getTagTable = domDocumentWindow.getElementsByTagName("table");
return [getTagTable];
} else {
const getTagTable = document.getElementsByTagName("table");
return [getTagTable];
}
const getTagTable = !testingTableSortJS
? document.getElementsByTagName("table")
: domDocumentWindow.getElementsByTagName("table");
return [getTagTable];
}

const [getTagTable] = getHTMLTables();
Expand All @@ -35,12 +32,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
}

function createMissingTableHead(sortableTable) {
let createTableHead;
if (testingTableSortJS === true) {
createTableHead = domDocumentWindow.createElement("thead");
} else {
createTableHead = document.createElement("thead");
}
let createTableHead = !testingTableSortJS
? document.createElement("thead")
: domDocumentWindow.createElement("thead");
createTableHead.appendChild(sortableTable.rows[0]);
sortableTable.insertBefore(createTableHead, sortableTable.firstChild);
}
Expand All @@ -49,8 +43,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
if (sortableTable.getElementsByTagName("thead").length === 0) {
createMissingTableHead(sortableTable);
if (sortableTable.querySelectorAll("tbody").length > 1) {
// Why index 1?; I don't remember
return sortableTable.querySelectorAll("tbody")[1];
// don't select empty tbody that the browser creates
return sortableTable.querySelectorAll("tbody:not(:nth-child(2))");
} else {
return sortableTable.querySelectorAll("tbody");
}
Expand Down Expand Up @@ -85,8 +79,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
let foundMatch = false;
for (let key of Object.keys(inferableClasses)) {
let classRegexp = inferableClasses[key].regexp;
if (tableColumn.innerText) {
if (tableColumn.innerText.match(classRegexp) !== null) {
if (tableColumn?.innerText !== undefined) {
if (tableColumn.innerText.match(classRegexp)) {
foundMatch = true;
inferableClasses[key].count++;
}
Expand Down Expand Up @@ -114,21 +108,21 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
rows: [],
headers: [],
};
for (let index of table.theads.keys()) {
table.headers.push(table.theads.item(index).querySelectorAll("th"));
}
for (let index of table.bodies.keys()) {
if (table.bodies.item(index) == null) {
return;
}
table.headers.push(table.theads.item(index).querySelectorAll("th"));
table.rows.push(table.bodies.item(index).querySelectorAll("tr"));
}

table.hasClass = {
noClassInfer: sortableTable.classList.contains("no-class-infer"),
cellsSort: sortableTable.classList.contains("cells-sort"),
tableArrows: sortableTable.classList.contains("table-arrows"),
rememberSort: sortableTable.classList.contains("remember-sort"),
};

for (
let headerIndex = 0;
headerIndex < table.theads.length;
Expand Down Expand Up @@ -244,19 +238,10 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
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 = column.getColumn(
tr,
column.spanSum,
column.span
).textContent;
} else {
columnOfTd = column.getColumn(
tr,
column.spanSum,
column.span
).innerText;
}
columnOfTd = column.getColumn(tr, column.spanSum, column.span);
columnOfTd = testingTableSortJS
? columnOfTd.textContent
: columnOfTd.innerText;
let match = columnOfTd.match(regexMinutesAndSeconds);
let [minutesInSeconds, hours, seconds] = [0, 0, 0];
let timeinSeconds = columnOfTd;
Expand Down
2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "table-sort-js",
"version": "1.17.0",
"version": "1.17.1",
"description": "A JavaScript client-side HTML table sorting library with no dependencies required.",
"license": "MIT",
"repository": "LeeWannacott/table-sort-js",
Expand Down
51 changes: 18 additions & 33 deletions npm/table-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ Instructions:

function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
function getHTMLTables() {
if (testingTableSortJS === true) {
const getTagTable = domDocumentWindow.getElementsByTagName("table");
return [getTagTable];
} else {
const getTagTable = document.getElementsByTagName("table");
return [getTagTable];
}
const getTagTable = !testingTableSortJS
? document.getElementsByTagName("table")
: domDocumentWindow.getElementsByTagName("table");
return [getTagTable];
}

const [getTagTable] = getHTMLTables();
Expand All @@ -35,12 +32,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
}

function createMissingTableHead(sortableTable) {
let createTableHead;
if (testingTableSortJS === true) {
createTableHead = domDocumentWindow.createElement("thead");
} else {
createTableHead = document.createElement("thead");
}
let createTableHead = !testingTableSortJS
? document.createElement("thead")
: domDocumentWindow.createElement("thead");
createTableHead.appendChild(sortableTable.rows[0]);
sortableTable.insertBefore(createTableHead, sortableTable.firstChild);
}
Expand All @@ -49,8 +43,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
if (sortableTable.getElementsByTagName("thead").length === 0) {
createMissingTableHead(sortableTable);
if (sortableTable.querySelectorAll("tbody").length > 1) {
// Why index 1?; I don't remember
return sortableTable.querySelectorAll("tbody")[1];
// don't select empty tbody that the browser creates
return sortableTable.querySelectorAll("tbody:not(:nth-child(2))");
} else {
return sortableTable.querySelectorAll("tbody");
}
Expand Down Expand Up @@ -85,8 +79,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
let foundMatch = false;
for (let key of Object.keys(inferableClasses)) {
let classRegexp = inferableClasses[key].regexp;
if (tableColumn.innerText) {
if (tableColumn.innerText.match(classRegexp) !== null) {
if (tableColumn?.innerText !== undefined) {
if (tableColumn.innerText.match(classRegexp)) {
foundMatch = true;
inferableClasses[key].count++;
}
Expand Down Expand Up @@ -114,21 +108,21 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
rows: [],
headers: [],
};
for (let index of table.theads.keys()) {
table.headers.push(table.theads.item(index).querySelectorAll("th"));
}
for (let index of table.bodies.keys()) {
if (table.bodies.item(index) == null) {
return;
}
table.headers.push(table.theads.item(index).querySelectorAll("th"));
table.rows.push(table.bodies.item(index).querySelectorAll("tr"));
}

table.hasClass = {
noClassInfer: sortableTable.classList.contains("no-class-infer"),
cellsSort: sortableTable.classList.contains("cells-sort"),
tableArrows: sortableTable.classList.contains("table-arrows"),
rememberSort: sortableTable.classList.contains("remember-sort"),
};

for (
let headerIndex = 0;
headerIndex < table.theads.length;
Expand Down Expand Up @@ -244,19 +238,10 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
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 = column.getColumn(
tr,
column.spanSum,
column.span
).textContent;
} else {
columnOfTd = column.getColumn(
tr,
column.spanSum,
column.span
).innerText;
}
columnOfTd = column.getColumn(tr, column.spanSum, column.span);
columnOfTd = testingTableSortJS
? columnOfTd.textContent
: columnOfTd.innerText;
let match = columnOfTd.match(regexMinutesAndSeconds);
let [minutesInSeconds, hours, seconds] = [0, 0, 0];
let timeinSeconds = columnOfTd;
Expand Down
Loading

0 comments on commit 08c2239

Please sign in to comment.