Difference between revisions of "MediaWiki:Common.js"
From Medivia Online Wiki
| Line 3: | Line 3: | ||
if (!maps.length) return; | if (!maps.length) return; | ||
const script = document.createElement('script'); | |||
script.src = 'https://tafonath.github.io/medivia-mapper/medivia-mapper.js'; | |||
script.onload = () => { | |||
maps.forEach(el => { | |||
maps.forEach | |||
const x = parseInt(el.dataset.x || 2048, 10); | const x = parseInt(el.dataset.x || 2048, 10); | ||
const y = parseInt(el.dataset.y || -2047, 10); | const y = parseInt(el.dataset.y || -2047, 10); | ||
const z = parseInt(el.dataset.z || 7, 10); | const z = parseInt(el.dataset.z || 7, 10); | ||
const zoom = parseInt(el.dataset.zoom || 2, 10); | const zoom = parseInt(el.dataset.zoom || 2, 10); | ||
const initUrl = `?x=${x}&y=${y}&z=${z}&zoom=${zoom}`; | |||
// Initialize the mapper in this element — requires modification to original app | |||
MediviaMapper.init(el, initUrl); // this assumes the app is modular | |||
}); | }); | ||
}); | }; | ||
document.body.appendChild(script); | |||
}); | }); | ||
Revision as of 11:07, 5 July 2025
$(document).ready(function () {
const maps = document.querySelectorAll('.medivia-map');
if (!maps.length) return;
const script = document.createElement('script');
script.src = 'https://tafonath.github.io/medivia-mapper/medivia-mapper.js';
script.onload = () => {
maps.forEach(el => {
const x = parseInt(el.dataset.x || 2048, 10);
const y = parseInt(el.dataset.y || -2047, 10);
const z = parseInt(el.dataset.z || 7, 10);
const zoom = parseInt(el.dataset.zoom || 2, 10);
const initUrl = `?x=${x}&y=${y}&z=${z}&zoom=${zoom}`;
// Initialize the mapper in this element — requires modification to original app
MediviaMapper.init(el, initUrl); // this assumes the app is modular
});
};
document.body.appendChild(script);
});