r89998 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89997‎ | r89998 | r89999 >
Date:19:08, 13 June 2011
Author:neilk
Status:ok
Tags:
Comment:
revert r89966, also remove terabytes so we can use system core messages, also fix algorithm so it doesnt go over GB
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizard.i18n.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardHooks.php (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.units.js (modified) (history)
  • /trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js
@@ -1,35 +1,35 @@
22 ( function( mw ) {
33
 4+ // matches the current system
45 mediaWiki.messages.set( {
5 - "size-bytes": "$1 bytes",
6 - "size-kilobytes": "$1 K",
 6+ "size-bytes": "$1 B",
 7+ "size-kilobytes": "$1 KB",
78 "size-megabytes": "$1 MB",
8 - "size-gigabytes": "$1 GB",
9 - "size-terabytes": "$1 TB"
 9+ "size-gigabytes": "$1 GB"
1010 } );
1111
1212 window.gM = mw.language.getMessageFunction();
1313
1414 // assumes english language selected
1515 describe( "mw.units.bytes", function() {
16 - it( "should say 0 bytes", function() {
17 - expect( mw.units.bytes( 0 ) ).toEqual( '0 bytes' );
 16+ it( "should say 0 B", function() {
 17+ expect( mw.units.bytes( 0 ) ).toEqual( '0 B' );
1818 } );
1919
20 - it( "should say bytes", function() {
21 - expect( mw.units.bytes( 7 ) ).toEqual( '7 bytes' );
 20+ it( "should say B", function() {
 21+ expect( mw.units.bytes( 7 ) ).toEqual( '7 B' );
2222 } );
2323
24 - it( "should say bytes (900)", function() {
25 - expect( mw.units.bytes( 900 ) ).toEqual( '900 bytes' );
 24+ it( "should say B (900)", function() {
 25+ expect( mw.units.bytes( 900 ) ).toEqual( '900 B' );
2626 } );
2727
2828 it( "should say 1023 = 1023 bytes", function() {
29 - expect( mw.units.bytes( 1023 ) ).toEqual( '1023 bytes' );
 29+ expect( mw.units.bytes( 1023 ) ).toEqual( '1023 B' );
3030 } );
3131
32 - it( "should say 1024 = 1K", function() {
33 - expect( mw.units.bytes( 1024 ) ).toEqual( '1 K' );
 32+ it( "should say 1024 = 1 KB", function() {
 33+ expect( mw.units.bytes( 1024 ) ).toEqual( '1 KB' );
3434 } );
3535
3636 it( "should say MB", function() {
@@ -40,15 +40,10 @@
4141 expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 ) ).toEqual( '3.14 GB' );
4242 } );
4343
44 - it( "should say TB", function() {
45 - expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 * 1024 ) ).toEqual( '3.14 TB' );
 44+ it( "should say GB even when much larger", function() {
 45+ expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 * 1024 ) ).toEqual( '3216.99 GB' );
4646 } );
4747
48 - it( "should say TB even when much larger", function() {
49 - expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 * 1024 * 1024 ) ).toEqual( '3216.99 TB' );
50 - } );
51 -
52 -
5348 it( "should round up", function() {
5449 expect( mw.units.bytes( 1.42857 * 1024 * 1024 * 1024 ) ).toEqual( '1.43 GB' );
5550 } );
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php
@@ -336,11 +336,10 @@
337337 'mwe-upwiz-feedback-error1',
338338 'mwe-upwiz-feedback-error2',
339339 'mwe-upwiz-feedback-error3',
340 - 'mwe-upwiz-size-terabytes',
341 - 'mwe-upwiz-size-gigabytes',
342 - 'mwe-upwiz-size-megabytes',
343 - 'mwe-upwiz-size-kilobytes',
344 - 'mwe-upwiz-size-bytes'
 340+ 'size-gigabytes',
 341+ 'size-megabytes',
 342+ 'size-kilobytes',
 343+ 'size-bytes'
345344 ),
346345 'group' => 'ext.uploadWizard'
347346 ),
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -268,15 +268,7 @@
269269 'mwe-upwiz-feedback-adding' => 'Adding feedback to page...',
270270 'mwe-upwiz-feedback-error1' => 'Error: Unrecognized result from API',
271271 'mwe-upwiz-feedback-error2' => 'Error: Edit failed',
272 - 'mwe-upwiz-feedback-error3' => 'Error: No response from API',
273 -
274 - // similar to mediawiki.special.upload.js
275 - 'mwe-upwiz-size-terabytes' => '$1 TB',
276 - 'mwe-upwiz-size-gigabytes' => '$1 GB',
277 - 'mwe-upwiz-size-megabytes' => '$1 MB',
278 - 'mwe-upwiz-size-kilobytes' => '$1 K',
279 - 'mwe-upwiz-size-bytes' => '$1 bytes'
280 -
 272+ 'mwe-upwiz-feedback-error3' => 'Error: No response from API'
281273
282274 );
283275
Index: trunk/extensions/UploadWizard/resources/mw.units.js
@@ -1,12 +1,6 @@
22 ( function( mw ) {
33
4 - var scaleMsgKeys = [
5 - 'mwe-upwiz-size-bytes',
6 - 'mwe-upwiz-size-kilobytes',
7 - 'mwe-upwiz-size-megabytes',
8 - 'mwe-upwiz-size-gigabytes',
9 - 'mwe-upwiz-size-terabytes'
10 - ];
 4+ var scaleMsgKeys = [ 'size-bytes', 'size-kilobytes', 'size-megabytes', 'size-gigabytes' ];
115
126 mw.units = {
137
@@ -21,7 +15,7 @@
2216 */
2317 bytes: function ( size ) {
2418 var i = 0;
25 - while ( size >= 1024 && i < scaleMsgKeys.length ) {
 19+ while ( size >= 1024 && i < scaleMsgKeys.length - 1 ) {
2620 size /= 1024.0;
2721 i++;
2822 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89916tests for pubsub and units.bytesneilk05:20, 12 June 2011
r89917messages for mw.units.bytesneilk05:22, 12 June 2011
r89966for bytes function, avoid conflict with similar strings in coreneilk14:30, 13 June 2011

Status & tagging log