MediaWiki:Common.js

From Medivia Online Wiki
Revision as of 11:07, 5 July 2025 by Eldrin (talk | contribs)

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.
$(document).ready(function () {
  var maps = document.querySelectorAll('.medivia-map');
  if (!maps.length) return;

  // Create script tag for full medivia-mapper logic
  var script = document.createElement('script');
  script.src = 'https://tafonath.github.io/medivia-mapper/medivia-mapper.js';
  script.onload = function () {
    for (var i = 0; i < maps.length; i++) {
      var el = maps[i];
      var x = parseInt(el.getAttribute('data-x') || 2048, 10);
      var y = parseInt(el.getAttribute('data-y') || -2047, 10);
      var z = parseInt(el.getAttribute('data-z') || 7, 10);
      var zoom = parseInt(el.getAttribute('data-zoom') || 2, 10);
      var initUrl = '?x=' + x + '&y=' + y + '&z=' + z + '&zoom=' + zoom;

      if (typeof MediviaMapper !== 'undefined' && typeof MediviaMapper.init === 'function') {
        MediviaMapper.init(el, initUrl);
      }
    }
  };
  document.body.appendChild(script);
});