r113122 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113121‎ | r113122 | r113123 >
Date:10:17, 6 March 2012
Author:hashar
Status:ok (Comments)
Tags:
Comment:
rv table sorting of IP and fraction

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".
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.20 (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.tablesorter.js (modified) (history)
  • /trunk/phase3/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
@@ -236,38 +236,6 @@
237237 ['204.204.132.158'],
238238 ['247.240.82.209']
239239 ];
240 -var ipv4CIDR = [
241 - // Some randomly generated fake IPs
242 - ['45.238.27.109/36'],
243 - ['170.38.91.162/36'],
244 - ['247.240.82.209/36'],
245 - ['204.204.132.158/24'],
246 - ['170.38.91.162/24']
247 -];
248 -var ipv4CIDRSorted = [
249 - // Sort order should go octet by octet
250 - ['45.238.27.109/36'],
251 - ['170.38.91.162/24'],
252 - ['170.38.91.162/36'],
253 - ['204.204.132.158/24'],
254 - ['247.240.82.209/36']
255 -];
256 -var ipv4Mixed = [
257 - // Some randomly generated fake IPs
258 - ['45.238.27.109'],
259 - ['170.38.91.162'],
260 - ['247.240.82.209'],
261 - ['204.204.132.158/24'],
262 - ['170.38.91.162/24']
263 -];
264 -var ipv4MixedSorted = [
265 - // Sort order should go octet by octet
266 - ['45.238.27.109'],
267 - ['170.38.91.162'],
268 - ['170.38.91.162/24'],
269 - ['204.204.132.158/24'],
270 - ['247.240.82.209']
271 -];
272240
273241 tableTest(
274242 'Bug 17141: IPv4 address sorting',
@@ -289,28 +257,7 @@
290258 $table.find( '.headerSort:eq(0)' ).click().click();
291259 }
292260 );
293 -tableTest(
294 - 'Bug 34475: IPv4/CIDR address sorting',
295 - ['IP'],
296 - ipv4CIDR,
297 - ipv4CIDRSorted,
298 - function( $table ) {
299 - $table.tablesorter();
300 - $table.find( '.headerSort:eq(0)' ).click();
301 - }
302 -);
303261
304 -tableTest(
305 - 'Bug 34475: Mixed IPv4 and IP/CIDR address sorting',
306 - ['IP'],
307 - ipv4Mixed,
308 - ipv4MixedSorted,
309 - function( $table ) {
310 - $table.tablesorter();
311 - $table.find( '.headerSort:eq(0)' ).click();
312 - }
313 -);
314 -
315262 var umlautWords = [
316263 // Some words with Umlauts
317264 ['Günther'],
@@ -575,47 +522,6 @@
576523 );
577524 // TODO add numbers sorting tests for bug 8115 with a different language
578525
579 -var fractions = [
580 - [ '56' ],
581 - [ '1 3/8' ],
582 - [ '4 7/8' ],
583 - [ '2,000 1/6' ],
584 - [ '4 1/8' ],
585 - [ '-4 1/8' ],
586 - [ '−5 1/8' ],
587 - [ '56 45/500' ],
588 - [ '56 100/500' ],
589 - [ '100 / 500' ]
590 -];
591 -var fractionsAsc = [
592 - [ '−5 1/8' ],
593 - [ '-4 1/8' ],
594 - [ '100 / 500' ],
595 - [ '1 3/8' ],
596 - [ '4 1/8' ],
597 - [ '4 7/8' ],
598 - [ '56' ],
599 - [ '56 45/500' ],
600 - [ '56 100/500' ],
601 - [ '2,000 1/6' ]
602 -];
603 -
604 -tableTest( 'sort fractional numbers in all sorts and forms (ascending)',
605 - ['Fractional numbers'], fractions, fractionsAsc,
606 - function( $table ) {
607 - $table.tablesorter();
608 - $table.find( '.headerSort:eq(0)' ).click();
609 - }
610 -);
611 -
612 -tableTest( 'sort fractional numbers in all sorts and forms (descending)',
613 - ['Fractional numbers'], fractions, reversed(fractionsAsc),
614 - function( $table ) {
615 - $table.tablesorter();
616 - $table.find( '.headerSort:eq(0)' ).click().click();
617 - }
618 -);
619 -
620526 test( 'bug 32888 - Tables inside a tableheader cell', function() {
621527 expect(2);
622528
Index: trunk/phase3/RELEASE-NOTES-1.20
@@ -19,9 +19,7 @@
2020 preference for the non-default skin to look at something using the default skin.
2121 * (bug 31417) New ID mw-content-text around the actual page text, without categories,
2222 contentSub, ... The same div often also contains the class mw-content-ltr/rtl.
23 -* (bug 34475) Add support for IP/CIDR notation to tablesorter
2423 * (bug 27619) Remove preference option to display broken links as link?
25 -* (bug 15404) Add support for sorting fractions in jquery.tablesorter
2624 * (bug 34896) Update jQuery JSON plugin to v2.3 (2011-09-17)
2725
2826 === Bug fixes in 1.20 ===
Index: trunk/phase3/resources/jquery/jquery.tablesorter.js
@@ -402,13 +402,12 @@
403403 digits.push( $.escapeRE( localised[i] ) );
404404 }
405405 }
406 - ts.digitClass = '[' + digits.join( '', digits ) + ']';
 406+ var digitClass = '[' + digits.join( '', digits ) + ']';
