r100413 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100412‎ | r100413 | r100414 >
Date:06:04, 21 October 2011
Author:nikerabbit
Status:resolved (Comments)
Tags:
Comment:
Added a forgotten file
Followup r100345 and Internationalization/#129
Modified paths:
  • /trunk/extensions/Translate/resources/ext.translate.messagetable.js (added) (history)

Diff [purge]

Index: trunk/extensions/Translate/resources/ext.translate.messagetable.js
@@ -0,0 +1,28 @@
 2+jQuery( document ).ready( function( $ ) {
 3+ var $buttons = $( ".mw-translate-messagereviewbutton" );
 4+ $buttons.each( function() {
 5+ var $b = $(this);
 6+ $b.click( function() {
 7+ var successFunction = function( data, textStatus ) {
 8+ console.log( data, textStatus );
 9+ if ( data.error ) {
 10+ var reason = mw.msg( "translate-messagereview-apierror-" + data.error.code );
 11+ $b.val( mw.msg( "translate-messagereview-failure", reason ) );
 12+ } else {
 13+ $b.val( mw.msg( "translate-messagereview-done" ) );
 14+ }
 15+ };
 16+
 17+ var params = {
 18+ action: "translationreview",
 19+ token: $b.data( "token" ),
 20+ revision: $b.data( "revision" ),
 21+ format: "json"
 22+ };
 23+ $b.val( mw.msg( "translate-messagereview-progress" ) );
 24+ $b.prop( "disabled", true );
 25+ $.post( mw.util.wikiScript( "api" ), params, successFunction );
 26+
 27+ } );
 28+ } );
 29+} );
Property changes on: trunk/extensions/Translate/resources/ext.translate.messagetable.js
___________________________________________________________________
Added: svn:eol-style
130 + native

Sign-offs

UserFlagDate
Amire80inspected10:40, 24 October 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r100590console.log should not be in production codenikerabbit09:24, 24 October 2011
r101799Improvements to r100413 based on code review feedback...nikerabbit09:20, 3 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100345Translation review interface...nikerabbit13:58, 20 October 2011

Comments

#Comment by Amire80 (talk | contribs)   10:39, 24 October 2011

unnecessary console.log removed in r100590.

#Comment by Amire80 (talk | contribs)   10:41, 24 October 2011

This should also be reviewed by someone who's better with JS than i am.

#Comment by GICodeWarrior (talk | contribs)   21:50, 2 November 2011

Could be tweaked a bit if you want. This: jQuery( document ).ready( function( $ ) { could be: jQuery( function( $ ) {

This:

 var $buttons = $( ".mw-translate-messagereviewbutton" );
 $buttons.each( function() {
   var $b = $(this);
   $b.click( function() {

Could be:

 $( '.mw-translate-messagereviewbutton' ).click( function() {
   var $b = $(this);

You should also handle HTTP related errors. (Unless it is safe to trust a global handler somewhere else I am unaware of.) $.post( ... ).fail(function() {

 // Message the user in a meaningful way that there was a HTTP/network error.

}); See: http://api.jquery.com/jQuery.post/#jqxhr-object and http://api.jquery.com/jQuery.ajax/#jqXHR

Hope that helps :-)

#Comment by GICodeWarrior (talk | contribs)   21:51, 2 November 2011

sorry, I fail at markup; lets try that again..


Could be tweaked a bit if you want. This:

jQuery( document ).ready( function( $ ) {

Could be:

jQuery( function( $ ) {

This:

var $buttons = $( ".mw-translate-messagereviewbutton" );
$buttons.each( function() {
  var $b = $(this);
  $b.click( function() {

Could be:

$( '.mw-translate-messagereviewbutton' ).click( function() {
  var $b = $(this);

You should also handle HTTP related errors. (Unless it is safe to trust a global handler somewhere else I am unaware of.)

$.post( ... ).fail(function() {
  // Message the user in a meaningful way that there was a HTTP/network error.
});

See: http://api.jquery.com/jQuery.post/#jqxhr-object and http://api.jquery.com/jQuery.ajax/#jqXHR

Hope that helps :-)

#Comment by Nikerabbit (talk | contribs)   09:22, 3 November 2011

It does, thank you.

Status & tagging log