Jump to content

User:Vicarage/maptab.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* Use the mechanism from {{GeoGroupTemplate}} to add a map tab to each page */

$(function () {
    if (mw.config.get('wgCanonicalNamespace') == "Special")
        return;  // no links for special pages
 
    var title = mw.config.get('wgTitle');
    if (mw.config.get('wgCanonicalNamespace') != "") {
        title = title.replace(/^.*\//, "");  // subpage name only
        var prefix=mw.config.get('wgCanonicalNamespace')+':';
    } else {
        var prefix='';
    }

    var article= encodeURIComponent(prefix+title); 
    var titleu = title.replace(/ /g, "_"); 
    var articleu = encodeURIComponent(prefix+titleu); 
    mw.util.addPortletLink('p-cactions', 
                   'http://maps.google.com/maps?q=http%3A%2F%2Ftoolserver.org%2F%7Epara%2Fcgi-bin%2Fkmlexport%3Farticle%3D'+articleu,
                   'Map', 'ca-map', 'Map"'+title+'"', 'M');
/*
    mw.util.addPortletLink('p-cactions', 
                   'http://maps.bing.com/?mapurl=http%3A%2F%2Ftoolserver.org%2F%7Epara%2Fcgi-bin%2Fkmlexport%3Farticle%3D'+article,
                   'Bing', 'ca-bing', 'Bing"'+title+'"', 'W');
*/
});