New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tablesort

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tablesort - npm Package Compare versions

Comparing version 1.6.4 to 1.7.0

GruntFile.js

16

package.json
{
"name": "tablesort",
"description": "A sorting component for HTML tables",
"version": "1.6.4",
"version": "1.7.0",
"author": "tristen <@fallsemo>",

@@ -9,9 +9,6 @@ "ender": "./ender.js",

"homepage": "http://tristen.ca/tablesort/demo",
"contributors": [
"Olivier Vaillancourt <@ovaillancourt>",
"Dmitry Kichenko <@imissmyjuno>",
"Dong Liu <@dongliu>",
"Andrew Cobby <andrew.cobby@gmail.com>",
"Pavel D. <@thexpaw>"
],
"repository": {
"type": "git",
"url": "git://github.com/tristen/tablesort.git"
},
"licenses": [{

@@ -21,4 +18,5 @@ "type": "MIT"

"devDependencies": {
"grunt": "0.3.x"
"grunt": "~0.4.5",
"grunt-contrib-uglify": "~0.5.0"
}
}

@@ -59,2 +59,9 @@ # tablesort.js

__Default sort on tablesort initialization__
It is possible to automatically sort the table once you create a Tablesort instance by adding `sort-default` class.
``` html
<th class='sort-default'>Name</th>
```
__Refresh sort on appended data__

@@ -61,0 +68,0 @@ Tablesort supports sorting when new data has been added. Simply call the refresh method.

@@ -32,3 +32,3 @@ ;(function () {

var onClick = function (e) {
var onClick = function () {
// Delete sort classes on headers that are not the current one.

@@ -48,2 +48,4 @@ var siblings = getParent(cell, 'tr').getElementsByTagName('th');

var defaultSort;
// Assume first row is the header and attach a click handler to each.

@@ -55,4 +57,13 @@ for (var i = 0; i < firstRow.cells.length; i++) {

addEvent(cell, 'click', onClick);
if (hasClass(cell, 'sort-default')) {
defaultSort = cell;
}
}
}
if (defaultSort) {
that.current = defaultSort;
that.sortTable(defaultSort);
}
},

@@ -119,4 +130,4 @@

// Sort as number if a currency key exists or number
if (item.match(/^-?[£\x24Û¢´€] ?\d/) || // prefixed currency
item.match(/^-?\d+\s*[€]/) || // suffixed currencty
if (item.match(/^-?[£\x24Û¢´€]?\d+\s*([,\.]\d{0,2})/) || // prefixed currency
item.match(/^-?\d+\s*([,\.]\d{0,2})?[£\x24Û¢´€]/) || // suffixed currency
item.match(/^-?(\d+[,\.]?)+(E[\-+][\d]+)?%?$/) // number

@@ -123,0 +134,0 @@ ) {

/*!
* tablesort v1.6.3 (2014-06-10)
* tablesort v1.6.5 (2014-08-31)
* http://tristen.ca/tablesort/demo
* Copyright (c) 2014 ; Licensed MIT
*/
(function(){function e(e,t){if(e.tagName!=="TABLE")throw new Error("Element must be a table");this.init(e,t||{})}e.prototype={init:function(e,t){var n=this,r;this.thead=!1,this.options=t,this.options.d=t.descending||!1,e.rows&&e.rows.length>0&&(e.tHead&&e.tHead.rows.length>0?(r=e.tHead.rows[e.tHead.rows.length-1],n.thead=!0):r=e.rows[0]);if(!r)return;var i=function(e){var t=o(u,"tr").getElementsByTagName("th");for(var r=0;r<t.length;r++)(c(t[r],"sort-up")||c(t[r],"sort-down"))&&t[r]!==this&&(t[r].className=t[r].className.replace(" sort-down","").replace(" sort-up",""));n.current=this,n.sortTable(this)};for(var s=0;s<r.cells.length;s++){var u=r.cells[s];c(u,"no-sort")||(u.className+=" sort-header",h(u,"click",i))}},getFirstDataRowIndex:function(){return this.thead?0:1},sortTable:function(e,t){var n=this,r=e.cellIndex,h,p=o(e,"table"),d="",v=n.getFirstDataRowIndex();if(p.rows.length<=1)return;while(d===""&&v<p.tBodies[0].rows.length){d=u(p.tBodies[0].rows[v].cells[r]),d=f(d);if(d.substr(0,4)==="<!--"||d.length===0)d="";v++}if(d==="")return;var m=function(e,t){var r=u(e.cells[n.col]).toLowerCase(),i=u(t.cells[n.col]).toLowerCase();return r===i?0:r<i?1:-1},g=function(e,t){var r=u(e.cells[n.col]),i=u(t.cells[n.col]);return r=l(r),i=l(i),a(i,r)},y=function(e,t){var r=u(e.cells[n.col]).toLowerCase(),i=u(t.cells[n.col]).toLowerCase();return s(i)-s(r)};d.match(/^-?[£\x24Û¢´€] ?\d/)||d.match(/^-?\d+\s*[€]/)||d.match(/^-?(\d+[,\.]?)+(E[\-+][\d]+)?%?$/)?h=g:i(d)?h=y:h=m,this.col=r;var b=[],w={},E,S=0;for(v=0;v<p.tBodies.length;v++)for(E=0;E<p.tBodies[v].rows.length;E++){var x=p.tBodies[v].rows[E];c(x,"no-sort")?w[S]=x:b.push({tr:x,index:S}),S++}t||(n.options.d?c(e,"sort-up")?(e.className=e.className.replace(/ sort-up/,""),e.className+=" sort-down"):(e.className=e.className.replace(/ sort-down/,""),e.className+=" sort-up"):c(e,"sort-down")?(e.className=e.className.replace(/ sort-down/,""),e.className+=" sort-up"):(e.className=e.className.replace(/ sort-up/,""),e.className+=" sort-down"));var T=function(e){return function(t,n){var r=e(t.tr,n.tr);return r===0?t.index-n.index:r}},N=function(e){return function(t,n){var r=e(t.tr,n.tr);return r===0?n.index-t.index:r}};c(e,"sort-down")?(b.sort(N(h)),b.reverse()):b.sort(T(h));var C=0;for(v=0;v<S;v++){var k;w[v]?(k=w[v],C++):k=b[v-C].tr,p.tBodies[0].appendChild(k)}},refresh:function(){this.current!==undefined&&this.sortTable(this.current,!0)}};var t=/(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\.?\,?\s*/i,n=/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/,r=/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/i,i=function(e){return(e.search(t)!==-1||e.search(n)!==-1||e.search(r!==-1))!==-1&&!isNaN(s(e))},s=function(e){return e=e.replace(/\-/g,"/"),e=e.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3"),(new Date(e)).getTime()},o=function(e,t){return e===null?null:e.nodeType===1&&e.tagName.toLowerCase()===t.toLowerCase()?e:o(e.parentNode,t)},u=function(e){var t=this;if(typeof e=="string"||typeof e=="undefined")return e;var n=e.getAttribute("data-sort")||"";if(n)return n;if(e.textContent)return e.textContent;if(e.innerText)return e.innerText;var r=e.childNodes,i=r.length;for(var s=0;s<i;s++)switch(r[s].nodeType){case 1:n+=t.getInnerText(r[s]);break;case 3:n+=r[s].nodeValue}return n},a=function(e,t){var n=parseFloat(e),r=parseFloat(t);return e=isNaN(n)?0:n,t=isNaN(r)?0:r,e-t},f=function(e){return e.replace(/^\s+|\s+$/g,"")},l=function(e){return e.replace(/[^\-?0-9.]/g,"")},c=function(e,t){return(" "+e.className+" ").indexOf(" "+t+" ")>-1},h=function(e,t,n){e.attachEvent?(e["e"+t+n]=n,e[t+n]=function(){e["e"+t+n](window.event)},e.attachEvent("on"+t,e[t+n])):e.addEventListener(t,n,!1)};typeof module!="undefined"&&module.exports?module.exports=e:window.Tablesort=e})();
*/!function(){function a(a,b){if("TABLE"!==a.tagName)throw new Error("Element must be a table");this.init(a,b||{})}a.prototype={init:function(a,b){var c,d=this;if(this.thead=!1,this.options=b,this.options.d=b.descending||!1,a.rows&&a.rows.length>0&&(a.tHead&&a.tHead.rows.length>0?(c=a.tHead.rows[a.tHead.rows.length-1],d.thead=!0):c=a.rows[0]),c){for(var e,f=function(){for(var a=g(i,"tr").getElementsByTagName("th"),b=0;b<a.length;b++)(l(a[b],"sort-up")||l(a[b],"sort-down"))&&a[b]!==this&&(a[b].className=a[b].className.replace(" sort-down","").replace(" sort-up",""));d.current=this,d.sortTable(this)},h=0;h<c.cells.length;h++){var i=c.cells[h];l(i,"no-sort")||(i.className+=" sort-header",m(i,"click",f),l(i,"sort-default")&&(e=i))}e&&(d.current=e,d.sortTable(e))}},getFirstDataRowIndex:function(){return this.thead?0:1},sortTable:function(a,b){var c,d=this,m=a.cellIndex,n=g(a,"table"),o="",p=d.getFirstDataRowIndex();if(!(n.rows.length<=1)){for(;""===o&&p<n.tBodies[0].rows.length;)o=h(n.tBodies[0].rows[p].cells[m]),o=j(o),("<!--"===o.substr(0,4)||0===o.length)&&(o=""),p++;if(""!==o){var q=function(a,b){var c=h(a.cells[d.col]).toLowerCase(),e=h(b.cells[d.col]).toLowerCase();return c===e?0:e>c?1:-1},r=function(a,b){var c=h(a.cells[d.col]),e=h(b.cells[d.col]);return c=k(c),e=k(e),i(e,c)},s=function(a,b){var c=h(a.cells[d.col]).toLowerCase(),e=h(b.cells[d.col]).toLowerCase();return f(e)-f(c)};c=o.match(/^-?[£\x24Û¢´€]?\d+\s*([,\.]\d{0,2})/)||o.match(/^-?\d+\s*([,\.]\d{0,2})?[£\x24Û¢´€]/)||o.match(/^-?(\d+[,\.]?)+(E[\-+][\d]+)?%?$/)?r:e(o)?s:q,this.col=m;var t,u=[],v={},w=0;for(p=0;p<n.tBodies.length;p++)for(t=0;t<n.tBodies[p].rows.length;t++){var x=n.tBodies[p].rows[t];l(x,"no-sort")?v[w]=x:u.push({tr:x,index:w}),w++}b||(d.options.d?l(a,"sort-up")?(a.className=a.className.replace(/ sort-up/,""),a.className+=" sort-down"):(a.className=a.className.replace(/ sort-down/,""),a.className+=" sort-up"):l(a,"sort-down")?(a.className=a.className.replace(/ sort-down/,""),a.className+=" sort-up"):(a.className=a.className.replace(/ sort-up/,""),a.className+=" sort-down"));var y=function(a){return function(b,c){var d=a(b.tr,c.tr);return 0===d?b.index-c.index:d}},z=function(a){return function(b,c){var d=a(b.tr,c.tr);return 0===d?c.index-b.index:d}};l(a,"sort-down")?(u.sort(z(c)),u.reverse()):u.sort(y(c));var A=0;for(p=0;w>p;p++){var B;v[p]?(B=v[p],A++):B=u[p-A].tr,n.tBodies[0].appendChild(B)}}}},refresh:function(){void 0!==this.current&&this.sortTable(this.current,!0)}};var b=/(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\.?\,?\s*/i,c=/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/,d=/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/i,e=function(a){return-1!==(-1!==a.search(b)||-1!==a.search(c)||a.search(-1!==d))&&!isNaN(f(a))},f=function(a){return a=a.replace(/\-/g,"/"),a=a.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3"),new Date(a).getTime()},g=function(a,b){return null===a?null:1===a.nodeType&&a.tagName.toLowerCase()===b.toLowerCase()?a:g(a.parentNode,b)},h=function(a){var b=this;if("string"==typeof a||"undefined"==typeof a)return a;var c=a.getAttribute("data-sort")||"";if(c)return c;if(a.textContent)return a.textContent;if(a.innerText)return a.innerText;for(var d=a.childNodes,e=d.length,f=0;e>f;f++)switch(d[f].nodeType){case 1:c+=b.getInnerText(d[f]);break;case 3:c+=d[f].nodeValue}return c},i=function(a,b){var c=parseFloat(a),d=parseFloat(b);return a=isNaN(c)?0:c,b=isNaN(d)?0:d,a-b},j=function(a){return a.replace(/^\s+|\s+$/g,"")},k=function(a){return a.replace(/[^\-?0-9.]/g,"")},l=function(a,b){return(" "+a.className+" ").indexOf(" "+b+" ")>-1},m=function(a,b,c){a.attachEvent?(a["e"+b+c]=c,a[b+c]=function(){a["e"+b+c](window.event)},a.attachEvent("on"+b,a[b+c])):a.addEventListener(b,c,!1)};"undefined"!=typeof module&&module.exports?module.exports=a:window.Tablesort=a}();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc