Mapper/Code

//JS

minimap_mapper_page = 'http://tibia.wikia.com/wiki/Mapper'; minimap_images = [ 'http://images1.wikia.nocookie.net/__cb20100713183442/tibia/en/images/5/5b/Minimap_Floor_0.gif', 'http://images2.wikia.nocookie.net/__cb20100713183443/tibia/en/images/1/1d/Minimap_Floor_1.gif', 'http://images1.wikia.nocookie.net/__cb20100713183444/tibia/en/images/d/da/Minimap_Floor_2.gif', 'http://images3.wikia.nocookie.net/__cb20100713183444/tibia/en/images/5/51/Minimap_Floor_3.gif', 'http://images3.wikia.nocookie.net/__cb20100713183444/tibia/en/images/6/6c/Minimap_Floor_4.gif', 'http://images2.wikia.nocookie.net/__cb20100713183445/tibia/en/images/6/62/Minimap_Floor_5.gif', 'http://images2.wikia.nocookie.net/__cb20100713183445/tibia/en/images/f/f3/Minimap_Floor_6.gif', 'http://images4.wikia.nocookie.net/__cb20100713183446/tibia/en/images/1/16/Minimap_Floor_7.gif', 'http://images4.wikia.nocookie.net/__cb20100713183446/tibia/en/images/b/b2/Minimap_Floor_8.gif', 'http://images1.wikia.nocookie.net/__cb20100713183446/tibia/en/images/d/d5/Minimap_Floor_9.gif', 'http://images2.wikia.nocookie.net/__cb20100713184204/tibia/en/images/7/7e/Minimap_Floor_10.gif', 'http://images2.wikia.nocookie.net/__cb20100713184204/tibia/en/images/a/ac/Minimap_Floor_11.gif', 'http://images2.wikia.nocookie.net/__cb20100713184205/tibia/en/images/8/89/Minimap_Floor_12.gif', 'http://images1.wikia.nocookie.net/__cb20100713184206/tibia/en/images/8/83/Minimap_Floor_13.gif', 'http://images2.wikia.nocookie.net/__cb20100713184207/tibia/en/images/7/7d/Minimap_Floor_14.gif', 'http://images3.wikia.nocookie.net/__cb20100713184209/tibia/en/images/1/10/Minimap_Floor_15.gif' ];

minimap_getVpHeight = function { return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; }; minimap_getVpWidth = function { return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; }; minimap_getDocHeight = function { var D = document, DB = D.body, DE = D.documentElement; return Math.max(Math.max(DB.scrollHeight, DE.scrollHeight), Math.max(DB.offsetHeight, DE.offsetHeight), Math.max(DB.clientHeight, DE.clientHeight)); };

