From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- .../modules/jquery.wikiEditor.preview.js | 50 ++++++++-------------- 1 file changed, 19 insertions(+), 31 deletions(-) (limited to 'extensions/WikiEditor/modules/jquery.wikiEditor.preview.js') diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js b/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js index f0665220..436b0720 100644 --- a/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js +++ b/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js @@ -33,6 +33,8 @@ fn: { * @param config Configuration object to create module from */ create: function ( context ) { + var api = new mw.Api(); + if ( 'initialized' in context.modules.preview ) { return; } @@ -53,18 +55,12 @@ fn: { } context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ).empty(); context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).show(); - $.ajax( { - url: mw.util.wikiScript( 'api' ), - type: 'POST', - dataType: 'json', - data: { - format: 'json', - action: 'parse', - title: mw.config.get( 'wgPageName' ), - text: wikitext, - prop: 'text|modules', - pst: '' - } + api.post( { + action: 'parse', + title: mw.config.get( 'wgPageName' ), + text: wikitext, + prop: 'text|modules', + pst: '' } ).done( function ( data ) { if ( !data.parse || !data.parse.text || data.parse.text['*'] === undefined ) { return; @@ -74,6 +70,7 @@ fn: { context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).hide(); context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ) .html( data.parse.text['*'] ) + .append( '
' ) .find( 'a:not([href^=#])' ) .click( false ); @@ -101,21 +98,14 @@ fn: { context.$changesTab.find( '.wikiEditor-preview-loading' ).show(); // Call the API. First PST the input, then diff it - $.ajax( { - url: mw.util.wikiScript( 'api' ), - type: 'POST', - dataType: 'json', - data: { - format: 'json', - action: 'parse', - title: mw.config.get( 'wgPageName' ), - onlypst: '', - text: wikitext - } + api.post( { + action: 'parse', + title: mw.config.get( 'wgPageName' ), + onlypst: '', + text: wikitext } ).done( function ( data ) { try { var postdata2 = { - format: 'json', action: 'query', indexpageids: '', prop: 'revisions', @@ -128,19 +118,17 @@ fn: { postdata2.rvsection = section; } - $.ajax( { - url: mw.util.wikiScript( 'api' ), - type: 'POST', - dataType: 'json', - data: postdata2 - } ).done( function ( data ) { + api.post( postdata2 ) + .done( function ( data ) { // Add diff CSS mw.loader.load( 'mediawiki.action.history.diff' ); try { var diff = data.query.pages[data.query.pageids[0]] .revisions[0].diff['*']; - context.$changesTab.find( 'table.diff tbody' ).html( diff ); + context.$changesTab.find( 'table.diff tbody' ) + .html( diff ) + .append( '
' ); context.modules.preview.changesText = wikitext; } catch ( e ) { // "data.blah is undefined" error, ignore -- cgit v1.2.3-54-g00ecf