rv table sorting of IP and fraction
authorAntoine Musso <hashar@users.mediawiki.org>
Tue, 6 Mar 2012 10:17:46 +0000 (10:17 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Tue, 6 Mar 2012 10:17:46 +0000 (10:17 +0000)
I am reverting, for now, two recent additions made to the table sorting:
 - r111884 fractions
 - r111829 IP addresses

Both need to be polished a bit more before landing in trunk. Please reapply
in a branch then once reviewed we can merge it in trunk, that will avoid
us a lot of "spam".

RELEASE-NOTES-1.20
resources/jquery/jquery.tablesorter.js
tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js

index a414942..1b00309 100644 (file)
@@ -19,9 +19,7 @@ production.
   preference for the non-default skin to look at something using the default skin.
 * (bug 31417) New ID mw-content-text around the actual page text, without categories,
   contentSub, ... The same div often also contains the class mw-content-ltr/rtl.
-* (bug 34475) Add support for IP/CIDR notation to tablesorter
 * (bug 27619) Remove preference option to display broken links as link?
-* (bug 15404) Add support for sorting fractions in jquery.tablesorter
 * (bug 34896) Update jQuery JSON plugin to v2.3 (2011-09-17)
 
 === Bug fixes in 1.20 ===
index 6ffddf2..ea86b64 100644 (file)
                                digits.push( $.escapeRE( localised[i] ) );
                        }
                }
