Total Complexity | 8 |
Complexity/F | 2.67 |
Lines of Code | 28 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | (function ($) { |
||
2 | $(document).ready(function () { |
||
3 | $('table').tablesort({ |
||
4 | compare: function(a, b) { |
||
5 | // Manage int, cast into int to have good result |
||
6 | if (!isNaN(a) && !isNaN(b)) { |
||
7 | a = Number.parseInt(a); |
||
8 | b = Number.parseInt(b); |
||
9 | } else { |
||
10 | // Manage prices, keep only number and cast int to int |
||
11 | if (a.match(moneyRegex)) { |
||
|
|||
12 | a = Number.parseInt(a.replace(/\D/g,'')); |
||
13 | } |
||
14 | if (b.match(moneyRegex)) { |
||
15 | b = Number.parseInt(b.replace(/\D/g,'')); |
||
16 | } |
||
17 | } |
||
18 | if (a > b) { |
||
19 | return 1; |
||
20 | } else if (a < b) { |
||
21 | return -1; |
||
22 | } else { |
||
23 | return 0; |
||
24 | } |
||
25 | } |
||
26 | }); |
||
27 | }); |
||
28 | })(window.Zepto || window.jQuery); |
||
29 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.