corrade-nucleus-nucleons
/pack-rat/003_pack_rat/pack-rat/node_modules/bootstrap-table/dist/extensions/natural-sorting/bootstrap-table-natural-sorting.js |
@@ -0,0 +1,67 @@ |
/** |
* @author: Brian Huisman |
* @webSite: http://www.greywyvern.com |
* @version: v1.0.0 |
* JS functions to allow natural sorting on bootstrap-table columns |
* add data-sorter="alphanum" or data-sorter="numericOnly" to any th |
* |
* @update Dennis Hernández <http://djhvscf.github.io/Blog> |
* @update Duane May |
*/ |
|
function alphanum(a, b) { |
function chunkify(t) { |
var tz = [], |
x = 0, |
y = -1, |
n = 0, |
i, |
j; |
|
while (i = (j = t.charAt(x++)).charCodeAt(0)) { |
var m = (i === 46 || (i >= 48 && i <= 57)); |
if (m !== n) { |
tz[++y] = ""; |
n = m; |
} |
tz[y] += j; |
} |
return tz; |
} |
|
function stringfy(v) { |
if (typeof(v) === "number") { |
v = "" + v; |
} |
if (!v) { |
v = ""; |
} |
return v; |
} |
|
var aa = chunkify(stringfy(a)); |
var bb = chunkify(stringfy(b)); |
|
for (x = 0; aa[x] && bb[x]; x++) { |
if (aa[x] !== bb[x]) { |
var c = Number(aa[x]), |
d = Number(bb[x]); |
|
if (c == aa[x] && d == bb[x]) { |
return c - d; |
} else { |
return (aa[x] > bb[x]) ? 1 : -1; |
} |
} |
} |
return aa.length - bb.length; |
} |
|
function numericOnly(a, b) { |
function stripNonNumber(s) { |
s = s.replace(new RegExp(/[^0-9]/g), ""); |
return parseInt(s, 10); |
} |
|
return stripNonNumber(a) - stripNonNumber(b); |
} |
/pack-rat/003_pack_rat/pack-rat/node_modules/bootstrap-table/dist/extensions/natural-sorting/bootstrap-table-natural-sorting.min.js |
@@ -0,0 +1,7 @@ |
/* |
* bootstrap-table - v1.11.1 - 2017-02-22 |
* https://github.com/wenzhixin/bootstrap-table |
* Copyright (c) 2017 zhixin wen |
* Licensed MIT License |
*/ |
function alphanum(a,b){function c(a){for(var b,c,d=[],e=0,f=-1,g=0;b=(c=a.charAt(e++)).charCodeAt(0);){var h=46===b||b>=48&&57>=b;h!==g&&(d[++f]="",g=h),d[f]+=c}return d}function d(a){return"number"==typeof a&&(a=""+a),a||(a=""),a}var e=c(d(a)),f=c(d(b));for(x=0;e[x]&&f[x];x++)if(e[x]!==f[x]){var g=Number(e[x]),h=Number(f[x]);return g==e[x]&&h==f[x]?g-h:e[x]>f[x]?1:-1}return e.length-f.length}function numericOnly(a,b){function c(a){return a=a.replace(new RegExp(/[^0-9]/g),""),parseInt(a,10)}return c(a)-c(b)} |