Difference between revisions of "MediaWiki:Common.js"

From Medivia Online Wiki
(Blanked the page)
Tags: Blanking Manual revert
Tag: Reverted
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);
        });
    });
});

Revision as of 13:32, 25 November 2025

$(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);
        });
    });

});