Difference between revisions of "MediaWiki:Common.js"
From Medivia Online Wiki
Tag: Reverted |
Tag: Reverted |
||
| Line 3: | Line 3: | ||
$('.map-toggle').on('click', function () { | $('.map-toggle').on('click', function () { | ||
var mapId = $(this). | var mapId = $(this).attr('data-mapid'); | ||
var box = $('#mw-customcollapsible-' + mapId); | var box = $('#mw-customcollapsible-' + mapId); | ||
// Already loaded? | // Already loaded? | ||
if (box. | if (box.attr('data-loaded') === "1") { | ||
return; | |||
} | |||
var x = box. | var x = box.attr('data-x'); | ||
var y = box. | var y = box.attr('data-y'); | ||
var z = box. | var z = box.attr('data-z'); | ||
var zoom = box. | var zoom = box.attr('data-zoom'); | ||
var w = box. | var w = box.attr('data-width'); | ||
var h = box. | var h = box.attr('data-height'); | ||
// Build mapper tag | // Build mapper tag (NO template strings!) | ||
var code = | var code = "{{#mapper:" + | ||
x + "|" + | |||
y + "|" + | |||
z + "|" + | |||
zoom + "|" + | |||
w + "|" + | |||
h + "}}"; | |||
new mw.Api().post({ | new mw.Api().post({ | ||
action: 'parse', | action: 'parse', | ||
| Line 25: | Line 32: | ||
prop: 'text' | prop: 'text' | ||
}).done(function (data) { | }).done(function (data) { | ||
var html = data.parse.text[ | var html = data.parse.text["*"]; | ||
box.find('.map-placeholder').replaceWith(html); | box.find('.map-placeholder').replaceWith(html); | ||
box.attr('data-loaded', 1); | box.attr('data-loaded', "1"); | ||
}); | }); | ||
}); | }); | ||
}); | }); | ||
Revision as of 13:37, 25 November 2025
$(function () {
$('.map-toggle').on('click', function () {
var mapId = $(this).attr('data-mapid');
var box = $('#mw-customcollapsible-' + mapId);
// Already loaded?
if (box.attr('data-loaded') === "1") {
return;
}
var x = box.attr('data-x');
var y = box.attr('data-y');
var z = box.attr('data-z');
var zoom = box.attr('data-zoom');
var w = box.attr('data-width');
var h = box.attr('data-height');
// Build mapper tag (NO template strings!)
var code = "{{#mapper:" +
x + "|" +
y + "|" +
z + "|" +
zoom + "|" +
w + "|" +
h + "}}";
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");
});
});
});