minimap_get_coords = function(url, varname) { url = unescape(url); if (typeof varname == 'undefined') { varname = 'coords'; } var pars = [], tmpp = url.split(varname + '='); tmpp.shift; tmpp = tmpp.join('').split('&')[0]; if (varname == 'coords') { //0x.1x,2y.3y,4z,5zoom,6zoomm,7centermark if (tmpp == '' || typeof (tmpp = tmpp.split(',')).length < 3) { pars = [127, 128, 124, 128, 7, 1, 1, 1]; } else { pars[0] = parseInt(tmpp[0].split('.')[0] || 127, 10); pars[1] = parseInt(tmpp[0].split('.')[1] || 0, 10); pars[2] = parseInt(tmpp[1].split('.')[0] || 124, 10); pars[3] = parseInt(tmpp[1].split('.')[1] || 0, 10); pars[4] = parseInt(tmpp[2] || 7, 10); pars[5] = parseFloat(tmpp[3] || 1); pars[6] = parseFloat(tmpp[4] || 1); pars[7] = parseInt(tmpp[5] || 1, 10); pars[0] = (pars[0] > 130 || pars[0] < 124 ? 127 : pars[0]); pars[1] = (pars[1] > 255 || pars[1] < 0 ? 0 : pars[1]); pars[2] = (pars[2] > 129 || pars[2] < 121 ? 124 : pars[2]); pars[3] = (pars[3] > 255 || pars[3] < 0 ? 0 : pars[3]); pars[4] = (pars[4] > 15 || pars[4] < 0 ? 7 : pars[4]); pars[5] = (pars[5] > 8 || pars[5] < 1 ? 1 : pars[5]); pars[6] = (pars[6] > 1 || pars[6] < 0 ? 1 : pars[6]); pars[7] = (pars[7] > 1 || pars[7] < 0 ? 1 : pars[7]); } }  else if (varname.indexOf('mark') === 0) { //Default 0x.1x,2y.3y,4z,5icon,6link if (tmpp ==  || typeof (tmpp = tmpp.split(',')).length < 3) { pars = [127, 128, 124, 128, 7, 1, ]; } else { pars[0] = parseInt(tmpp[0].split('.')[0] || 127, 10); pars[1] = parseInt(tmpp[0].split('.')[1] || 0, 10); pars[2] = parseInt(tmpp[1].split('.')[0] || 124, 10); pars[3] = parseInt(tmpp[1].split('.')[1] || 0, 10); pars[4] = parseInt(tmpp[2] || 7, 10); pars[5] = parseInt(tmpp[3] || 1, 10); pars[6] = tmpp[4] || ''; pars[0] = (pars[0] > 130 || pars[0] < 124 ? 127 : pars[0]); pars[1] = (pars[1] > 255 || pars[1] < 0 ? 0 : pars[1]); pars[2] = (pars[2] > 129 || pars[2] < 121 ? 124 : pars[2]); pars[3] = (pars[3] > 255 || pars[3] < 0 ? 0 : pars[3]); pars[4] = (pars[4] > 15 || pars[4] < 0 ? 7 : pars[4]); pars[5] = (pars[5] > 20 || pars[5] < 0 ? 1 : pars[5]); } }  return pars; };

minimap_center_div = function (em) { var aligner = function(ea) { if (ea.style.display == 'block') { ea.style.top = parseInt(((minimap_getVpHeight - ea.offsetHeight) / 2)+                  Math.max(document.body.scrollTop, document.documentElement.scrollTop), 10)+'px'; ea.style.left = parseInt(((minimap_getVpWidth - ea.offsetWidth) / 2)+                  Math.max(document.body.scrollLeft, document.documentElement.scrollLeft), 10)+'px'; var t = document.getElementById('minimap_blackout'); t.style.display = 'block'; t.style.height = minimap_getDocHeight+'px'; } }; if (typeof em == 'undefined') { var x, tmp = document.minimap_getElementsByClassName('minimap_wp'); for (x in tmp) { if (tmp.hasOwnProperty(x)) { aligner(tmp[x]); } } return; } aligner(em); };

minimap_addeventlistener = function(obj, event, listener) { if (window.addEventListener) { obj.addEventListener(event, listener, false); } else if ( window.attachEvent ) { obj.attachEvent('on'+event, listener); } };

minimap_drago = null; minimap_dragos = null; minimap_dragms = null; minimap_dragstart = function (e) { if (!e) { return; } e.onmousedown = function(ev) { ev = (ev || window.event); if (!(minimap_drago = document.getElementById('minimap_imgdiv'))) { return; } minimap_dragms = minimap_getmxy(ev); minimap_dragos = {x:minimap_drago.style.left, y:minimap_drago.style.top}; return false; }; }; minimap_getmxy = function (ev) { if (ev.pageX || ev.pageY) { return {x:ev.pageX, y:ev.pageY}; } return {x:ev.clientX+document.body.scrollLeft-document.body.clientLeft, y:ev.clientY+document.body.scrollTop-document.body.clientTop}; };

minimap_addeventlistener(document, 'mouseup', function (ev) { if (minimap_drago) {    ev = (ev || window.event);    var currxy = minimap_getmxy(ev);    minimap_map_data[1] += parseInt((minimap_dragms.x -currxy.x)/minimap_map_data[5], 10);    minimap_map_data[3] += parseInt((minimap_dragms.y -currxy.y)/minimap_map_data[5], 10);    minimap_pos;  }  minimap_drago = null; });

minimap_addeventlistener(document, 'mousemove', function (ev) { ev = (ev || window.event);  var currxy = minimap_getmxy(ev);  if (minimap_drago) {    minimap_drago.style.left = (parseFloat(minimap_dragos.x) - (minimap_dragms.x - currxy.x))+'px';    minimap_drago.style.top = (parseFloat(minimap_dragos.y) - (minimap_dragms.y - currxy.y))+'px';    return false;  } });

minimap_map_data = []; minimap_map_sdata = [];

minimap_data_to_url = function (type) { //0x.1x,2y.3y,4z,5zoom,6zoomm,7centermark //0x.1x,2y.3y,4z,5icon,6link var x, ret; if (type === 0) {//Link ret = minimap_mapper_page+'?coords='; ret += minimap_map_data[0]+'.'+minimap_map_data[1]+','+minimap_map_data[2]+'.'+minimap_map_data[3]+','+ minimap_map_data[4]+','+minimap_map_data[5]+','+minimap_map_data[6]+','+minimap_map_data[7]; if (document.getElementById('minimap_marks_enabled').checked) { for (x in minimap_map_data) { if (minimap_map_data.hasOwnProperty(x) && typeof minimap_map_data[x] == 'object') { ret += '&'+x+'='; ret += minimap_map_data[x][0]+'.'+minimap_map_data[x][1]+','+minimap_map_data[x][2]+'.'+minimap_map_data[x][3]+ ','+minimap_map_data[x][4]+','+minimap_map_data[x][5]+(minimap_map_data[x][6] ? ','+minimap_map_data[x][6] : ''); } }   }  }  if (type == 1) {//Template:Minimap ret = '{'+'{Minimap'; ret += '|x='+minimap_map_data[0]+'.'+minimap_map_data[1]+'|y='+minimap_map_data[2]+'.'+minimap_map_data[3]+'|z='+ minimap_map_data[4]+'|zoom='+minimap_map_data[5]+'|zoomm='+minimap_map_data[6]+ '|width='+(1 / minimap_map_data[5])+'|height='+(1 / minimap_map_data[5])+ '|centermark='+(minimap_map_data[7] ? 'yes' : 0); if (document.getElementById('minimap_marks_enabled').checked) { for (x in minimap_map_data) { if (minimap_map_data.hasOwnProperty(x) && typeof minimap_map_data[x] == 'object') { if (minimap_map_data[4] != minimap_map_data[x][4]) { continue; } ret += '|'+x+'='; ret += minimap_map_data[x][0]+'.'+minimap_map_data[x][1]+','+minimap_map_data[x][2]+'.'+minimap_map_data[x][3]+ ','+minimap_map_data[x][5]+','+minimap_map_data[x][6]; } }   }    ret += '}'+'}'; } if (type == 2) {//Template:Minimap_Popup ret = '{'+'{Minimap_Popup'; ret += '|link='+minimap_data_to_url(0).replace(/\s|%20/gi, '_')+'|text='+document.getElementById('minimap_tcode3').value.replace(/\s|%20/gi, '_'); ret += '}'+'}'; } return ret; };

minimap_mapper_list_click = function { if (document.getElementById('minimap_loading').style.display == 'block') { return; } var e = document.getElementById('mapper_list'); e = e[e.selectedIndex]; e = unescape(e.value).split(','); document.getElementById('mapper_mark_remove').disabled = false; minimap_map_data[0] = parseInt(e[0], 10); minimap_map_data[1] = parseInt(e[1], 10); minimap_map_data[2] = parseInt(e[2], 10); minimap_map_data[3] = parseInt(e[3], 10); minimap_map_data[4] = parseInt(e[4], 10); minimap_pos(false); };

minimap_codes_update = function (reset_list) { var d; d = document.getElementById('minimap_current_floor'); d.value = -1*(minimap_map_data[4] - 7); if ((d = document.getElementById('minimap_tcode1')) !== null) { d.value = minimap_data_to_url(0); d = document.getElementById('minimap_tcode2'); d.value = minimap_data_to_url(1); d = document.getElementById('minimap_tcode4'); d.value = minimap_data_to_url(2); if (typeof reset_list == 'undefined') { reset_list = true; } if (reset_list) { d = document.getElementById('mapper_list'); d.onchange = 'minimap_mapper_list_click;'; minimap_addeventlistener(d, 'change', function{minimap_mapper_list_click;}); d.options.length = 0; var i = 1, newopt; while (minimap_map_data['mark'+i]) { newopt = document.createElement('option'); d.options.add(newopt); newopt.innerHTML = i;       newopt.value = escape(minimap_map_data['mark'+i].join(',')); i++; }   }  } };

minimap_pos_b = function(act, val) { if (document.getElementById('minimap_loading').style.display == 'block') { return; } var x; if (act == 'reset') { minimap_map_data = []; for (x in minimap_map_sdata) { if (minimap_map_sdata.hasOwnProperty(x)) { minimap_map_data[x] = (typeof minimap_map_sdata[x] == 'object' ? minimap_map_sdata[x].slice(0) : minimap_map_sdata[x]); } } }  else if (act == 'we') { minimap_map_data[1] += val; } else if (act == 'ns') { minimap_map_data[3] += val; } else if (act == 'zoom') { x = minimap_map_data[5] * val; if (x > 8 || x < 1) { return; } minimap_map_data[5] = x; } else if (act == 'floor') { x = minimap_map_data[4] + val; if (x > 15 || x < 0) { return; } minimap_map_data[4] = x; } minimap_pos; };

minimap_pos = function(reset_list) { //Adjusts values out of range for x and y minimap_map_data[0] = minimap_map_data[0]+Math.floor(minimap_map_data[1] / 256); minimap_map_data[1] = minimap_map_data[1]-(Math.floor(minimap_map_data[1]/256)*256); minimap_map_data[2] = minimap_map_data[2]+Math.floor(minimap_map_data[3] / 256); minimap_map_data[3] = minimap_map_data[3]-(Math.floor(minimap_map_data[3]/256)*256);

document.getElementById('minimap_maindiv').style.display = 'none'; document.getElementById('minimap_loading').style.display = 'block'; var parss, pars = minimap_map_data; var tleft = Math.floor((((pars[0] - 124 - (1*(1/pars[5]))) * 256) + pars[1]) * pars[5], 10); var ttop = Math.floor((((pars[2] - 121- (0.75*(1/pars[5]))) * 256) + pars[3]) * pars[5], 10); var twidth = Math.floor(1792 * pars[5]); var theight = Math.floor(2304 * pars[5]); //main image var d = document.getElementById('minimap_imgdiv'); d.style.left = (-1*tleft)+'px'; d.style.top = (-1*ttop)+'px'; d.firstChild.width = twidth; d.firstChild.height = theight; if (d.firstChild.src == minimap_images[pars[4]]) { document.getElementById('minimap_loading').style.display = 'none'; document.getElementById('minimap_maindiv').style.display = 'block'; } else { d.firstChild.src = minimap_images[pars[4]]; }

//dashed lines if (document.getElementById('minimap_cmark_enabled').checked) { minimap_map_data[7] = 1; d = document.getElementById('minimap_vl'); d.style.display = 'block'; d.visibility = 'visible'; d = document.getElementById('minimap_hl'); d.style.display = 'block'; d.visibility = 'visible';

if (wgPageName != 'Mapper') { parss = minimap_map_sdata; tleft = Math.floor((((parss[0] - 124 - (1*(1/pars[5]))) * 256) + parss[1]) * pars[5], 10); ttop = Math.floor((((parss[2] - 121- (0.75*(1/pars[5]))) * 256) + parss[3]) * pars[5], 10);

d = document.getElementById('minimap_vl'); d.style.left = (tleft+256)+'px'; d.style.top = (ttop+(wgPageName != 'Mapper' ? parseInt((384-parseInt(384*(pars[5] / parss[5]), 10))/2, 10) : 0))+'px'; d.style.height = (wgPageName != 'Mapper' ? parseInt(384*(pars[5] / parss[5]), 10) : 384)+'px';

d = document.getElementById('minimap_hl'); d.style.left = (tleft+(wgPageName != 'Mapper' ? parseInt((512-parseInt(512*(pars[5] / parss[5]), 10))/2, 10) : 0))+'px'; d.style.top = (ttop+192)+'px'; d.style.width = (wgPageName != 'Mapper' ? parseInt(512*(pars[5] / parss[5]), 10) : 512)+'px'; } }  else { minimap_map_data[7] = 0; d = document.getElementById('minimap_vl'); d.style.display = 'none'; d.visibility = 'hidden'; d = document.getElementById('minimap_hl'); d.style.display = 'none'; d.visibility = 'hidden'; }

//marks var onclick_f = function { return function { window.open(this.href);return false; }; }; var tmpm, i = 1, msize;

while ((d = document.getElementById('minimap_mark'+i)) !== null) { d.style.display = 'none'; d.style.visibility = 'hidden'; i++; } i = 1; while (pars['mark'+i]) { if (!document.getElementById('minimap_marks_enabled').checked) { break; } tmpm = pars['mark'+i]; if (!(d = document.getElementById('minimap_mark'+i))) { var newdiv = document.createElement('div'); newdiv.setAttribute('id', 'minimap_mark'+i); document.getElementById('minimap_imgdiv').appendChild(newdiv); newdiv.style.display = 'block'; newdiv.style.position = 'absolute'; newdiv.style.zIndex = '1003'; newdiv.style.overflow = 'hidden'; newdiv.innerHTML = ' '+ ' '; }   d = document.getElementById('minimap_mark'+i); if (tmpm[4] != pars[4]) { i++; continue; }   d.style.display = 'block'; d.style.visibility = 'visible'; msize = Math.floor(11*pars[5]*pars[6])+'px'; d.style.left = Math.floor(((((tmpm[0] - 124) * 256) + (tmpm[1])) * pars[5]) - (6*pars[5]*pars[6]))+'px'; d.style.top = Math.floor(((((tmpm[2] - 121) * 256) + (tmpm[3])) * pars[5]) - (6*pars[5]*pars[6]))+'px'; d.style.width = msize; d.style.height = msize; d = d.firstChild; d.style.left = '-'+Math.floor(Math.floor((tmpm[5]-1)/2)*11*pars[5]*pars[6])+'px'; d.style.top = '-'+Math.floor((Math.floor((tmpm[5])/2) == ((tmpm[5])/2) ? 11 : 0)*pars[5]*pars[6])+'px'; d = d.firstChild;//a link d.cursor = 'default'; d.onclick = 'return false;'; d.href = ''; if (tmpm[6] != '') { d.style.cursor = 'pointer'; d.href = '/wiki/'+encodeURI(tmpm[6]); d.onclick = onclick_f; }   d = d.firstChild;//image d.alt = tmpm[6]; d.width = Math.floor(110*pars[5]*pars[6]); d.height = Math.floor(22*pars[5]*pars[6]); i++; } if (typeof reset_list == 'undefined') { reset_list = true; } minimap_codes_update(reset_list); };

minimap_mapper_add_mark = function { if (document.getElementById('minimap_loading').style.display == 'block') { return; } var i, m = 1; for (i=1; i<20; i++) { if (document.getElementById('mapper_marker_r'+i).checked) { m = document.getElementById('mapper_marker_r'+i).value; break; } } i = 1; while (minimap_map_data['mark'+i]) { i++; } minimap_map_data['mark'+i] = minimap_map_data.slice(0, 5); minimap_map_data['mark'+i][5] = m; minimap_map_data['mark'+i][6] = document.getElementById('mapper_optional_link').value.replace(/\s|%20/gi, '_'); minimap_pos; };

minimap_mapper_remove_mark = function { if (document.getElementById('minimap_loading').style.display == 'block') { return; } var tmp, i = 1, x, o, s = document.getElementById('mapper_list'); if (s.selectedIndex == -1) { return; } o = s.options[s.selectedIndex]; document.getElementById('mapper_mark_remove').disabled = true; s.remove(s.selectedIndex); minimap_map_data = minimap_map_data.slice(0, 8); for (x=0;x<s.options.length;x++) { tmp = unescape(s.options[x].value).split(',', 7); minimap_map_data['mark'+i] = []; minimap_map_data['mark'+i][0] = parseInt(tmp[0], 10); minimap_map_data['mark'+i][1] = parseInt(tmp[1], 10); minimap_map_data['mark'+i][2] = parseInt(tmp[2], 10); minimap_map_data['mark'+i][3] = parseInt(tmp[3], 10); minimap_map_data['mark'+i][4] = parseInt(tmp[4], 10); minimap_map_data['mark'+i][5] = parseInt(tmp[5], 10); minimap_map_data['mark'+i][6] = tmp[6]; i++; } minimap_pos; //0x.1x,2y.3y,4z,5zoom,6zoomm,7centermark //0x.1x,2y.3y,4z,5icon,6link };

minimap_load = function(el, url) { minimap_map_sdata = minimap_get_coords(url); minimap_map_data = minimap_get_coords(url); var pars = minimap_get_coords(url);

if (wgPageName != 'Mapper') { if (el.style.display != 'block') { el.style.display = 'block'; if (!document.getElementById('minimap_blackout')) { var newdiv = document.createElement('div'); newdiv.setAttribute('id', 'minimap_blackout'); newdiv.className = 'minimap_blackout'; newdiv.innerHTML = ' '; document.getElementsByTagName('body')[0].appendChild(newdiv); }   }    var t = document.getElementById('minimap_blackout'); t.style.display = 'block'; t.style.height = minimap_getDocHeight+'px'; } var tmpd = ' '+ ' '; var tmp = (wgPageName != 'Mapper' ? 'TibiaWiki Map '+    ' '  : ' Mapper ')+ ' '+   ' '+ ' '+ ''+ ''+ (wgPageName != 'Mapper' ? tmpd : ''); var tmpm, i = 1; while (url.indexOf('mark'+i) != -1) { tmpm = minimap_get_coords(url, 'mark'+i); minimap_map_sdata['mark'+i] = tmpm.slice(0); minimap_map_data['mark'+i] = tmpm; tmp += ''+ ' '+       ' '+ ' '+        '';    i++; } tmp += ' '+     (wgPageName == 'Mapper' ? tmpd : '')+ ' '+  ' '+  '<div style="'+(wgPageName != 'Mapper' ? 'background-color:#EEEEEE;' : '')+'">    '+ '   Simple Template:'+ ' <input id= "minimap_tcode2" readonly="readonly" type="text" value="" size="45" onclick="this.select" /> ' : '')+  '    '+  (wgPageName != 'Mapper' ? '<div onclick="window.open(minimap_data_to_url(0));document.getElementById(\'minimap_blackout\').style.display= \'none\'; var t = this, r = new RegExp(/\\bminimap_wp\\b/); while (!r.test(t.className)) { t = t.parentNode; } t.style.display = \'none\'; t.innerHTML = \' \';return false;" class="minimap_wl"> ' : )+ ;  el.innerHTML = tmp;  if (wgPageName != 'Mapper') { minimap_center_div(el); }

var ti = document.getElementById('minimap_img'); minimap_addeventlistener(ti, 'load', function {   document.getElementById('minimap_loading').style.display= 'none';    document.getElementById('minimap_maindiv').style.display= 'block';  }); minimap_pos; minimap_dragstart(document.getElementById('minimap_img')); if (wgPageName == 'Mapper') { try { document.getElementById('mapper_loading').style.display = 'none'; } catch(e) { } } };

if (wgPageName == 'Mapper') { minimap_load(document.getElementById('minimap_wf'), window.location.search.substring(1)); } else { minimap_center_div_f = function { return function { minimap_center_div; }; }; var x, tmp = document.minimap_getElementsByClassName('minimap_wp'); for (x in tmp) { if (tmp.hasOwnProperty(x)) { minimap_addeventlistener(window, 'resize', minimap_center_div_f); break; } } minimap_load_f = function { return function { minimap_load(this.nextSibling, this.href); return false; }; }; var x, tmp = document.minimap_getElementsByClassName('minimap_clic'); for (x in tmp) { if (tmp.hasOwnProperty(x)) { tmp[x].firstChild.onclick = minimap_load_f; } } } //