MediaWiki:Common.js
From Medivia Online Wiki
Revision as of 10:57, 5 July 2025 by Eldrin (talk | contribs) (Created page with "→Any JavaScript here will be loaded for all users on every page load.: mw.loader.load('https://unpkg.com/[email protected]/dist/leaflet.css', 'text/css'); mw.loader.load('https://unpkg.com/[email protected]/dist/leaflet.js'); $(function () { $('.medivia-map').each(function () { const el = this; const x = parseInt(el.dataset.x); const y = parseInt(el.dataset.y); const z = parseInt(el.dataset.z); const zoom = parseInt(el.dataset.zoom); const map = L...")
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.load('https://unpkg.com/[email protected]/dist/leaflet.css', 'text/css');
mw.loader.load('https://unpkg.com/[email protected]/dist/leaflet.js');
$(function () {
$('.medivia-map').each(function () {
const el = this;
const x = parseInt(el.dataset.x);
const y = parseInt(el.dataset.y);
const z = parseInt(el.dataset.z);
const zoom = parseInt(el.dataset.zoom);
const map = L.map(el, {
crs: L.CRS.Simple,
minZoom: 0,
maxZoom: 7,
center: [y, x],
zoom: zoom
});
// Define the tile URL pattern based on Medivia Mapper structure
L.tileLayer('https://tafonath.github.io/medivia-mapper/tiles/{z}/{x}/{y}.png', {
attribution: '© Medivia',
tileSize: 256,
noWrap: true
}).addTo(map);
map.setView([y, x], zoom);
});
});