MediaWiki:Gadget-cs.js: Difference between revisions
From Tardis Wiki, the free Doctor Who reference
Bongolium500 (talk | contribs) No edit summary |
Bongolium500 (talk | contribs) No edit summary |
||
Line 5: | Line 5: | ||
var params = { | var params = { | ||
action: 'parse', | action: 'parse', | ||
text: '{{#invoke:cite source|generateCollapsibleTextFromJSON|' + | text: '{{#invoke:cite source|generateCollapsibleTextFromJSON|' + $(currentEl).children(".cs-d")[0].innerHTML + ' }}', | ||
format: 'json' | format: 'json' | ||
}; | }; |
Revision as of 17:26, 9 April 2024
mw.hook( 'wikipage.content' ).add( function ( $content ) {
$('.cs-l').each(function(){ /* 'this' means the element */
/* adapted from https://www.mediawiki.org/wiki/API%3aParsing_wikitext#MediaWiki_JS under MIT license */
var currentEl = this;
var params = {
action: 'parse',
text: '{{#invoke:cite source|generateCollapsibleTextFromJSON|' + $(currentEl).children(".cs-d")[0].innerHTML + ' }}',
format: 'json'
};
var api = new mw.Api();
api.get(params).done(function(data) {
currentEl.innerHTML = data.parse.text['*'];
});
});
} );