http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89998
Revision: 89998
Author: neilk
Date: 2011-06-13 19:08:41 +0000 (Mon, 13 Jun 2011)
Log Message:
-----------
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
trunk/extensions/UploadWizard/UploadWizardHooks.php
trunk/extensions/UploadWizard/resources/mw.units.js
trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js
Modified: trunk/extensions/UploadWizard/UploadWizard.i18n.php
===================================================================
--- trunk/extensions/UploadWizard/UploadWizard.i18n.php 2011-06-13 19:05:49 UTC
(rev 89997)
+++ trunk/extensions/UploadWizard/UploadWizard.i18n.php 2011-06-13 19:08:41 UTC
(rev 89998)
@@ -268,15 +268,7 @@
'mwe-upwiz-feedback-adding' => 'Adding feedback to page...',
'mwe-upwiz-feedback-error1' => 'Error: Unrecognized result from API',
'mwe-upwiz-feedback-error2' => 'Error: Edit failed',
- 'mwe-upwiz-feedback-error3' => 'Error: No response from API',
-
- // similar to mediawiki.special.upload.js
- 'mwe-upwiz-size-terabytes' => '$1 TB',
- 'mwe-upwiz-size-gigabytes' => '$1 GB',
- 'mwe-upwiz-size-megabytes' => '$1 MB',
- 'mwe-upwiz-size-kilobytes' => '$1 K',
- 'mwe-upwiz-size-bytes' => '$1 bytes'
-
+ 'mwe-upwiz-feedback-error3' => 'Error: No response from API'
);
Modified: trunk/extensions/UploadWizard/UploadWizardHooks.php
===================================================================
--- trunk/extensions/UploadWizard/UploadWizardHooks.php 2011-06-13 19:05:49 UTC
(rev 89997)
+++ trunk/extensions/UploadWizard/UploadWizardHooks.php 2011-06-13 19:08:41 UTC
(rev 89998)
@@ -336,11 +336,10 @@
'mwe-upwiz-feedback-error1',
'mwe-upwiz-feedback-error2',
'mwe-upwiz-feedback-error3',
- 'mwe-upwiz-size-terabytes',
- 'mwe-upwiz-size-gigabytes',
- 'mwe-upwiz-size-megabytes',
- 'mwe-upwiz-size-kilobytes',
- 'mwe-upwiz-size-bytes'
+ 'size-gigabytes',
+ 'size-megabytes',
+ 'size-kilobytes',
+ 'size-bytes'
),
'group' => 'ext.uploadWizard'
),
Modified: trunk/extensions/UploadWizard/resources/mw.units.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.units.js 2011-06-13 19:05:49 UTC
(rev 89997)
+++ trunk/extensions/UploadWizard/resources/mw.units.js 2011-06-13 19:08:41 UTC
(rev 89998)
@@ -1,12 +1,6 @@
( function( mw ) {
- var scaleMsgKeys = [
- 'mwe-upwiz-size-bytes',
- 'mwe-upwiz-size-kilobytes',
- 'mwe-upwiz-size-megabytes',
- 'mwe-upwiz-size-gigabytes',
- 'mwe-upwiz-size-terabytes'
- ];
+ var scaleMsgKeys = [ 'size-bytes', 'size-kilobytes', 'size-megabytes',
'size-gigabytes' ];
mw.units = {
@@ -21,7 +15,7 @@
*/
bytes: function ( size ) {
var i = 0;
- while ( size >= 1024 && i < scaleMsgKeys.length ) {
+ while ( size >= 1024 && i < scaleMsgKeys.length - 1 ) {
size /= 1024.0;
i++;
}
Modified: trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js
===================================================================
--- trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js
2011-06-13 19:05:49 UTC (rev 89997)
+++ trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js
2011-06-13 19:08:41 UTC (rev 89998)
@@ -1,35 +1,35 @@
( function( mw ) {
+ // matches the current system
mediaWiki.messages.set( {
- "size-bytes": "$1 bytes",
- "size-kilobytes": "$1 K",
+ "size-bytes": "$1 B",
+ "size-kilobytes": "$1 KB",
"size-megabytes": "$1 MB",
- "size-gigabytes": "$1 GB",
- "size-terabytes": "$1 TB"
+ "size-gigabytes": "$1 GB"
} );
window.gM = mw.language.getMessageFunction();
// assumes english language selected
describe( "mw.units.bytes", function() {
- it( "should say 0 bytes", function() {
- expect( mw.units.bytes( 0 ) ).toEqual( '0 bytes' );
+ it( "should say 0 B", function() {
+ expect( mw.units.bytes( 0 ) ).toEqual( '0 B' );
} );
- it( "should say bytes", function() {
- expect( mw.units.bytes( 7 ) ).toEqual( '7 bytes' );
+ it( "should say B", function() {
+ expect( mw.units.bytes( 7 ) ).toEqual( '7 B' );
} );
- it( "should say bytes (900)", function() {
- expect( mw.units.bytes( 900 ) ).toEqual( '900 bytes' );
+ it( "should say B (900)", function() {
+ expect( mw.units.bytes( 900 ) ).toEqual( '900 B' );
} );
it( "should say 1023 = 1023 bytes", function() {
- expect( mw.units.bytes( 1023 ) ).toEqual( '1023 bytes'
);
+ expect( mw.units.bytes( 1023 ) ).toEqual( '1023 B' );
} );
- it( "should say 1024 = 1K", function() {
- expect( mw.units.bytes( 1024 ) ).toEqual( '1 K' );
+ it( "should say 1024 = 1 KB", function() {
+ expect( mw.units.bytes( 1024 ) ).toEqual( '1 KB' );
} );
it( "should say MB", function() {
@@ -40,15 +40,10 @@
expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 )
).toEqual( '3.14 GB' );
} );
- it( "should say TB", function() {
- expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 *
1024 ) ).toEqual( '3.14 TB' );
+ it( "should say GB even when much larger", function() {
+ expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 *
1024 ) ).toEqual( '3216.99 GB' );
} );
- it( "should say TB even when much larger", function() {
- expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 *
1024 * 1024 ) ).toEqual( '3216.99 TB' );
- } );
-
-
it( "should round up", function() {
expect( mw.units.bytes( 1.42857 * 1024 * 1024 * 1024 )
).toEqual( '1.43 GB' );
} );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs