MediaWiki:Gesamtkarte.js: Unterschied zwischen den Versionen

aus Chaos FreewarWiki, der Referenz für Freewar
Zur Navigation springen Zur Suche springen
K (angepasst für Platz der Ehre)
(Eine Zahl mehr für die Gesamtkarte, dann passen die typischerweise dreistelligen negativen Dungeonkoordiaten auch ins inputfeld (sowie die gefrorene Insel).)
 
(22 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
  // Code für die [[Gesamtkarte]]
  // Code für die [[Gesamtkarte]]
  // Einbindung in [[MediaWiki:Common.js#Gesamtkarte]]
  // Einbindung in [[MediaWiki:Common.js#Gesamtkarte]]<nowiki>
var routermode = false, routerloaded = false;
var offsetX, offsetY, prefix = '', oldprefix;
// Metadaten-"Cache"
var prefixes = Object(), crossmods = Array(), oldcrossmod = Object();
var TopLeftXs = Object(), TopLeftYs = Object(), OffsetXs = Object(), OffsetYs = Object();
   
   
  function map_click(event)
  function map_click(event)
  {
  {
  // Alle folgenden Pixelangaben siehe in show_map_position
   if (this.id == 'map_horz' || this.id == 'map_vert') prefix = oldprefix;
  // Alle folgenden sonstigen Zahlen sind Minimalkoordinatenangaben.
  else if (this.id.substr(0, 8) == 'map_img_') prefix = this.id.substr(8);
  var offsetX = 55, offsetY = 80;
   else prefix = '';
   if (this.id == 'map_img_narubia' || ((this.id == 'map_horz' || this.id == 'map_vert')
  offsetX = TopLeftXs[prefix + 'TopLeftX'] - 1;
                                        && document.getElementById('map_vert').style.top.substring(0, 1) == '0'
  offsetY = TopLeftYs[prefix + 'TopLeftY'] - 1;
                                        && document.getElementById('map_horz').style.left == '1140px'))
  var crossprefix = (routermode && document.map_form.map_radio[1].checked ? 'map_dest_' : 'map_');
      { offsetX = 498; offsetY = 50; }
   else if (this.id == 'map_img_insel' || ((this.id == 'map_horz' || this.id == 'map_vert')
                                          && document.getElementById('map_vert').style.top == '225px'))
          { offsetX = 1002; offsetY = 1001; }
  else if (this.id == 'map_vert' && this.style.top == '450px') offsetY = 110;
   
   
  var offX;
  var offY;
   if (window.event) // Internet Explorer, Opera, Konqueror, Safari
   if (window.event) // Internet Explorer, Opera, Konqueror, Safari
   {
   {
     if (this.id != 'map_vert') document.map_form.map_x.value = Math.floor((window.event.offsetX - 2) / 15 + offsetX);
     offX = window.event.offsetX;
     if (this.id != 'map_horz') document.map_form.map_y.value = Math.floor((window.event.offsetY - 2) / 15 + offsetY);
     offY = window.event.offsetY;
   } else {
   } else {
     if (this.id != 'map_vert') document.map_form.map_x.value = Math.floor((event.layerX - 2) / 15 + offsetX);
     offX = event.layerX;
     if (this.id != 'map_horz') document.map_form.map_y.value = Math.floor((event.layerY - 2) / 15 + offsetY);
     offY = event.layerY;
   }
   }
   show_map_position();
 
  document.map_form.elements[crossprefix + 'x'].value = Number(this.id == 'map_vert' || this.id == 'map_dest_vert' ? document.map_form.elements[this.id.substr(0, this.id.length - 4) + 'x'].value : Math.floor((offX - 2) / 15) + offsetX + Number(!oldcrossmod[this.id.substr(0, this.id.length - 4)] ? 0 : oldcrossmod[this.id.substr(0, this.id.length - 4)][4]));
  document.map_form.elements[crossprefix + 'y'].value = Number(this.id == 'map_horz' || this.id == 'map_dest_horz' ? document.map_form.elements[this.id.substr(0, this.id.length - 4) + 'y'].value : Math.floor((offY - 2) / 15) + offsetY + Number(!oldcrossmod[this.id.substr(0, this.id.length - 4)] ? 0 : oldcrossmod[this.id.substr(0, this.id.length - 4)][6]));
 
   show_map_position(crossprefix);
  if (routermode) finde_weg();
  oldprefix = prefix;
  }
  }
   
   
Zeile 31: Zeile 39:
   // Hilfsfunktion: Position von "x,y" in str ermitteln, sodass vor und nach dem Ergebnis keine Ziffer steht.
   // Hilfsfunktion: Position von "x,y" in str ermitteln, sodass vor und nach dem Ergebnis keine Ziffer steht.
   if (str.indexOf(' ' + x + ',' + y + ';') > -1) return str.indexOf(' ' + x + ',' + y + ';') + 1;
   if (str.indexOf(' ' + x + ',' + y + ';') > -1) return str.indexOf(' ' + x + ',' + y + ';') + 1;
   else if (str.indexOf(' ' + x + ',' + y + '{') > -1) return str.indexOf(' ' + x + ',' + y + '{') + 1;
   else if (str.indexOf(' ' + x + ',' + y + '<') > -1) return str.indexOf(' ' + x + ',' + y + '<') + 1;
   else if (str.indexOf('}' + x + ',' + y + ';') > -1) return str.indexOf('}' + x + ',' + y + ';') + 1;
   else if (str.indexOf('}' + x + ',' + y + ';') > -1) return str.indexOf('}' + x + ',' + y + ';') + 1;
   else return str.indexOf('}' + x + ',' + y + '{') + 1;
   else return str.indexOf('}' + x + ',' + y + '<') + 1;
  }
  }
   
   
  function show_map_position()
  function show_map_position(crossprefix)
  {
  {
   var map_horz = document.getElementById('map_horz');
   var map_horz = document.getElementById(crossprefix + 'horz');
   var map_vert = document.getElementById('map_vert');
   var map_vert = document.getElementById(crossprefix + 'vert');
   
   
   var gebiet = gebiet_map_position(document.map_form.map_x.value, document.map_form.map_y.value);
   var gebiet = gebiet_map_position(document.map_form.elements[crossprefix + 'x'].value, document.map_form.elements[crossprefix + 'y'].value);
   var map_out = document.getElementById('map_out');
  if (prefix == '?') {
    if (document.getElementById('prefix' + gebiet.replace(/\s/g, '_')))
      prefix = document.getElementById('prefix' + gebiet.replace(/\s/g, '_')).firstChild.nodeValue;
    else prefix = '';
    offsetX = TopLeftXs[prefix + 'TopLeftX'] - 1;
    offsetY = TopLeftYs[prefix + 'TopLeftY'] - 1;
  }
 
   var map_out_gebiet = document.getElementById('map_out_gebiet');
   var map_out_ort = document.getElementById('map_out_ort');
   var map_out_ort = document.getElementById('map_out_ort');
   if (gebiet != '')
   if (gebiet != '' || routermode)
   {
   {
     map_out.firstChild.href = '/wiki/index.php/' + gebiet;
     map_out_gebiet.firstChild.href = '/index.php/' + gebiet;
     map_out.firstChild.firstChild.nodeValue = gebiet;
     map_out_gebiet.firstChild.firstChild.nodeValue = gebiet;
     map_out.firstChild.nextSibling.nextSibling.href = '/wiki/index.php/Karte:' + gebiet;
     map_out_gebiet.firstChild.nextSibling.nextSibling.href = '/index.php/Karte:' + gebiet;
     ort = ort_map_position(document.map_form.map_x.value, document.map_form.map_y.value);
     ort = ort_map_position(document.map_form.elements[crossprefix + 'x'].value, document.map_form.elements[crossprefix + 'y'].value);
     if (ort != '')
     if (ort != '')
     {
     {
       map_out_ort.firstChild.nextSibling.firstChild.nodeValue = ort;
       map_out_ort.firstChild.nextSibling.firstChild.nodeValue = ort;
       map_out_ort.firstChild.nextSibling.href = '/wiki/index.php/' + ort;
       map_out_ort.firstChild.nextSibling.href = '/index.php/' + ort;
       map_out_ort.style.display = 'inline';
       map_out_ort.style.display = 'inline';
     }
     } else
    else map_out_ort.style.display = 'none';
      map_out_ort.style.display = 'none';
     map_out.style.visibility = 'visible';
     map_out_gebiet.style.visibility = 'visible';
   }
   } else
  else map_out.style.visibility = 'hidden';
    map_out_gebiet.style.visibility = 'hidden';
   if (gebiet == '' || document.map_form.map_x.value < 1 || document.map_form.map_y.value < 1)
   if (gebiet == '' || document.map_form.elements[crossprefix + 'x'].value < 1 || document.map_form.elements[crossprefix + 'y'].value < 1)
   {
   {
     map_horz.style.display = 'none';
     map_horz.style.display = 'none';
Zeile 66: Zeile 82:
     return false;
     return false;
   }
   }
   if (document.map_form.map_x.value > 123 && document.map_form.map_x.value < 142
   var imgOffsetX = Number(OffsetXs[prefix + 'OffsetX']);
      && document.map_form.map_y.value > 110 && document.map_form.map_y.value < 121) // Linya
   var imgOffsetY = Number(OffsetYs[prefix + 'OffsetY']);
   {
  var mod_left = 0, mod_top = 0, mod_width = 0, mod_height = 0;
    map_horz.style.left = '0';
  oldcrossmod[crossprefix] = null;
    map_vert.style.top = '450px';
   for (var i in crossmods) {
    map_horz.style.width = '1320px';
     var mod = crossmods[i].split('|');
    map_vert.style.height = '180px';
     if (Number(document.map_form.elements[crossprefix + 'x'].value) >= mod[0]
    map_horz.style.top = String(document.map_form.map_y.value * 15 - 1200) + 'px';
        && Number(document.map_form.elements[crossprefix + 'x'].value) <= mod[2]
    map_vert.style.left = String(document.map_form.map_x.value * 15 - 825) + 'px';
        && Number(document.map_form.elements[crossprefix + 'y'].value) >= mod[1]
   }
        && Number(document.map_form.elements[crossprefix + 'y'].value) <= mod[3]) {
  else if (document.map_form.map_x.value > 499 && document.map_form.map_x.value < 509
      mod_left  = Number(mod[4]);
      && document.map_form.map_y.value > 50 && document.map_form.map_y.value < 58) // Narubia
      mod_width  = Number(mod[5]);
  {
      mod_top   = Number(mod[6]);
     map_horz.style.left = '1140px';
      mod_height = Number(mod[7]);
    map_vert.style.top = '0';
      oldcrossmod[crossprefix] = mod;
     map_horz.style.width = '180px';
      break;
    map_vert.style.height = '135px';
     }
    map_horz.style.top = String(document.map_form.map_y.value * 15 - 750) + 'px';
    map_vert.style.left = String(document.map_form.map_x.value * 15 - 6330) + 'px';
  }
  else if (document.map_form.map_x.value > 1002 && document.map_form.map_x.value < 1012
            && document.map_form.map_y.value > 1001 && document.map_form.map_y.value < 1009) // Gefrorene Insel
  {
    map_horz.style.left = '1155px';
    map_vert.style.top = '225px';
    map_horz.style.width = '165px';
    map_vert.style.height = '135px';
    map_horz.style.top = String(document.map_form.map_y.value * 15 - 14790) + 'px';
    map_vert.style.left = String(document.map_form.map_x.value * 15 - 13875) + 'px';
   }
  else
  {
    map_horz.style.left = '0';
    map_vert.style.top = '0';
    if (document.map_form.map_y.value > 110 && document.map_form.map_y.value < 121) map_horz.style.width = '1320px';
    else map_horz.style.width = '1050px'; // Linya-Breite
    map_vert.style.height = '630px';
     map_horz.style.top = String(document.map_form.map_y.value * 15 - 1200) + 'px';
    map_vert.style.left = String(document.map_form.map_x.value * 15 - 825) + 'px';
   }
   }
  map_horz.style.left = String((imgOffsetX + mod_left) * 15) + 'px';
  map_vert.style.top = String((imgOffsetY + mod_top) * 15) + 'px';
  map_horz.style.width = String((mod_width ? mod_width : (document.getElementById(prefix + 'BottomRightX').firstChild.nodeValue - TopLeftXs[prefix + 'TopLeftX'] + 3)) * 15) + 'px';
  map_vert.style.height = String((mod_height ? mod_height : (document.getElementById(prefix + 'BottomRightY').firstChild.nodeValue - TopLeftYs[prefix + 'TopLeftY'] + 3)) * 15) + 'px';
  map_horz.style.top = String((Number(document.map_form.elements[crossprefix + 'y'].value) + imgOffsetY - Number(offsetY)) * 15) + 'px';
  map_vert.style.left = String((Number(document.map_form.elements[crossprefix + 'x'].value) + imgOffsetX - Number(offsetX)) * 15) + 'px';
   
   
   map_horz.style.display = 'block';
   map_horz.style.display = 'block';
   map_vert.style.display = 'block';
   map_vert.style.display = 'block';
  return false;
}
function press_map_button() {
  prefix = '?';
  show_map_position('map_');
  if (routermode) {
    prefix = '?';
    show_map_position('map_dest_');
    finde_weg();
  }
   return false;
   return false;
  }
  }
Zeile 117: Zeile 129:
   if (map_nav)
   if (map_nav)
   {
   {
     map_nav.firstChild.style.display = 'none';
     map_nav.getElementsByTagName('big')[0].style.display = 'none';
     var map_form, map_x, map_y, map_submit, map_kartenlink, map_link_img;
     var map_form, map_x, map_y, map_submit, map_kartenlink, map_link_img;
     map_form = document.createElement('form');
     map_form = document.createElement('form');
     map_form.name = 'map_form';
     map_form.name = 'map_form';
    map_form.onsubmit = press_map_button;
    map_nav.insertBefore(map_form, map_nav.firstChild);
    map_form.appendChild(map_nav.getElementsByTagName('table')[0]);
     map_x = document.createElement('input'); map_y = document.createElement('input');
     map_x = document.createElement('input'); map_y = document.createElement('input');
     map_x.type = 'text'; map_y.type = 'text';
     map_x.type = 'text'; map_y.type = 'text';
     map_x.id = 'map_x'; map_y.id = 'map_y';
     map_x.id = 'map_x'; map_y.id = 'map_y';
     map_x.size = '3'; map_y.size = '3';
     map_x.size = '4'; map_y.size = '4';
     map_x.style.textAlign = 'right'; map_y.style.textAlign = 'right';
     map_x.style.textAlign = 'right'; map_y.style.textAlign = 'right';
    with (document.getElementById('map_start')) {
      appendChild(document.createTextNode('X: '));
      appendChild(map_x);
      appendChild(document.createTextNode(' Y: '));
      appendChild(map_y);
    }
     map_submit = document.createElement('input');
     map_submit = document.createElement('input');
     map_submit.type = 'submit';
     map_submit.type = 'submit';
     map_submit.value = 'OK';
     map_submit.value = 'OK';
     document.getElementById('map_button').appendChild(map_submit);
     map_form.appendChild(document.createTextNode('X: '));
    map_form.appendChild(map_x);
    map_form.appendChild(document.createTextNode(' Y: '));
    map_form.appendChild(map_y);
    map_form.appendChild(document.createTextNode(' '));
    map_form.appendChild(map_submit);
    map_form.onsubmit = show_map_position;
    map_nav.insertBefore(map_form, map_nav.firstChild);
      
      
     map_kartenlink = document.createElement('a');
     map_kartenlink = document.createElement('a');
     map_link_img = document.createElement('img');
     map_link_img = document.createElement('img');
     map_link_img.src = 'http://freewar.tiramon.de/wiki/images/4/41/12px-Erde.png';
     map_link_img.src = 'http://www.fwwiki.de/images/4/41/12px-Erde.png';
     map_link_img.border = '0';
     map_link_img.border = '0';
     map_kartenlink.appendChild(map_link_img);
     map_kartenlink.appendChild(map_link_img);
     document.getElementById('map_out').insertBefore(map_kartenlink, document.getElementById('map_out_ort'));
     document.getElementById('map_out_gebiet').appendChild(map_kartenlink);
    n = document.getElementById('map').firstChild;
    do {
      if (n.nodeName == 'DIV') n.onclick = map_click;
    } while (n = n.nextSibling);
    init_map_metadata(document.getElementById('metadata'));
    document.getElementById('map_link_normal').firstChild.href = 'javascript:switch_mode(0);';
    document.getElementById('map_link_normal').style.display = 'inline';
    document.getElementById('map_link_router').firstChild.href = 'javascript:switch_mode(1);';
    document.getElementById('map_link_router').style.display = 'inline';
   
   
     document.getElementById('map_img').onclick = map_click;
     document.getElementById('map_dest').firstChild.style.display = 'none';
    document.getElementById('map_img_narubia').onclick = map_click;
    document.getElementById('map_img_insel').onclick = map_click;
    document.getElementById('map_horz').onclick = map_click;
    document.getElementById('map_vert').onclick = map_click;
   }
   }
  }
  }
   
   
  aOnloadFunctions[aOnloadFunctions.length] = init_map;
  function init_map_metadata(n) {
  n = n.firstChild;
  do {
    if (n.id) {
      if (n.id.substr(0, 6) == 'prefix') prefixes[n.id] = n.firstChild.nodeValue;
      if (n.id.substr(n.id.length - 8) == 'TopLeftX') TopLeftXs[n.id] = n.firstChild.nodeValue;
      if (n.id.substr(n.id.length - 8) == 'TopLeftY') TopLeftYs[n.id] = n.firstChild.nodeValue;
      if (n.id.substr(n.id.length - 7) == 'OffsetX') OffsetXs[n.id] = n.firstChild.nodeValue;
      if (n.id.substr(n.id.length - 7) == 'OffsetY') OffsetYs[n.id] = n.firstChild.nodeValue;
    }
    switch (n.className) {
      case 'crossmod':
        crossmods[crossmods.length] = n.firstChild.nodeValue;
        break;
    }
    // Rekursieren, da es umschließende <p> und <pre> Tags geben kann
    if (n.tagName) init_map_metadata(n);
  } while (n = n.nextSibling);
}
function switch_mode(mode) {
  if (mode == routermode) return;
  routermode = mode;
  var tmp = document.getElementById('map_link_normal').parentNode.getAttribute('style');
  document.getElementById('map_link_normal').parentNode.setAttribute('style', document.getElementById('map_link_router').parentNode.getAttribute('style'));
  document.getElementById('map_link_router').parentNode.setAttribute('style', tmp);
  if (mode == 1 && !routerloaded) init_router();
  document.getElementById('map_dest').style.display = (mode == 1 ? 'block' : 'none');
  document.getElementById('map_tools').style.display = (mode == 1 ? 'block' : 'none');
  document.getElementById('map_out_route').style.display = (mode == 1 ? 'inline' : 'none');
  document.getElementById('map_out_gebiet').style.display = (mode == 1 ? 'none' : 'inline');
  document.getElementById('map_label_start').style.display = (mode == 1 ? 'inline' : 'none');
  document.getElementById('map_label_dest').style.display = (mode == 1 ? 'inline' : 'none');
  document.getElementById('map_label_mouse').style.display = (mode == 1 ? 'inline' : 'none');
  document.getElementById('map_path').style.display = (mode == 1 ? 'inline' : 'none');
  document.getElementById('map_dest_horz').style.display = document.getElementById('map_dest_vert').style.display = (mode == 1 && document.map_form.elements['map_dest_x'].value > 0 && document.map_form.elements['map_dest_y'].value > 0 && gebiet_map_position(document.map_form.elements['map_dest_x'].value, document.map_form.elements['map_dest_y'].value) ? 'block' : 'none');
  if (!mode) press_map_button();
}
function gebiet_map_position(x, y)
{
  // Zumindest FF teilt Textknoten nach 2^12 Zeichen, also alle Kindknoten aneinanderreihen
  var ret = '', n = document.getElementById('coordlist').firstChild;
  do {
    ret = ret + n.nodeValue;
  } while (n = n.nextSibling);
  ret = ret.substring(0, get_koords_position(ret, x, y));
  ret = ret.substring(ret.lastIndexOf('{') + 13); // 13 ist die Länge von "Gebietslink|" + 1
  ret = ret.substring(0, ret.indexOf('}'));
  return ret;
}
function ort_map_position(x, y)
{
  // Zumindest FF teilt Textknoten nach 2^12 Zeichen, also alle Kindknoten aneinanderreihen
  var ret = '', n = document.getElementById('sitelist').firstChild;
  do {
    ret = ret + n.nodeValue;
  } while (n = n.nextSibling);
  ret = ret.substring(0, get_koords_position(ret, x, y));
  ret = ret.substring(ret.lastIndexOf('[') + 1);
  ret = ret.substring(0, ret.indexOf(']'));
  return ret;
}
//addOnloadHook(init_map);
jQuery( document ).ready( function( $ ) {
init_map();
} );
 
 
// </nowiki>

