"മീഡിയവിക്കി:Common.js" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം

No edit summary
No edit summary
വരി 2: വരി 2:
   OpenStreetMap marker URL fix
   OpenStreetMap marker URL fix
   ============================================================ */
   ============================================================ */
mw.hook('wikipage.content').add(function () {
mw.hook('kartographer.ready').add(function (map) {
     function replaceOSMMarkers(root) {
     if (window.L && L.Icon && L.Icon.Default) {
        var images = root.querySelectorAll('img[src*="tile.openstreetmap.org/v4/marker/"]');
        L.Icon.Default.mergeOptions({
 
            imagePath: 'https://maps.wikimedia.org/v4/marker/'
        images.forEach(function (img) {
            img.src = img.src.replace(
                'https://tile.openstreetmap.org/v4/marker/',
                'https://maps.wikimedia.org/v4/marker/'
            );
         });
         });
     }
     }
});


    // Initial pass
    replaceOSMMarkers(document);
    // Watch for dynamically added images
    var observer = new MutationObserver(function (mutations) {
        mutations.forEach(function (mutation) {
            mutation.addedNodes.forEach(function (node) {
                if (node.nodeType === 1) {
                    replaceOSMMarkers(node);
                }
            });
        });
    });
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
});




"https://schoolwiki.in/മീഡിയവിക്കി:Common.js" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്