mediawiki-js
v0.1.0
Published
Ultra-light, vanilla JavaScript wrapper of Mediawiki API for use in the browser
Downloads
4
Readme
mediawiki-js
Ultra-light, vanilla JavaScript wrapper of Mediawiki API for use in the browser
Simple one-shot usage:
MediaWikiJS('https://en.wikipedia.org', {action: 'query', prop: 'revisions', titles: 'Main Page'}, function (data) {
var pages = data.query.pages;
alert('Last edited by: ' + pages[Object.keys(pages)[0]].revisions[0].user);
});
Simple reusable usage:
var mwjs = MediaWikiJS('https://en.wikipedia.org');
mwjs.send({action: 'query', prop: 'revisions', titles: 'Main Page'}, function (data) {
var pages = data.query.pages;
alert('Last edited by: ' + pages[Object.keys(pages)[0]].revisions[0].user);
});
Configuration object:
var mwjs = MediaWikiJS({baseURL: 'https://en.wikipedia.org', apiPath: '/w/api.php'});
mwjs.send({action: 'query', prop: 'revisions', titles: 'Main Page'}, function (data) {
var pages = data.query.pages;
alert('Last edited by: ' + pages[Object.keys(pages)[0]].revisions[0].user);
});