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 2: | Line 2: | ||
$('.cs-js').each(function(){ /* 'this' means the element */ | $('.cs-js').each(function(){ /* 'this' means the element */ | ||
/* adapted from https://www.mediawiki.org/wiki/API%3aParsing_wikitext#MediaWiki_JS under MIT license */ | /* adapted from https://www.mediawiki.org/wiki/API%3aParsing_wikitext#MediaWiki_JS under MIT license */ | ||
var currentEl = this; | |||
var params = { | var params = { | ||
action: 'parse', | action: 'parse', | ||
Line 12: | Line 12: | ||
console.log(text); | console.log(text); | ||
console.log(this); | console.log(this); | ||
currentEl.innerHTML = text; | |||
}); | }); | ||
}); | }); | ||
} ); | } ); |
Revision as of 22:34, 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 currentEl = this;
var params = {
action: 'parse',
text: '{{cite source|Rose (TV story)}}',
format: 'json'
};
var api = new mw.Api();
api.get(params).done(function(text) {
console.log(text);
console.log(this);
currentEl.innerHTML = text;
});
});
} );