User:Hlaw/global.js

// Import modified version of Leaflet.js to work around clash of "define" function importScriptPage('User:Hlaw/Leaflet.js', 'c');

// Earth icon in base64 encoding, from wikipedia var iconSource = 'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAA4dJREFUOMtVk8tvG1UYR3/3zp2H7dhTO4nTNlVoS0vVtEBaWgmJihVQIRYU1B1ixY4/gz1CVGLLik2FQKyoxHsBohEPRUofCmmV1m6al+2J7fHMnTvfvR8bqODsz9kdgX8Y6QT1MMLK7rCVZO7kT119ZGXfTvXT0pxr2d35Gu79slpsttsefXr1AYC3/lUhAODX7h6mIy9Y3tZLWekuBkpM30+t/GwUweYGL6uEz00X+cbArkW+97OqjvurqzP4+v1nAQDy7u4e2hWEmbWvpFZcvj+Ws0HgCwp8Dh1xaEueqwpMhajOx3Tel5OrO9veoVb7MT652QUAqNPtj/DOl+9dXGgGF5ZzJbRUfOuRwwM/wKV2ibCQOBFJSCHZk2Ah6HDFx+vdLfX5t8naGAC86Q+uHd6g8LU7FFT6YYih7yOCxYUK4Y2Ww2Kd4AmCLgmaCAURayoOCEX50bOTTnziXSgie5ZZNJQQLB1DGcKrsw5nW4CChWMLcg6WHZxjWGawcIJsuXjjuvkDKDLldH4UmgRNDEu2OD8r0JCEccbwI4e/+gZgQlY4COlAzoGcc6W1zVrdNaUnM1XjPE7TFGWo0ITBUlWASocbHUJVMZoBYb5BgCAURDBkkecW3Y3MJ021IFRQsdBuP+kh8hyuPBPidNODJwApHTZHFmxLFGRgSsKjHuNO1yKODDobKc9OR2zJQs1Uy/2H2+N6o2YxX5/BqJBgBqoe41hsMSkIWwnBUwYPtg1W1w1aYgydjs22TscAQy0+PXVvozuY7z8msfbQ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EVYdFRodW1iOjpVUkkAZmlsZTovLy90bXAvbG9jYWxjb3B5XzE1OGFjNzliNmYzOC0xLnBuZ+/apGAAAAAASUVORK5CYII='

/* if (wgCanonicalNamespace == 'User' || wgCanonicalNamespace == 'User_talk') { $('Hide ').insertAfter('.UserProfileActionButton'); $('Show ').insertAfter('.UserProfileActionButton'); } function hideBar { $('#UserProfileMasthead').hide; } function showBar { $('#UserProfileMasthead').show; }

/* Insert map */ function CreateHideMap { // Only activate for namespace=0 if (wgNamespaceNumber != 0) return;

// HTML for botton and map, to insert in Coord Template var spanHTML = '     '

// Insert button and map after last link in box // $('.infomap tbody:nth-child(1) tr:nth-child(1) td:nth-child(1) span:nth-child(1) a:nth-last-child(1)').after(spanHTML); $('.infomap > a:nth-last-child(1)').after(spanHTML);

// get lat-lon microdata from template var maplat = $('.infomap').attr('data-lat'); var maplon = $('.infomap').attr('data-lon');

// Create map, set zoom to 17 var map = L.map('embededmap').setView([maplat, maplon], 17); // Don't show the 'Powered by Leaflet' text. map.attributionControl.setPrefix(''); // OSM settings var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; var osmAttrib='Map data © OpenStreetMap contributors'; L.tileLayer(osmUrl, {       minZoom: 9,         maxZoom: 18,        attribution: osmAttrib,         zoomControl: false    }).addTo(map); var roundIcon = L.divIcon({       className: 'round-icon',        // html here defines what goes in the div created for each marker        html: '',        iconAnchor: [18, 36],        // marker width and height        iconSize: [36, 36]    })

L.marker([maplat, maplon],{icon: busIcon}).addTo(map).bindPopup(wgPageName); }

addOnloadHook(CreateHideMap);

/*$(window).load(function { //   $.getScript( 'http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js').done(function // { CreateHideMap; //  }); });*/