Skip to content

Commit

Permalink
Make handle some emojis.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-wannacott committed Nov 7, 2024
1 parent b24dec1 commit 0f43bbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<script type="text/javascript" src="./table-sort.js"></script>

<h1>Manual testing of table sort js</h1>
<table class="table-sort table-arrows-⇈⇆⇊">
<!-- 👏🏽 -->
<table class="table-sort table-arrows-🦄🚀🚀">
<tr>
<td>Last Name</td>
<td>First Name</td>
Expand Down
15 changes: 7 additions & 8 deletions public/table-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
noClassInfer: sortableTable.classList.contains("no-class-infer"),
cellsSort: sortableTable.classList.contains("cells-sort"),
rememberSort: sortableTable.classList.contains("remember-sort"),
// tableArrows: sortableTable.classList.contains("table-arrows"),
tableArrows: Array.from(sortableTable.classList).filter((item) =>
item.includes("table-arrows")
),
Expand Down Expand Up @@ -520,14 +519,14 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
let arrow = { up: " ↑", neutral: " ↕", down: " ↓" };
if (table.hasClass.tableArrows[0]) {
if (table.hasClass.tableArrows[0].split("-").length > 2) {
var customArrow = table.hasClass.tableArrows[0].split("-")[2];
// Array.from to support utf-8 strings e.g emojis
var customArrow = Array.from(
table.hasClass.tableArrows[0].split("-")[2]
);
customArrow = customArrow.map((i) => " " + i);
console.log(customArrow);
if (customArrow.length === 3) {
console.log(table.hasClass.tableArrows[0].split("-"));
[arrow.up, arrow.neutral, arrow.down] = [
" " + customArrow[0],
" " + customArrow[1],
" " + customArrow[2],
];
[arrow.up, arrow.neutral, arrow.down] = [...customArrow];
}
}
th.insertAdjacentText("beforeend", arrow.neutral);
Expand Down

0 comments on commit 0f43bbf

Please sign in to comment.