407407
408408 // We allow a trailing percent sign, which we just strip. This works fine
409409 // if percents and regular numbers aren't being mixed.
410410 ts.numberRegex = new RegExp("^(" + "[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?" + // Fortran-style scientific
411 - "|" + "[-+\u2212]?" + ts.digitClass + "+[\\s\\xa0]*%?" + // Generic localised
412 - "|([-+\u2212]?" + ts.digitClass + "+[\\s\\xa0]+)*" + ts.digitClass + "+[\\s\\xa0]*[\\/][\\s\\xa0]*" + ts.digitClass + "+" + // Fractions
 411+ "|" + "[-+\u2212]?" + digitClass + "+[\\s\\xa0]*%?" + // Generic localised
413412 ")$", "i");
414413 }
415414
@@ -485,7 +484,7 @@
486485 }
487486 ts.rgx = {
488487 IPAddress: [
489 - new RegExp( /^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}(\/\d{1,3})?$/)
 488+ new RegExp( /^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/)
490489 ],
491490 currency: [
492491 new RegExp( /^[£$€?.]/),
@@ -503,9 +502,6 @@
504503 ],
505504 time: [
506505 new RegExp( /^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/)
507 - ],
508 - fractions: [
509 - new RegExp( "^(?:([-+\u2212]?" + ts.digitClass + "+)[\\s\\xa0]+)*(" + ts.digitClass + "+)[\\s\\xa0]*[\\/][\\s\\xa0]*(" + ts.digitClass + "+)" )
510506 ]
511507 };
512508 }
@@ -771,15 +767,9 @@
772768 },
773769 format: function( s ) {
774770 var a = s.split( '.' ),
775 - r = '';
776 - if( a.length == 4 ) {
777 - var cidr = a[3].split('/');
778 - if (cidr.length > 1 ) {
779 - a[3] = cidr[0];
780 - a[4] = cidr[1];
781 - } else a[4] = '000';
782 - }
783 - for ( var i = 0; i < a.length; i++ ) {
 771+ r = '',
 772+ l = a.length;
 773+ for ( var i = 0; i < l; i++ ) {
784774 var item = a[i];
785775 if ( item.length == 1 ) {
786776 r += '00' + item;
@@ -913,19 +903,6 @@
914904 return $.tablesorter.numberRegex.test( $.trim( s ));
915905 },
916906 format: function( s ) {
917 - var values = ts.rgx.fractions[0].exec($.trim(s));
918 - if( values != null ) {
919 - // A fraction
920 - var retVal = 0;
921 - var decimal = $.tablesorter.formatDigit(values[2]) / $.tablesorter.formatDigit(values[3]);
922 - if( values[1] != undefined ) {
923 - retVal = $.tablesorter.formatDigit(values[1]);
924 - }
925 - if( !isNaN(decimal) && isFinite(decimal) ) {
926 - retVal += decimal;
927 - }
928 - return retVal;
929 - }
930907 return $.tablesorter.formatDigit(s);
931908 },
932909 type: 'numeric'

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111829Add support to tablesorter to handle IP/CIDR notation...hartman14:35, 18 February 2012
r111884Add support for sorting fractions in jquery.tablesorter...hartman19:56, 19 February 2012

Comments

#Comment by TheDJ (talk | contribs)   10:54, 6 March 2012

Reopened the bug tickets.

#Comment by Hashar (talk | contribs)   10:54, 6 March 2012

Thanks!

Status & tagging log