MediaWiki:Gadget-cs.js: Difference between revisions

From Tardis Wiki, the free Doctor Who reference
No edit summary
No edit summary
Line 1: Line 1:
mw.hook( 'wikipage.content' ).add( function ( $content ) {
mw.hook( 'wikipage.content' ).add( function ( $content ) {
$('.cs-js').each(function(){ /* 'this' means the element */
$('.cs-js').each(function(){ /* 'this' means the element */
var preview = new Morebits.wiki.preview(this);
/* adapted from https://www.mediawiki.org/wiki/API%3aParsing_wikitext#MediaWiki_JS under MIT license */
preview.beginRender("{{cite source|Rose (TV story)}}");
    var params = {
action: 'parse',
text: '{{cite source|Rose (TV story)}}',
format: 'json'
};
var api = new mw.Api();
api.get(params).done(function(data) {
    this.innerHTML = data;
});
});
});
} );
} );

Revision as of 22:23, 7 April 2024

mw.hook( 'wikipage.content' ).add( function ( $content ) {
	$('.cs-js').each(function(){ /* 'this' means the element */
		/* adapted from https://www.mediawiki.org/wiki/API%3aParsing_wikitext#MediaWiki_JS under MIT license */
		    var params = {
				action: 'parse',
				text: '{{cite source|Rose (TV story)}}',
				format: 'json'
			};
			var api = new mw.Api();
			api.get(params).done(function(data) {
			    this.innerHTML = data;
			});
	});
} );