Difference between revisions of "MediaWiki:Common.js"
From Medivia Online Wiki
(Blanked the page) Tags: Blanking Manual revert |
Tag: Reverted |
||
| Line 1: | Line 1: | ||
$(function () { | |||
$('.map-toggle').on('click', function () { | |||
var mapId = $(this).data('mapid'); | |||
var box = $('#mw-customcollapsible-' + mapId); | |||
// Already loaded? | |||
if (box.data('loaded')) return; | |||
var x = box.data('x'); | |||
var y = box.data('y'); | |||
var z = box.data('z'); | |||
var zoom = box.data('zoom'); | |||
var w = box.data('width'); | |||
var h = box.data('height'); | |||
// Build mapper tag | |||
var code = `{{#mapper:${x}|${y}|${z}|${zoom}|${w}|${h}}}`; | |||
// Ask MW API to parse it into HTML | |||
new mw.Api().post({ | |||
action: 'parse', | |||
text: code, | |||
prop: 'text' | |||
}).done(function (data) { | |||
var html = data.parse.text['*']; | |||
box.find('.map-placeholder').replaceWith(html); | |||
box.attr('data-loaded', 1); | |||
}); | |||
}); | |||
}); | |||
Revision as of 13:36, 25 November 2025
$(function () {
$('.map-toggle').on('click', function () {
var mapId = $(this).data('mapid');
var box = $('#mw-customcollapsible-' + mapId);
// Already loaded?
if (box.data('loaded')) return;
var x = box.data('x');
var y = box.data('y');
var z = box.data('z');
var zoom = box.data('zoom');
var w = box.data('width');
var h = box.data('height');
// Build mapper tag
var code = `{{#mapper:${x}|${y}|${z}|${zoom}|${w}|${h}}}`;
// Ask MW API to parse it into HTML
new mw.Api().post({
action: 'parse',
text: code,
prop: 'text'
}).done(function (data) {
var html = data.parse.text['*'];
box.find('.map-placeholder').replaceWith(html);
box.attr('data-loaded', 1);
});
});
});