Difference between revisions of "MediaWiki:Common.js"

From Medivia Online Wiki
Tag: Reverted
(Blanked the page)
Tags: Blanking Manual revert
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
$(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);
        });
    });
});

Latest revision as of 20:17, 17 January 2026