Difference between revisions of "MediaWiki:Common.js"

From Medivia Online Wiki
Tag: Reverted
(Blanked the page)
Tags: Blanking Manual revert
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
$(function () {


    $('.map-toggle').on('click', function () {
        console.log("Toggle clicked, loading map...");
        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");
        });
    });
});

Latest revision as of 20:17, 17 January 2026