Aktuelle Version vom 18. Februar 2017, 18:36 Uhr

 // Code für die [[Gesamtkarte]]
 // Einbindung in [[MediaWiki:Common.js#Gesamtkarte]]<nowiki>
 var routermode = false, routerloaded = false;
 var offsetX, offsetY, prefix = '', oldprefix;
 // Metadaten-"Cache"
 var prefixes = Object(), crossmods = Array(), oldcrossmod = Object();
 var TopLeftXs = Object(), TopLeftYs = Object(), OffsetXs = Object(), OffsetYs = Object();
 
 function map_click(event)
 {
   if (this.id == 'map_horz' || this.id == 'map_vert') prefix = oldprefix;
   else if (this.id.substr(0, 8) == 'map_img_') prefix = this.id.substr(8);
   else prefix = '';
   offsetX = TopLeftXs[prefix + 'TopLeftX'] - 1;
   offsetY = TopLeftYs[prefix + 'TopLeftY'] - 1;
   var crossprefix = (routermode && document.map_form.map_radio[1].checked ? 'map_dest_' : 'map_');
 
   var offX;
   var offY;
   if (window.event)			// Internet Explorer, Opera, Konqueror, Safari
   {
     offX = window.event.offsetX;
     offY = window.event.offsetY;
   } else {
     offX = event.layerX;
     offY = event.layerY;
   }

   document.map_form.elements[crossprefix + 'x'].value = Number(this.id == 'map_vert' || this.id == 'map_dest_vert' ? document.map_form.elements[this.id.substr(0, this.id.length - 4) + 'x'].value : Math.floor((offX - 2) / 15) + offsetX + Number(!oldcrossmod[this.id.substr(0, this.id.length - 4)] ? 0 : oldcrossmod[this.id.substr(0, this.id.length - 4)][4]));
   document.map_form.elements[crossprefix + 'y'].value = Number(this.id == 'map_horz' || this.id == 'map_dest_horz' ? document.map_form.elements[this.id.substr(0, this.id.length - 4) + 'y'].value : Math.floor((offY - 2) / 15) + offsetY + Number(!oldcrossmod[this.id.substr(0, this.id.length - 4)] ? 0 : oldcrossmod[this.id.substr(0, this.id.length - 4)][6]));

   show_map_position(crossprefix);
   if (routermode) finde_weg();
   oldprefix = prefix;
 }
 
 function get_koords_position(str, x, y)
 {
   // Hilfsfunktion: Position von "x,y" in str ermitteln, sodass vor und nach dem Ergebnis keine Ziffer steht.
   if (str.indexOf(' ' + x + ',' + y + ';') > -1) return str.indexOf(' ' + x + ',' + y + ';') + 1;
   else if (str.indexOf(' ' + x + ',' + y + '<') > -1) return str.indexOf(' ' + x + ',' + y + '<') + 1;
   else if (str.indexOf('}' + x + ',' + y + ';') > -1) return str.indexOf('}' + x + ',' + y + ';') + 1;
   else return str.indexOf('}' + x + ',' + y + '<') + 1;
 }
 
 function show_map_position(crossprefix)
 {
   var map_horz = document.getElementById(crossprefix + 'horz');
   var map_vert = document.getElementById(crossprefix + 'vert');
 
   var gebiet = gebiet_map_position(document.map_form.elements[crossprefix + 'x'].value, document.map_form.elements[crossprefix + 'y'].value);
   if (prefix == '?') {
     if (document.getElementById('prefix' + gebiet.replace(/\s/g, '_')))
       prefix = document.getElementById('prefix' + gebiet.replace(/\s/g, '_')).firstChild.nodeValue;
     else prefix = '';
     offsetX = TopLeftXs[prefix + 'TopLeftX'] - 1;
     offsetY = TopLeftYs[prefix + 'TopLeftY'] - 1;
   }

   var map_out_gebiet = document.getElementById('map_out_gebiet');
   var map_out_ort = document.getElementById('map_out_ort');
   if (gebiet != '' || routermode)
   {
     map_out_gebiet.firstChild.href = '/index.php/' + gebiet;
     map_out_gebiet.firstChild.firstChild.nodeValue = gebiet;
     map_out_gebiet.firstChild.nextSibling.nextSibling.href = '/index.php/Karte:' + gebiet;
     ort = ort_map_position(document.map_form.elements[crossprefix + 'x'].value, document.map_form.elements[crossprefix + 'y'].value);
     if (ort != '')
     {
       map_out_ort.firstChild.nextSibling.firstChild.nodeValue = ort;
       map_out_ort.firstChild.nextSibling.href = '/index.php/' + ort;
       map_out_ort.style.display = 'inline';
     } else
       map_out_ort.style.display = 'none';
     map_out_gebiet.style.visibility = 'visible';
   } else
     map_out_gebiet.style.visibility = 'hidden';
   if (gebiet == '' || document.map_form.elements[crossprefix + 'x'].value < 1 || document.map_form.elements[crossprefix + 'y'].value < 1)
   {
     map_horz.style.display = 'none';
     map_vert.style.display = 'none';
     return false;
   }
   var imgOffsetX = Number(OffsetXs[prefix + 'OffsetX']);
   var imgOffsetY = Number(OffsetYs[prefix + 'OffsetY']);
   var mod_left = 0, mod_top = 0, mod_width = 0, mod_height = 0;
   oldcrossmod[crossprefix] = null;
   for (var i in crossmods) {
     var mod = crossmods[i].split('|');
     if (Number(document.map_form.elements[crossprefix + 'x'].value) >= mod[0]
         && Number(document.map_form.elements[crossprefix + 'x'].value) <= mod[2]
         && Number(document.map_form.elements[crossprefix + 'y'].value) >= mod[1]
         && Number(document.map_form.elements[crossprefix + 'y'].value) <= mod[3]) {
       mod_left   = Number(mod[4]);
       mod_width  = Number(mod[5]);
       mod_top    = Number(mod[6]);
       mod_height = Number(mod[7]);
       oldcrossmod[crossprefix] = mod;
       break;
     }
   }
   map_horz.style.left = String((imgOffsetX + mod_left) * 15) + 'px';
   map_vert.style.top = String((imgOffsetY + mod_top) * 15) + 'px';
   map_horz.style.width = String((mod_width ? mod_width : (document.getElementById(prefix + 'BottomRightX').firstChild.nodeValue - TopLeftXs[prefix + 'TopLeftX'] + 3)) * 15) + 'px';
   map_vert.style.height = String((mod_height ? mod_height : (document.getElementById(prefix + 'BottomRightY').firstChild.nodeValue - TopLeftYs[prefix + 'TopLeftY'] + 3)) * 15) + 'px';
   map_horz.style.top = String((Number(document.map_form.elements[crossprefix + 'y'].value) + imgOffsetY - Number(offsetY)) * 15) + 'px';
   map_vert.style.left = String((Number(document.map_form.elements[crossprefix + 'x'].value) + imgOffsetX - Number(offsetX)) * 15) + 'px';
 
   map_horz.style.display = 'block';
   map_vert.style.display = 'block';
 
   return false;
 }
 
 function press_map_button() {
   prefix = '?';
   show_map_position('map_');
   if (routermode) {
     prefix = '?';
     show_map_position('map_dest_');
     finde_weg();
   }
   return false;
 }
 
 function init_map()
 {
   var map_nav = document.getElementById('map_nav');
   if (map_nav)
   {
     map_nav.getElementsByTagName('big')[0].style.display = 'none';
     var map_form, map_x, map_y, map_submit, map_kartenlink, map_link_img;
     map_form = document.createElement('form');
     map_form.name = 'map_form';
     map_form.onsubmit = press_map_button;
     map_nav.insertBefore(map_form, map_nav.firstChild);
     map_form.appendChild(map_nav.getElementsByTagName('table')[0]);
 
     map_x = document.createElement('input');	map_y = document.createElement('input');
     map_x.type = 'text';			map_y.type = 'text';
     map_x.id = 'map_x'; 			map_y.id = 'map_y';
     map_x.size = '4';				map_y.size = '4';
     map_x.style.textAlign = 'right';		map_y.style.textAlign = 'right';
 
     with (document.getElementById('map_start')) {
       appendChild(document.createTextNode('X: '));
       appendChild(map_x);
       appendChild(document.createTextNode(' Y: '));
       appendChild(map_y);
     }
 
     map_submit = document.createElement('input');
     map_submit.type = 'submit';
     map_submit.value = 'OK';
     document.getElementById('map_button').appendChild(map_submit);
     
     map_kartenlink = document.createElement('a');
     map_link_img = document.createElement('img');
     map_link_img.src = 'http://www.fwwiki.de/images/4/41/12px-Erde.png';
     map_link_img.border = '0';
     map_kartenlink.appendChild(map_link_img);
     document.getElementById('map_out_gebiet').appendChild(map_kartenlink);
 
     n = document.getElementById('map').firstChild;
     do {
       if (n.nodeName == 'DIV') n.onclick = map_click;
     } while (n = n.nextSibling);
 
     init_map_metadata(document.getElementById('metadata'));
 
     document.getElementById('map_link_normal').firstChild.href = 'javascript:switch_mode(0);';
     document.getElementById('map_link_normal').style.display = 'inline';
     document.getElementById('map_link_router').firstChild.href = 'javascript:switch_mode(1);';
     document.getElementById('map_link_router').style.display = 'inline';
 
     document.getElementById('map_dest').firstChild.style.display = 'none';
   }
 }
 
 function init_map_metadata(n) {
   n = n.firstChild;
   do {
     if (n.id) {
       if (n.id.substr(0, 6) == 'prefix') prefixes[n.id] = n.firstChild.nodeValue;
       if (n.id.substr(n.id.length - 8) == 'TopLeftX') TopLeftXs[n.id] = n.firstChild.nodeValue;
       if (n.id.substr(n.id.length - 8) == 'TopLeftY') TopLeftYs[n.id] = n.firstChild.nodeValue;
       if (n.id.substr(n.id.length - 7) == 'OffsetX') OffsetXs[n.id] = n.firstChild.nodeValue;
       if (n.id.substr(n.id.length - 7) == 'OffsetY') OffsetYs[n.id] = n.firstChild.nodeValue;
     }
     switch (n.className) {
       case 'crossmod':
         crossmods[crossmods.length] = n.firstChild.nodeValue;
         break;
     }
     // Rekursieren, da es umschließende <p> und <pre> Tags geben kann
     if (n.tagName) init_map_metadata(n);
   } while (n = n.nextSibling);
 }
 
 function switch_mode(mode) {
   if (mode == routermode) return;
   routermode = mode;
   var tmp = document.getElementById('map_link_normal').parentNode.getAttribute('style');
   document.getElementById('map_link_normal').parentNode.setAttribute('style', document.getElementById('map_link_router').parentNode.getAttribute('style'));
   document.getElementById('map_link_router').parentNode.setAttribute('style', tmp);
   if (mode == 1 && !routerloaded) init_router();
   document.getElementById('map_dest').style.display = (mode == 1 ? 'block' : 'none');
   document.getElementById('map_tools').style.display = (mode == 1 ? 'block' : 'none');
   document.getElementById('map_out_route').style.display = (mode == 1 ? 'inline' : 'none');
   document.getElementById('map_out_gebiet').style.display = (mode == 1 ? 'none' : 'inline');
   document.getElementById('map_label_start').style.display = (mode == 1 ? 'inline' : 'none');
   document.getElementById('map_label_dest').style.display = (mode == 1 ? 'inline' : 'none');
   document.getElementById('map_label_mouse').style.display = (mode == 1 ? 'inline' : 'none');
   document.getElementById('map_path').style.display = (mode == 1 ? 'inline' : 'none');
   document.getElementById('map_dest_horz').style.display = document.getElementById('map_dest_vert').style.display = (mode == 1 && document.map_form.elements['map_dest_x'].value > 0 && document.map_form.elements['map_dest_y'].value > 0 && gebiet_map_position(document.map_form.elements['map_dest_x'].value, document.map_form.elements['map_dest_y'].value) ? 'block' : 'none');
   if (!mode) press_map_button();
 }
 
 function gebiet_map_position(x, y)
 {
   // Zumindest FF teilt Textknoten nach 2^12 Zeichen, also alle Kindknoten aneinanderreihen
   var ret = '', n = document.getElementById('coordlist').firstChild;
   do {
     ret = ret + n.nodeValue;
   } while (n = n.nextSibling);
   ret = ret.substring(0, get_koords_position(ret, x, y));
   ret = ret.substring(ret.lastIndexOf('{') + 13);			// 13 ist die Länge von "Gebietslink|" + 1
   ret = ret.substring(0, ret.indexOf('}'));
   return ret;
 }
 
 function ort_map_position(x, y)
 {
   // Zumindest FF teilt Textknoten nach 2^12 Zeichen, also alle Kindknoten aneinanderreihen
   var ret = '', n = document.getElementById('sitelist').firstChild;
   do {
     ret = ret + n.nodeValue;
   } while (n = n.nextSibling);
   ret = ret.substring(0, get_koords_position(ret, x, y));
   ret = ret.substring(ret.lastIndexOf('[') + 1);
   ret = ret.substring(0, ret.indexOf(']'));
   return ret;
 }
 
 //addOnloadHook(init_map);
 
 jQuery( document ).ready( function( $ ) {
	init_map();
 } );


 // </nowiki>