From 91b514abb547b1543ef8033804e25404ec878f84 Mon Sep 17 00:00:00 2001 From: LeeWannacott Date: Sat, 30 Mar 2024 22:20:40 +1300 Subject: [PATCH] Version 1.21.0 - currency signs and percentages. --- browser-extensions/chrome/manifest.json | 2 +- browser-extensions/chrome/table-sort-js.zip | Bin 8117 -> 8219 bytes browser-extensions/chrome/table-sort.js | 29 ++++++++++--------- browser-extensions/firefox/manifest.json | 2 +- browser-extensions/firefox/table-sort-js.zip | Bin 8117 -> 8219 bytes browser-extensions/firefox/table-sort.js | 29 ++++++++++--------- npm/README.md | 9 +++--- npm/package.json | 2 +- npm/table-sort.js | 29 ++++++++++--------- 9 files changed, 56 insertions(+), 46 deletions(-) diff --git a/browser-extensions/chrome/manifest.json b/browser-extensions/chrome/manifest.json index 2f0fd4f..af4aa6e 100644 --- a/browser-extensions/chrome/manifest.json +++ b/browser-extensions/chrome/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "author": "Lee Wannacott", "name": "table-sort-js", - "version": "1.20.0", + "version": "1.21.0", "description": "Makes tables sortable using table-sort-js: https://github.com/LeeWannacott/table-sort-js", "icons": { "48": "icons/t.png" }, "browser_action": { diff --git a/browser-extensions/chrome/table-sort-js.zip b/browser-extensions/chrome/table-sort-js.zip index cab2ee6aef3fdb9085e01116ef9948bc74b15b65..5ddb2452b213f0f40a9f3cab927471e7c76fcda8 100644 GIT binary patch delta 5642 zcmV+l7WL`1Kbt_Xvj_-MvVK^=4u+_cy9geC>(~comL&9Lb$AN^0R-p+000E&0{{SR zP(4q>Fc97ID=g2cLxBNBs0%AhATgjQx;Sp);@FYz0z=gQjz0>tQWwj9ANSsQEg0hy zSiM(B?U(YXo#i#VDGg`k%wM;&v;4 zZZg~}lwQwtqF&%rAxm~-(I0PYL2UQXEDUA zjNd=RxCB%rW;<|pOq$NSZ&bbodFr$VG!@;$VyKOlXcg7Dxx5sSCUfN@f+&XsCn-y9 z-aS_ONCR?K`hJq5N(6rdW7@?V-0`M0{1qHB2Y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gb|)oVUA3o`%LeviJABf8FaITMOnLk`FuN6KuZSRk_-wZ_}(_ zvM<}z;rQ71u+|#k!df3F#~aAM{qZLSRbxAz6uh{{DZv)lwni-yX0_}T^n&){B>C|( z=nd_V!u;Cna(|}?degG)ZAs>MM=bQzpnn3xdw#(;6K=ohl!Y=qKMn)JU}W(+T2>`1 z*?Nh;$B@C?9?fFVrEw;WlR#EOZRdeZDBZ(d9BV#ytVy1^NYWaj^R?KEEy{v+o56yY zVfRLxJxw|r!=drw%&8Vz!Rgfwewq_)7`wUV(Z{Ts{D15}!)&@U16i@QePCSeEsxvW zAp&?OoyMfYg!E}wcaWoa!8@Cm7=V=RHf;%h~c06S;FfRSBR%A#0 zM%oJU3^hls)}FhkSF@YHO}F-0drM39_Wd2`dD29;iv;dK*T?g1U5g8dE|>V*O3;D~ zAX!Pu&wsS4(uDFK`rt>QDvUbmJYHq;bTqkHq_YKx27g{4vZUWupb#(~uo+&&>leER zH<-fJ5iL})PWPTvZDqDl#Ul4ss;T= threshold) { th.classList.add(inferableClasses[key].class); @@ -341,7 +342,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { function parseNumberFromString(str) { let num; str = str.slice(0, str.indexOf("#")); - if (str.match(/^\((\d+(?:\.\d+)?)\)$/)) { + if (str.match(/^\(-?(\d+(?:\.\d+)?)\)$/)) { num = -1 * Number(str.slice(1, -1)); } else { num = Number(str); @@ -358,11 +359,13 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { } function handleNumbers(str1, str2) { - let num1, num2; - str1 = str1.replaceAll(",", ""); - str2 = str2.replaceAll(",", ""); - num1 = parseNumberFromString(str1); - num2 = parseNumberFromString(str2); + const matchCurrencyCommaAndPercent = /[$£€¥₩₽₺₣฿₿Ξξ¤¿\u20A1\uFFE0,% ]/g; + str1 = str1.replace(matchCurrencyCommaAndPercent, ""); + str2 = str2.replace(matchCurrencyCommaAndPercent, ""); + const [num1, num2] = [ + parseNumberFromString(str1), + parseNumberFromString(str2), + ]; if (!isNaN(num1) && !isNaN(num2)) { return num1 - num2; diff --git a/browser-extensions/firefox/manifest.json b/browser-extensions/firefox/manifest.json index c3fa018..f93ad67 100644 --- a/browser-extensions/firefox/manifest.json +++ b/browser-extensions/firefox/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "author": "Lee Wannacott", "name": "table-sort-js", - "version": "1.20.0", + "version": "1.21.0", "description": "Makes tables sortable using table-sort-js: https://github.com/LeeWannacott/table-sort-js", "icons": { "48": "icons/t.png" }, "browser_action": { diff --git a/browser-extensions/firefox/table-sort-js.zip b/browser-extensions/firefox/table-sort-js.zip index 8b682a74158ecd4ae3503cd445b5952decd5975a..1676d5b4a48a6ff2c115364bdaf52b5d9771321c 100644 GIT binary patch delta 5373 zcmVLs1S6ILfvl$*W!8S+=p#Wpkmq+0jf>9D6=^Gfm4pnJ<3G`{8h}_j1WY zfc$_UK(fI8fcp)Be@Uvkd-`i;C`vYh7zV|euBxuCs;;iCuIAuA>9F7;f1x{NUa+0l zW#@3gW_d9p&nP9|2U!+`Ib)q?aY(a}j>zfLbHX1=N{;jSvWPEdjCf&>?CtIiZ7k9u z@UQbt%)VV*kniX`FJqP$%MqC|HZMnm!DY;5iwi%@(*a;A#DUFHHc!bs2;T&kRHI&9 zUHQ=Py5!ih*+G0l(_CXDf0SNTJ@~TcI3K(O;Ax(~w=V{Q)y~tbWI>XQIwwV*F`7jq z@~{kxc+N;!gpay6P_&pZp8VHk_wmDlp!AsJMdwL=l_hx)5jKlUGK~{Tf-E9I6xkiN z(qK7R=8J-Sdw%+ibdEp@oLiJwECxX=ZaDb`=&qo@U&ICVy1qZifAWa_Q<_JMgqCZW z?-4GVViB@9&&m<#_YhbOlb|e3CcDTNe=L!`uOgDfZz#S@1Ne&|*a+yyNgTc*c?JTY z0)xzG5YeJUXavNT)bHFMbUM>T#yb{(XVCcT(qpt_advsGUY(IgWEvzT?UN`^pXA{p zr5XD^&Z7JZnj-n4e@CvNe?{_=GL#`FQ+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4lMZ&>ex)j7r!000-0%O58Mn{9 diff --git a/browser-extensions/firefox/table-sort.js b/browser-extensions/firefox/table-sort.js index 300da8b..7004923 100644 --- a/browser-extensions/firefox/table-sort.js +++ b/browser-extensions/firefox/table-sort.js @@ -64,9 +64,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { // Don't infer dates with delimiter "."; as could capture semantic version numbers. const dmyRegex = /^(\d\d?)[/-](\d\d?)[/-]((\d\d)?\d\d)/; const ymdRegex = /^(\d\d\d\d)[/-](\d\d?)[/-](\d\d?)/; - // const numericRegex = /^(?:\(\d+(?:\.\d+)?\)|-?\d+(?:\.\d+)?)$/; doesn't handle commas const numericRegex = - /^-?(?:\d{1,3}(?:[',]\d{3})*(?:\.\d+)?|\d+(?:\.\d+)?(?:[',]\d{3})*?)$/; + /^-?(?:[$£€¥₩₽₺₣฿₿Ξξ¤¿\u20A1\uFFE0]\d{1,3}(?:[',]\d{3})*(?:\.\d+)?|\d+(?:\.\d+)?(?:[',]\d{3})*?)(?:%?)$/; + const inferableClasses = { runtime: { regexp: runtimeRegex, class: "runtime-sort", count: 0 }, filesize: { regexp: fileSizeRegex, class: "file-size-sort", count: 0 }, @@ -91,11 +91,12 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { let foundMatch = false; for (let key of Object.keys(inferableClasses)) { let classRegexp = inferableClasses[key].regexp; - if (tableColumn.innerText !== undefined) { - if (tableColumn.innerText.match(classRegexp)) { - foundMatch = true; - inferableClasses[key].count++; - } + let columnOfTd = testingTableSortJS + ? tableColumn.textContent + : tableColumn.innerText; + if (columnOfTd !== undefined && columnOfTd.match(classRegexp)) { + foundMatch = true; + inferableClasses[key].count++; } if (inferableClasses[key].count >= threshold) { th.classList.add(inferableClasses[key].class); @@ -341,7 +342,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { function parseNumberFromString(str) { let num; str = str.slice(0, str.indexOf("#")); - if (str.match(/^\((\d+(?:\.\d+)?)\)$/)) { + if (str.match(/^\(-?(\d+(?:\.\d+)?)\)$/)) { num = -1 * Number(str.slice(1, -1)); } else { num = Number(str); @@ -358,11 +359,13 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { } function handleNumbers(str1, str2) { - let num1, num2; - str1 = str1.replaceAll(",", ""); - str2 = str2.replaceAll(",", ""); - num1 = parseNumberFromString(str1); - num2 = parseNumberFromString(str2); + const matchCurrencyCommaAndPercent = /[$£€¥₩₽₺₣฿₿Ξξ¤¿\u20A1\uFFE0,% ]/g; + str1 = str1.replace(matchCurrencyCommaAndPercent, ""); + str2 = str2.replace(matchCurrencyCommaAndPercent, ""); + const [num1, num2] = [ + parseNumberFromString(str1), + parseNumberFromString(str2), + ]; if (!isNaN(num1) && !isNaN(num2)) { return num1 - num2; diff --git a/npm/README.md b/npm/README.md index 0acc86a..c458b05 100644 --- a/npm/README.md +++ b/npm/README.md @@ -21,13 +21,13 @@ - Option 1: Load as script from a Content Delivery Network (CDN): ```javascript - + ``` -Or Minified (smaller size, but harder to debug!): +Or non-minified version (larger size, but easier to debug!): ```javascript - + ``` Example on how to use table-sort-js with [HTML](https://leewannacott.github.io/table-sort-js/docs/html5.html) @@ -72,7 +72,8 @@ Examples on using table-sort-js with frontend frameworks such as [React.js](http | <th> Inferred Classes. | Description | | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -| "numeric-sort" | Sorts numbers including decimals - Positive, Negative (in both minus and parenthesis representations) | +| "numeric-sort" | Sorts numbers including decimals - Positive, Negative (in both minus and parenthesis representations). | +| | Supports common currencies e.g ($£€¥) and percentage signs e.g (0.39%) | | "dates-dmy-sort" | Sorts dates in dd/mm/yyyy format. e.g (18/10/1995). Can use "/" or "-" as separator. | | "dates-ymd-sort" | Sorts dates in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) yyyy/mm/dd format. e.g (2021/10/28). Use "/" or "-" as separator. | | "file-size-sort" | Sorts file sizes(B->TiB) uses the binary prefix. (e.g 10 B, 100 KiB, 1 MiB); optional space between number and prefix. | diff --git a/npm/package.json b/npm/package.json index f4b887a..3a39da2 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "table-sort-js", - "version": "1.20.0", + "version": "1.21.0", "description": "A JavaScript client-side HTML table sorting library with no dependencies required.", "license": "MIT", "repository": "LeeWannacott/table-sort-js", diff --git a/npm/table-sort.js b/npm/table-sort.js index 300da8b..7004923 100644 --- a/npm/table-sort.js +++ b/npm/table-sort.js @@ -64,9 +64,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { // Don't infer dates with delimiter "."; as could capture semantic version numbers. const dmyRegex = /^(\d\d?)[/-](\d\d?)[/-]((\d\d)?\d\d)/; const ymdRegex = /^(\d\d\d\d)[/-](\d\d?)[/-](\d\d?)/; - // const numericRegex = /^(?:\(\d+(?:\.\d+)?\)|-?\d+(?:\.\d+)?)$/; doesn't handle commas const numericRegex = - /^-?(?:\d{1,3}(?:[',]\d{3})*(?:\.\d+)?|\d+(?:\.\d+)?(?:[',]\d{3})*?)$/; + /^-?(?:[$£€¥₩₽₺₣฿₿Ξξ¤¿\u20A1\uFFE0]\d{1,3}(?:[',]\d{3})*(?:\.\d+)?|\d+(?:\.\d+)?(?:[',]\d{3})*?)(?:%?)$/; + const inferableClasses = { runtime: { regexp: runtimeRegex, class: "runtime-sort", count: 0 }, filesize: { regexp: fileSizeRegex, class: "file-size-sort", count: 0 }, @@ -91,11 +91,12 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { let foundMatch = false; for (let key of Object.keys(inferableClasses)) { let classRegexp = inferableClasses[key].regexp; - if (tableColumn.innerText !== undefined) { - if (tableColumn.innerText.match(classRegexp)) { - foundMatch = true; - inferableClasses[key].count++; - } + let columnOfTd = testingTableSortJS + ? tableColumn.textContent + : tableColumn.innerText; + if (columnOfTd !== undefined && columnOfTd.match(classRegexp)) { + foundMatch = true; + inferableClasses[key].count++; } if (inferableClasses[key].count >= threshold) { th.classList.add(inferableClasses[key].class); @@ -341,7 +342,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { function parseNumberFromString(str) { let num; str = str.slice(0, str.indexOf("#")); - if (str.match(/^\((\d+(?:\.\d+)?)\)$/)) { + if (str.match(/^\(-?(\d+(?:\.\d+)?)\)$/)) { num = -1 * Number(str.slice(1, -1)); } else { num = Number(str); @@ -358,11 +359,13 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { } function handleNumbers(str1, str2) { - let num1, num2; - str1 = str1.replaceAll(",", ""); - str2 = str2.replaceAll(",", ""); - num1 = parseNumberFromString(str1); - num2 = parseNumberFromString(str2); + const matchCurrencyCommaAndPercent = /[$£€¥₩₽₺₣฿₿Ξξ¤¿\u20A1\uFFE0,% ]/g; + str1 = str1.replace(matchCurrencyCommaAndPercent, ""); + str2 = str2.replace(matchCurrencyCommaAndPercent, ""); + const [num1, num2] = [ + parseNumberFromString(str1), + parseNumberFromString(str2), + ]; if (!isNaN(num1) && !isNaN(num2)) { return num1 - num2;