Index: trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js |
— | — | @@ -1,35 +1,35 @@ |
2 | 2 | ( function( mw ) { |
3 | 3 | |
| 4 | + // matches the current system |
4 | 5 | mediaWiki.messages.set( { |
5 | | - "size-bytes": "$1 bytes", |
6 | | - "size-kilobytes": "$1 K", |
| 6 | + "size-bytes": "$1 B", |
| 7 | + "size-kilobytes": "$1 KB", |
7 | 8 | "size-megabytes": "$1 MB", |
8 | | - "size-gigabytes": "$1 GB", |
9 | | - "size-terabytes": "$1 TB" |
| 9 | + "size-gigabytes": "$1 GB" |
10 | 10 | } ); |
11 | 11 | |
12 | 12 | window.gM = mw.language.getMessageFunction(); |
13 | 13 | |
14 | 14 | // assumes english language selected |
15 | 15 | 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' ); |
18 | 18 | } ); |
19 | 19 | |
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' ); |
22 | 22 | } ); |
23 | 23 | |
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' ); |
26 | 26 | } ); |
27 | 27 | |
28 | 28 | 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' ); |
30 | 30 | } ); |
31 | 31 | |
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' ); |
34 | 34 | } ); |
35 | 35 | |
36 | 36 | it( "should say MB", function() { |
— | — | @@ -40,15 +40,10 @@ |
41 | 41 | expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 ) ).toEqual( '3.14 GB' ); |
42 | 42 | } ); |
43 | 43 | |
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' ); |
46 | 46 | } ); |
47 | 47 | |
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 | | - |
53 | 48 | it( "should round up", function() { |
54 | 49 | expect( mw.units.bytes( 1.42857 * 1024 * 1024 * 1024 ) ).toEqual( '1.43 GB' ); |
55 | 50 | } ); |
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php |
— | — | @@ -336,11 +336,10 @@ |
337 | 337 | 'mwe-upwiz-feedback-error1', |
338 | 338 | 'mwe-upwiz-feedback-error2', |
339 | 339 | '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' |
345 | 344 | ), |
346 | 345 | 'group' => 'ext.uploadWizard' |
347 | 346 | ), |
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -268,15 +268,7 @@ |
269 | 269 | 'mwe-upwiz-feedback-adding' => 'Adding feedback to page...', |
270 | 270 | 'mwe-upwiz-feedback-error1' => 'Error: Unrecognized result from API', |
271 | 271 | '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' |
281 | 273 | |
282 | 274 | ); |
283 | 275 | |
Index: trunk/extensions/UploadWizard/resources/mw.units.js |
— | — | @@ -1,12 +1,6 @@ |
2 | 2 | ( function( mw ) { |
3 | 3 | |
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' ]; |
11 | 5 | |
12 | 6 | mw.units = { |
13 | 7 | |
— | — | @@ -21,7 +15,7 @@ |
22 | 16 | */ |
23 | 17 | bytes: function ( size ) { |
24 | 18 | var i = 0; |
25 | | - while ( size >= 1024 && i < scaleMsgKeys.length ) { |
| 19 | + while ( size >= 1024 && i < scaleMsgKeys.length - 1 ) { |
26 | 20 | size /= 1024.0; |
27 | 21 | i++; |
28 | 22 | } |