MediaWiki:Common.js
From Medivia Online Wiki
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
$(document).ready(function () {
$('.map-toggle').on('click', function () {
const mapId = $(this).data('mapid');
const container = $('#mw-customcollapsible-' + mapId);
// Only load once
if (container.data('loaded')) return;
const x = container.data('x');
const y = container.data('y');
const z = container.data('z');
const zoom = container.data('zoom');
const width = container.data('width');
const height = container.data('height');
// Build mapper tag
const mapperTag = `{{#mapper:${x}|${y}|${z}|${zoom}|${width}|${height}}}`;
// Ask the server to render the parser function
// (Requires a parser API module)
new mw.Api().post({
action: 'parse',
text: mapperTag,
prop: 'text'
}).done(function (data) {
const html = data.parse.text['*'];
container.find('.map-placeholder').replaceWith(html);
container.data('loaded', true);
});
});
});