-               ts.digitClass = '[' + digits.join( '', digits ) + ']';
+               var digitClass = '[' + digits.join( '', digits ) + ']';
 
                // We allow a trailing percent sign, which we just strip. This works fine
                // if percents and regular numbers aren't being mixed.
                ts.numberRegex = new RegExp("^(" + "[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?" + // Fortran-style scientific
-               "|" + "[-+\u2212]?" + ts.digitClass + "+[\\s\\xa0]*%?" + // Generic localised
-               "|([-+\u2212]?" + ts.digitClass + "+[\\s\\xa0]+)*" + ts.digitClass + "+[\\s\\xa0]*[\\/][\\s\\xa0]*" + ts.digitClass + "+" + // Fractions
+               "|" + "[-+\u2212]?" + digitClass + "+[\\s\\xa0]*%?" + // Generic localised
                ")$", "i");
        }
 
                }
                ts.rgx = {
                        IPAddress: [
-                               new RegExp( /^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}(\/\d{1,3})?$/)
+                               new RegExp( /^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/)
                        ],
                        currency: [
                                new RegExp( /^[£$€?.]/),
                        ],
                        time: [
                                new RegExp( /^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/)
-                       ],
-                       fractions: [
-                               new RegExp( "^(?:([-+\u2212]?" + ts.digitClass + "+)[\\s\\xa0]+)*(" + ts.digitClass + "+)[\\s\\xa0]*[\\/][\\s\\xa0]*(" + ts.digitClass + "+)" )
                        ]
                };
        }
                },
                format: function( s ) {
                        var     a = s.split( '.' ),
-                               r = '';
-                       if( a.length == 4 ) {
-                               var cidr = a[3].split('/');
-                               if (cidr.length > 1 ) {
-                                       a[3] = cidr[0];
-                                       a[4] = cidr[1];
-                               } else a[4] = '000';
-                       }
-                       for ( var i = 0; i < a.length; i++ ) {
+                               r = '',
+                               l = a.length;
+                       for ( var i = 0; i < l; i++ ) {
                                var item = a[i];
                                if ( item.length == 1 ) {
                                        r += '00' + item;
                        return $.tablesorter.numberRegex.test( $.trim( s ));
                },
                format: function( s ) {
-                       var values = ts.rgx.fractions[0].exec($.trim(s));
-                       if( values != null ) {
-                               // A fraction
-                               var retVal = 0;
-                               var decimal = $.tablesorter.formatDigit(values[2]) / $.tablesorter.formatDigit(values[3]);
-                               if( values[1] != undefined ) {
-                                       retVal = $.tablesorter.formatDigit(values[1]);
-                               }
-                               if( !isNaN(decimal) && isFinite(decimal) ) {
-                                       retVal += decimal;
-                               }
-                               return retVal;
-                       }
                        return $.tablesorter.formatDigit(s);
                },
                type: 'numeric'
index a76af5e..95284c7 100644 (file)
@@ -236,38 +236,6 @@ var ipv4Sorted = [
        ['204.204.132.158'],
        ['247.240.82.209']
 ];
-var ipv4CIDR = [
-       // Some randomly generated fake IPs
-       ['45.238.27.109/36'],
-       ['170.38.91.162/36'],
-       ['247.240.82.209/36'],
-       ['204.204.132.158/24'],
-       ['170.38.91.162/24']
-];
-var ipv4CIDRSorted = [
-       // Sort order should go octet by octet
-       ['45.238.27.109/36'],
-       ['170.38.91.162/24'],
-       ['170.38.91.162/36'],
-       ['204.204.132.158/24'],
-       ['247.240.82.209/36']
-];
-var ipv4Mixed = [
-       // Some randomly generated fake IPs
-       ['45.238.27.109'],
-       ['170.38.91.162'],
-       ['247.240.82.209'],
-       ['204.204.132.158/24'],
-       ['170.38.91.162/24']
-];
-var ipv4MixedSorted = [
-       // Sort order should go octet by octet
-       ['45.238.27.109'],
-       ['170.38.91.162'],
-       ['170.38.91.162/24'],
-       ['204.204.132.158/24'],
-       ['247.240.82.209']
-];
 
 tableTest(
        'Bug 17141: IPv4 address sorting',
@@ -289,27 +257,6 @@ tableTest(
                $table.find( '.headerSort:eq(0)' ).click().click();
        }
 );
-tableTest(
-       'Bug 34475: IPv4/CIDR address sorting',
-       ['IP'],
-       ipv4CIDR,
-       ipv4CIDRSorted,
-       function( $table ) {
-               $table.tablesorter();
-               $table.find( '.headerSort:eq(0)' ).click();
-       }
-);
-
-tableTest(
-       'Bug 34475: Mixed IPv4 and IP/CIDR address sorting',
-       ['IP'],
-       ipv4Mixed,
-       ipv4MixedSorted,
-       function( $table ) {
-               $table.tablesorter();
-               $table.find( '.headerSort:eq(0)' ).click();
-       }
-);
 
 var umlautWords = [
        // Some words with Umlauts
@@ -575,47 +522,6 @@ tableTest( 'bug 8115: sort numbers with commas (descending)',
 );
 // TODO add numbers sorting tests for bug 8115 with a different language
 
-var fractions = [
-       [ '56'           ],
-       [ '1 3/8'        ],
-       [ '4 7/8'        ],
-       [ '2,000 1/6'    ],
-       [ '4 1/8'        ],
-       [ '-4 1/8'       ],
-       [ '−5 1/8'   ],
-       [ '56 45/500'    ],
-       [ '56 100/500'   ],
-       [ '100 / 500'    ]
-];
-var fractionsAsc = [
-       [ '−5 1/8'   ],
-       [ '-4 1/8'       ],
-       [ '100 / 500'    ],
-       [ '1 3/8'        ],
-       [ '4 1/8'        ],
-       [ '4 7/8'        ],
-       [ '56'           ],
-       [ '56 45/500'    ],
-       [ '56 100/500'   ],
-       [ '2,000 1/6'    ]
-];
-
-tableTest( 'sort fractional numbers in all sorts and forms (ascending)',
-        ['Fractional numbers'], fractions, fractionsAsc,
-        function( $table ) {
-                $table.tablesorter();
-                $table.find( '.headerSort:eq(0)' ).click();
-        }
-);
-
-tableTest( 'sort fractional numbers in all sorts and forms (descending)',
-        ['Fractional numbers'], fractions, reversed(fractionsAsc),
-        function( $table ) {
-                $table.tablesorter();
-                $table.find( '.headerSort:eq(0)' ).click().click();
-        }
-);
-
 test( 'bug 32888 - Tables inside a tableheader cell', function() {
        expect(2);