Line 203: |
Line 203: |
| <script src="/js/jquery.dataTables.min.js"></script> | | <script src="/js/jquery.dataTables.min.js"></script> |
| <script> | | <script> |
− | | + | function trim(str) { |
− | 1
| + | str = str.replace(/^\s+/, ''); |
− | 2
| + | for (var i = str.length - 1; i >= 0; i--) { |
− | 3
| + | if (/\S/.test(str.charAt(i))) { |
− | 4
| + | str = str.substring(0, i + 1); |
− | 5
| + | break; |
− | 6
| + | } |
− | 7
| + | } |
− | 8
| + | return str; |
− | 9
| + | } |
− | 10
| |
− | 11
| |
− | 12
| |
− | 13
| |
− | 14
| |
− | 15
| |
− | 16
| |
− | 17
| |
− | 18
| |
− | 19
| |
− | 20
| |
− | 21
| |
− | 22
| |
− | 23
| |
− | 24
| |
− | 25
| |
− | 26
| |
− | 27
| |
− | 28
| |
− | 29
| |
− | jQuery.extend( jQuery.fn.dataTableExt.oSort, {
| |
− | "date-euro-pre": function ( a ) {
| |
− | if ($.trim(a) != '') {
| |
− |
| |
− | var frDatea = $.trim(a).split(' ');
| |
− |
| |
− | var frTimea = frDatea[1].split(':'); // hh:mm:ss
| |
− |
| |
− | var frDatea2 = frDatea[0].split('/'); // YYYY-MM-DD
| |
− |
| |
− | var x = new Date(frDatea2[2],frDatea2[1]-1,frDatea2[0],frTimea[0],frTimea[1],frTimea[2]);
| |
| | | |
| + | function dateHeight(dateStr){ |
| + | if (trim(dateStr) != '') { |
| + | var frDate = trim(dateStr).split(' '); |
| + | var frTime = frDate[1].split(':'); |
| + | var frDateParts = frDate[0].split('/'); |
| + | var day = frDateParts[0] * 60 * 24; |
| + | var month = frDateParts[1] * 60 * 24 * 31; |
| + | var year = frDateParts[2] * 60 * 24 * 366; |
| + | var hour = frTime[0] * 60; |
| + | var minutes = frTime[1]; |
| + | var x = day+month+year+hour+minutes; |
| } else { | | } else { |
− |
| + | var x = 99999999999999999; //GoHorse! |
− | var x = new Date(0,0,0,0,0,0);
| |
− |
| |
| } | | } |
− |
| |
| return x; | | return x; |
− | },
| + | } |
− |
| + | |
− | "date-euro-asc": function ( a, b ) {
| + | jQuery.fn.dataTableExt.oSort['date-euro-asc'] = function(a, b) { |
− | return a > b;
| + | var x = dateHeight(a); |
− | },
| + | var y = dateHeight(b); |
− |
| + | var z = ((x < y) ? -1 : ((x > y) ? 1 : 0)); |
− | "date-euro-desc": function ( a, b ) {
| + | return z; |
− | return b > a;
| + | }; |
− | }
| + | |
− | } ); | + | jQuery.fn.dataTableExt.oSort['date-euro-desc'] = function(a, b) { |
| + | var x = dateHeight(a); |
| + | var y = dateHeight(b); |
| + | var z = ((x < y) ? 1 : ((x > y) ? -1 : 0)); |
| + | return z; |
| + | }; |
| + | |
| + | |
| </script> | | </script> |
| </scripts> | | </scripts> |