diff options
Diffstat (limited to 'MLEB/Translate/resources/js/ext.translate.special.pagepreparation.js')
-rw-r--r-- | MLEB/Translate/resources/js/ext.translate.special.pagepreparation.js | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/MLEB/Translate/resources/js/ext.translate.special.pagepreparation.js b/MLEB/Translate/resources/js/ext.translate.special.pagepreparation.js index 03c4385d..b32008fe 100644 --- a/MLEB/Translate/resources/js/ext.translate.special.pagepreparation.js +++ b/MLEB/Translate/resources/js/ext.translate.special.pagepreparation.js @@ -45,7 +45,9 @@ obj = data.query.pages[ page ]; } - diff = obj.revisions[ 0 ].diff[ '*' ]; + if ( obj !== undefined ) { + diff = obj.revisions[ 0 ].diff[ '*' ]; + } return diff; } ); @@ -91,7 +93,7 @@ aliases.push( 'category' ); for ( i = 0; i < aliases.length; i++ ) { - aliases[ i ] = mw.RegExp.escape( aliases[ i ] ); + aliases[ i ] = mw.util.escapeRegExp( aliases[ i ] ); } aliasList = aliases.join( '|' ); @@ -360,11 +362,11 @@ var pageContent, $input = $( '#page' ); - $( '#action-cancel' ).click( function () { + $( '#action-cancel' ).on( 'click', function () { document.location.reload( true ); } ); - $( '#action-save' ).click( function () { + $( '#action-save' ).on( 'click', function () { var pageName, pageUrl = ''; @@ -383,11 +385,11 @@ } ); } ); - $( '#action-prepare' ).click( function () { - var pageName, messageDiv = $( '.messageDiv' ); + $( '#action-prepare' ).on( 'click', function () { + var pageName, $messageDiv = $( '.messageDiv' ); pageName = $input.val().trim(); - messageDiv.hide(); + $messageDiv.hide(); if ( pageName === '' ) { // eslint-disable-next-line no-alert alert( mw.msg( 'pp-pagename-missing' ) ); @@ -407,15 +409,20 @@ pageContent = postPreparationCleanup( pageContent ); pageContent = pageContent.trim(); getDiff( pageName, pageContent ).done( function ( diff ) { + if ( diff === undefined ) { + $messageDiv.text( mw.msg( 'pp-diff-error' ) ).show(); + return; + } + $( '.diff tbody' ).append( diff ); $( '.divDiff' ).show( 'fast' ); if ( diff !== '' ) { - messageDiv.text( mw.msg( 'pp-prepare-message' ) ).show(); + $messageDiv.text( mw.msg( 'pp-prepare-message' ) ).show(); $( '#action-prepare' ).hide(); $( '#action-save' ).show(); $( '#action-cancel' ).show(); } else { - messageDiv.text( mw.msg( 'pp-already-prepared-message' ) ).show(); + $messageDiv.text( mw.msg( 'pp-already-prepared-message' ) ).show(); } } ); } ); |