MediaWiki:Common.js
From Medivia Online Wiki
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.
/**
* MediviaMapper MediaWiki Extension (minimal prototype)
* Allows embedding the full Medivia Mapper in a <mediviamap> tag
* using an <iframe> internally (safest, lowest maintenance approach)
*/
(function () {
if (typeof mw === 'undefined') return;
mw.hook('wikipage.content').add(function ($content) {
$content.find('mediviamap').each(function () {
var el = $(this);
var x = el.attr('x') || '2048';
var y = el.attr('y') || '-2047';
var z = el.attr('z') || '7';
var zoom = el.attr('zoom') || '2';
var width = el.attr('width') || '100%';
var height = el.attr('height') || '500px';
var iframe = $('<iframe>', {
src: 'https://tafonath.github.io/medivia-mapper/?x=' + x + '&y=' + y + '&z=' + z + '&zoom=' + zoom,
width: width,
height: height,
frameborder: 0,
allowfullscreen: true,
style: 'border:none;'
});
el.replaceWith(iframe);
});
});
})();