User:BPositive/prepare.js

mw.loader.using( ['jquery.ui.dialog', 'mediawiki.api'], function {	//Function to show the content in a dialog box	function renderContentDialog ( content ) {		var $dialog = $( '  ' )			.html ( content )			.dialog ({ autoOpen: true, title: 'Text after preparing the page ' + wgPageName + " for translation", width: '70%', modal: true });	}	///w/api.php?action=query&prop=revisions&format=json&rvprop=content&rvlimit=1&titles=User%3ABPositive	//Function to prepare the page for translation   function prepareForTranslation{	    var api = new mw.Api;	    //This api call returns the raw source text of the page	    api.get ({ action:'query', prop: 'revisions', format: 'json', rvprop: 'content', rvlimit: '1', titles: wgPageName }).done ( function( data ) { var pageContent = data['query']['pages'][wgArticleId]['revisions'][0]['*']; pageContent.replace('\\n', ' '); renderContentDialog(pageContent); });   }    $(document).ready( function { // Add a link to the toolbox var link = mw.util.addPortletLink(			'p-tb',			'#',			'Prepare',			't-preparetranslation',			'Prepare the page for translation',			null,			'#t-whatlinkshere'		); $(link).click( function( e ) {			// Avoid the browser going to '#'			e.preventDefault;			prepareForTranslation;		}); }); });