MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ // Edit page tool selector // -> modified from http://commons.wikimedia.org/wiki/MediaWiki:Edittools.js

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if ((matches = re.exec(document.location))) { try { return decodeURI(matches[1]); } catch (e) { } }  return null; }

function customCharInsert { if(!window.wgCustomCharInsert||!wgUserName) { return; } var spec = document.getElementById('specialchars'); var userp = document.createElement('p'); userp.className = 'specialbasic'; userp.id = 'Custom_Edittools'; userp.style.display='none';

for (var i=0;i<wgCustomCharInsert.length;i++) { var a = document.createElement('a'); a.href='#'; a.setAttribute('onclick', 'insertTags("' + wgCustomCharInsert[i].tagOpen + '","' + wgCustomCharInsert[i].tagClose + '","' + wgCustomCharInsert[i].sampleText + '"); return false;'); a.appendChild(document.createTextNode(wgCustomCharInsert[i].tagOpen + wgCustomCharInsert[i].tagClose)); userp.appendChild(a); if(i!=wgCustomCharInsert.length-1) { userp.appendChild(document.createTextNode(' · ')); } } spec.appendChild(userp); } if(queryString('action')=='edit'||queryString('action')=='submit') { addOnloadHook(customCharInsert); }

function edittoolsTabs { var spec = document.getElementById('specialchars'); if(!spec) { return; } var sb = getElementsByClassName(spec,'p','specialbasic'); if(sb.length<=1) { return; }

var sel = document.createElement('select'); sel.style.display = 'inline'; sel.setAttribute('onchange','chooseCharSubset(selectedIndex)');

for(var i=0;i<sb.length;i++) { var o = document.createElement('option'); o.appendChild(document.createTextNode(sb[i].id.replace(/_/g,' '))); sel.appendChild(o); } spec.insertBefore(sel,spec.firstChild.nextSibling); } if(queryString('action')=='edit'||queryString('action')=='submit') { addOnloadHook(edittoolsTabs); }

function chooseCharSubset(seld) { var spec = document.getElementById('specialchars'); var sb = getElementsByClassName(spec,'p','specialbasic'); for (var i = 0; i < sb.length ; i++) { sb[i].style.display = i == seld ? 'inline' : 'none'; } }

/* Code for demo widgets */ addWidgets = function { var widgets = getElementsByClassName(document.getElementById('bodyContent'),'div','wikia_widget'); for(var i = 0; i < widgets.length; i++){ widgets[i].innerHTML = " <embed src='http://images.wikia.com/common/skins/common/flash_widgets/wikia_widget.swf' FlashVars='backgroundColor=000000&backgroundImage=&borderColor=92947c&dropShadow=on&headerColor=92947c&headerAlpha=.05&headerBorderColor=000000&headline1=The Vault presents&headline1Color=CCCCCC&headline2=Most Wanted DLC Items&headline2Color=FFFFFF&clickURL=http://fallout.wikia.com&wikiURLColor=FFFFFF&wikiaLogoColor=FFFFFF&type=slideshow&slideshowImages=http://images1.wikia.nocookie.net/fallout/images/8/8b/Widget_Auto-Axe.png,http://images3.wikia.nocookie.net/fallout/images/f/ff/Widget_Gauss-Rifle.png,http://images3.wikia.nocookie.net/fallout/images/6/6f/Widget_WidPower-Armor.png,http://images3.wikia.nocookie.net/fallout/images/1/1c/Get_Shock-Sword.png&=Preview images in the widget&' quality='high' wmode='transparent' width='300' height='250' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' name='wikia_widget' /> "; } };

addOnloadHook(addWidgets); /* End of code for demo widgets */

/* Force Preview JavaScript code - Start */ // Code slightly modified from http://www.mediawiki.org/w/index.php?title=Manual:Force_preview&oldid=250009 (function {    "use strict";    /*jslint browser: true */    /*globals addOnloadHook*/    var disable_force_preview = window.disable_force_preview || false,        wgAction = window.wgAction || "view",        wgUserName = window.wgUserName || "",        wgUserGroups = window.wgUserGroups || [],        permittedGroups = ["sysop", "bureaucrat", "rollback", "bot"],        permittedUsers = ["Kwigon the sharpshooter", "Temahk"],        userName = [ wgUserName ],        userGroups = wgUserGroups || [];    if (typeof Array.prototype.intersects !== "function") {        Array.prototype.intersects = function (arr) {            var len1 = this.length, len2 = arr ? arr.length : 0, i = 0, j;            //             //    Returns true if any element in the argument array            //    is the same as an element in this array            //             for (i; i < len1; i += 1) {                j = 0; for (j; j < len2; j += 1) { if (this[i] === arr[j]) { return true; }               }            }            return false; };   }    function forcePreview { // Check if a user is permitted to bypass preview var save = document.getElementById("wpSave"), preview = document.getElementById("wpPreview"); if (!(userGroups.intersects(permittedGroups) || userName.intersects(permittedUsers))) { save.disabled = true; save.value = "Save page (use preview first)"; save.style.fontWeight = "normal"; preview.style.fontWeight = "bold"; }       // to bypass force preview, add this to your user skin JS file: // var disable_force_preview = true; }   if (wgAction === "edit" && !disable_force_preview) { //addOnloadHook(forcePreview); } }); /* Force Preview JavaScript code - End */

/* No Account No Edit Category - Start */ // Prevent users that are not logged in from adding Categories through the special interace addOnloadHook(function { if( wgUserName == null || wgUserName == "") {  var addCat = document.getElementById("csAddCategorySwitch");   if( !addCat ) { return; }   addCat.style.display = 'none'; } }); /* No Account No Edit Category - End */

if (wgAction === 'view' || wgAction === 'submit' || wgAction === 'purge') { /* infobox sidebar toggle */ $(document).ready(function {  'use strict';  if (skin !== 'oasis') { return; }  var read_cookie = function (name) {    var i, c, cl = document.cookie.split(';');    for (i = 0; i < cl.length; i++) { c = $.trim(cl[i]); if (c.indexOf(name + '=') === 0) { return c.substring(name.length + 1); } }    return null;  },  write_cookie = function (name, val) {    var date = new Date; date.setTime(date.getTime + (365 * 24 * 60 * 60 * 1000)); date = date.toGMTString;    document.cookie = name + '=' + val + '; expires=' + date + '; path=/';  },  $infobox_sidebar_toggler,  $infobox_sidebar = $('#WikiaArticle #infobox_sidebar'), $infobox_bottom = $('#WikiaArticle #infobox_bottom'),  $infobox_topleft = $('#WikiaArticle #infobox_topleft'), $infobox_topright = $('#WikiaArticle #infobox_topright'),  version_pos = function  {    $infobox_topleft.css('width', 'auto');    $infobox_topleft.css( $infobox_topleft.width + $infobox_topright.width + 10 > $infobox_topleft.parent.width ? {'top': '18px', 'width': '63'} : {'top': '5px', 'width': 'auto'} ); };  if ($infobox_sidebar.length === 1) {    $infobox_sidebar_toggler = $(' ', {'id': 'infobox_sidebar_toggler', 'href': '#'}).css({ 'position': 'absolute', 'right': '1px', 'top': '40px', 'width': '1em', 'text-align': 'center', 'font-size': 'smaller', 'line-height': '0.8em', 'color': '#006CB0', 'cursor': 'pointer' }).html('T o g g l e

S i d e b a r')   .toggle(function  { $infobox_sidebar.hide; $infobox_bottom.attr('colspan', '1'); write_cookie('infobox_sidebar_hide', '1'); version_pos; }, function { $infobox_sidebar.show; $infobox_bottom.attr('colspan', '2'); write_cookie('infobox_sidebar_hide', '0'); version_pos; });   $infobox_sidebar.siblings('td:first').children('div').append($infobox_sidebar_toggler);    if (read_cookie('infobox_sidebar_hide') === '1') { $infobox_sidebar_toggler.click; }    version_pos;  } }); /* infobox sidebar toggle end */ /* Color Transcripts */ addOnloadHook(function { $('table.npc_chat_div_r div.m3, table.npc_chat_div div.m3').each(function{$(this).html(' '+($(this).html.replace(/|| /gi, ' ').replace(/player:|player<\/i>:|player:/gi, ' -:pL:-').replace(/-:pL:-/g, ' Player :').replace(/::/g, ':').replace(/\{/g, ).replace(/\}/g, ))+' ');}); }); /* End of Color Transcripts */ /* Outfiter */ if (wgPageName === 'Outfiter') { addOnloadHook(function { $.ajax({ url: '/index.php?title=Outfiter/Code&action=raw',success: function(text) { var otext = text; text = text.slice(text.search('id="pre_outfiter1">')+19, text.search('<\/pre>')); $('head').append(''+text+' '); text = otext.slice(otext.search(' ')+4); text = text.slice(text.search('id="pre_outfiter2">')+19, text.search(' ')); $('#outfiter_container').html(text); text = otext.slice(otext.search(' ')+4); text = text.slice(text.search(' ')+4); text = text.slice(text.search('id="pre_outfiter3">')+19, text.search(' ')); $('#outfiter_script').append(''+text+' '); }}); }); } /* End of Outfiter */ /* Mapper */ addOnloadHook(function { if (wgPageName === 'Mapper' || $('a[href*="http://tibia.wikia.com/wiki/Mapper"]').size) { $.ajax({ url: '/index.php?title=Mapper/Code&action=raw', success: function(text) { text = text.slice(text.search('id="pre_mapper">')+16, text.search('<\/pre>')); $('body:first').append(''+text+' '); }}); } }); /* End Mapper */ /* Test Mapper */ addOnloadHook(function { if (wgPageName === 'Mapper/Test' || $('a[href*="http://tibia.wikia.com/wiki/Mapper/Test"]').size) { wgPageName = 'Mapper'; $.ajax({ url: '/index.php?title=Mapper/Test/Code&action=raw', success: function(text) { text = text.slice(text.search('id="pre_mapper">')+16, text.search('<\/pre>')); $('body:first').append(''+text+' '); }}); } }); /* Test Mapper */ /* Loot Statistics */ if (wgPageName === 'Loot_Statistics') { addOnloadHook(function { $.ajax({ url: '/index.php?title=Loot_Statistics/Code&action=raw', cache: false, success: function(text) { text = text.slice(text.search('id="pre_lootparser">')+21, text.search('<\/pre>')); $('#lootparser_loot_script').append(''+text+' '); }}); }); } /* End of Loot Statistics */ /* Loot Statistics checker */ if (wgPageName === 'Loot_Statistics/Checker') { addOnloadHook(function { $.ajax({ url: '/index.php?title=Loot_Statistics/Checker/Code&action=raw', cache: false, success: function(text) { text = text.slice(text.search('id="pre_lootchecker">')+22, text.search('<\/pre>')); $('#stats_data').parents('div:first').append(''+text+' '); }}); }); } /* End of Loot Statistics checker */ /* TibiaWiki:Creature_Statistics */ if (wgPageName === 'TibiaWiki:Creature_Statistics') { addOnloadHook(function { $.ajax({ url: '/index.php?title=TibiaWiki:Creature_Statistics/Code&action=raw', dataType:'text', cache: false, success: function(text) { text = text.slice(text.search('id="pre_statsparser">')+22, text.search('<\/pre>')); $('body:first').append(''+text+' '); }}); }); } /* TibiaWiki:Creature_Statistics End */ /* NPC Chat Windows */ addOnloadHook(function { $('.npc_chat_div .t3.npc_chat_can_grow, .npc_chat_div_r .t3.npc_chat_can_grow').append( $('Expand</a>').click(function {   $(this).closest('.npc_chat_div, .npc_chat_div_r').find('.m3').height('100%'); $(this).add($(this).next).remove; return false;  }), $(' - ') ); $('.npc_chat_div .t3, .npc_chat_div_r .t3').append( $('<a class="npc_chat_div_ttoggle" href="#">Hide</a>').click(function {   $(this).closest('.npc_chat_div, .npc_chat_div_r').find('.m_tr').hide; $(this).parent.find('.npc_chat_div_ttoggle').toggle; return false;  }), $('<a style="display:none;" class="npc_chat_div_ttoggle" href="#">Show</a>').click(function {   $(this).closest('.npc_chat_div, .npc_chat_div_r').find('.m_tr').show; $(this).parent.find('.npc_chat_div_ttoggle').toggle; return false;  }), $(' - '), $('<a class="npc_chat_div_swcol" href="#">Switch Color</a>').click(function {    var writeCookie = function(data) {var date=new Date;date.setTime(date.getTime+(30*24*60*60*1000));date=date.toGMTString;document.cookie='npc_transcript_color='+data+';expires='+date+';path=/';};    if ($('.npc_chat_div').size) { $('.npc_chat_div').removeClass('npc_chat_div').addClass('npc_chat_div_r'); writeCookie('white'); }    else { $('.npc_chat_div_r').removeClass('npc_chat_div_r').addClass('npc_chat_div'); writeCookie('tibia'); }    return false;  }) ); if (document.cookie.match(/npc_transcript_color[\s]?=[\s]?white/) !== null) { $('.npc_chat_div_swcol:first').click; } }); /* End of NPC Chat Windows */ /* Loot percentage data */ addOnloadHook(function { 'use strict'; var current_tibia_version = '8.6', lootparser_versions_ex = {'8.6': { /*changed*/  'Rat': '9.63',  'Spider': '9.63',  'Poison Spider': '9.63',  'Bug': '9.63',  'Massive Fire Elemental': '9.6',  'Ancient Scarab': '9.5',  'Behemoth': '9.5',  'Betrayed Wraith': '9.5',  'Blightwalker': '9.5',  'Crystal Spider': '9.5',  'Dark Torturer': '9.5',  'Defiler': '9.5',  'Demon Skeleton': '9.5',  'Draken Spellweaver': '9.5',  'Eternal Guardian': '9.5',  'Ghastly Dragon': '9.5',  'Giant Spider': '9.5',  'Gnarlhound': '9.5',  'Hand of cursed Fate': '9.5',  'Hellhound': '9.5',  'Hydra': '9.5',  'Ice Golem': '9.5',  'Juggernaut': '9.5',  'Killer Caiman': '9.5',  'Lizard Zaogun': '9.5',  'Lost Soul': '9.5',  'Mammoth': '9.5',  'Mutated Tiger': '9.5',  'Phantasm': '9.5',  'Quara Constrictor': '9.5',  'Quara Constrictor Scout': '9.5',  'Quara Hydromancer': '9.5',  'Quara Hydromancer Scout': '9.5', 'Quara Mantassin': '9.5', 'Quara Mantassin Scout': '9.5', 'Quara Pincher': '9.5', 'Quara Predator Scout': '9.5', 'Sea Serpent': '9.5', 'Wailing Widow': '9.5', 'Undead Dragon': '9.5', 'Wyvern': '9.5', 'Blazing Fire Elemental': '9.1', 'Blistering Fire Elemental': '9.1', 'Carrion Worm': '9.1', 'Draken Abomination': '9.1', 'Dwarf Guard': '9.1', 'Earth Elemental': '9.1', 'Fire Overlord': '9.1', 'Hellfire Fighter': '9.1', 'Jagged Earth Elemental': '9.1', 'Muddy Earth Elemental': '9.1', 'Stone Golem': '9.1', 'Tarantula': '9.1', 'Vampire': '9.1', 'Witch': '9.1', 'Worker Golem': '9.1', /*bosses*/ 'Ethershreck': '9.5', 'Gorgo': '9.5', 'Kerberos': '9.5', 'Stonecracker': '9.5', 'Deathbine': '9.2', 'Esmeralda': '9.2', 'Flameborn': '9.2', 'Fleshcrawler': '9.2', 'Hide': '9.2', 'Leviathan': '9.2', 'Ribstride': '9.2', 'Shardhead': '9.2', 'Sulphur Scuttler': '9.2', 'The Bloodtusk': '9.2', 'The Bloodweb': '9.2', 'The Many': '9.2', 'The Noxious Spawn': '9.2', 'The Old Widow': '9.2', 'The Snapper': '9.2', 'Thul': '9.2', /*new*/ 'Adventurer': '9.8', 'Angry Adventurer': '9.8', 'Corym Charlatan': '9.8', 'Corym Skirmisher': '9.8', 'Corym Vanguard': '9.8', 'Drillworm': '9.8', 'Emerald Damselfly': '9.8', 'Little Corym Charlatan': '9.8', 'Lost Basher': '9.8', 'Lost Husher': '9.8', 'Lost Thrower': '9.8', 'Marsh Stalker': '9.8', 'Party Skeleton': '9.8', 'Pigeon': '9.8', 'Salamander': '9.8', 'Swampling': '9.8', 'Swamp Troll': '9.8', 'Water Buffalo': '9.8', 'Young Troll': '9.63', 'Abyssador': '9.6', 'Deathstrike': '9.6', 'Gnomevil': '9.6', 'Vesperoth': '9.6', 'Armadile': '9.6', 'Cliff Strider': '9.6', 'Crystalcrusher': '9.6', 'Damaged Crystal Golem': '9.6', 'Dragonling': '9.6', 'Enraged Crystal Golem': '9.6', 'Enslaved Dwarf': '9.6', 'Hideous Fungus': '9.6', 'Humongous Fungus': '9.6', 'Humorless Fungus': '9.6', 'Ironblight': '9.6', 'Lava Golem': '9.6', 'Lost Berserker': '9.6', 'Magma Crawler': '9.6', 'Modified Gnarlhound': '9.6', 'Mushroom Sniffer': '9.6', 'Orewalker': '9.6', 'Stone Devourer': '9.6', 'Vulcongra': '9.6', 'Weeper': '9.6', 'Wiggler': '9.6', 'Bretzecutioner': '9.5', 'Bruise Payne': '9.5', 'Chopper': '9.5', 'Fazzrah': '9.5', 'Fleshslicer': '9.5', 'Hemming': '9.5', 'Maw': '9.5', 'Mindmasher': '9.5', 'Paiz the Pauperizer': '9.5', 'Rotspit': '9.5', 'Shadowstalker': '9.5', 'Tormentor': '9.5', 'Tromphonyte': '9.5', 'Zanakeph': '9.5', 'Jaul': '9.4', 'Obujos': '9.4', 'Tanjis': '9.4', 'Calamary': '9.4', 'Crawler': '9.4', 'Deepling Guard': '9.4', 'Deepling Spellsinger': '9.4', 'Deepling Warrior': '9.4', 'Deepling Worker': '9.4', 'Fish (Creature)': '9.4', 'Floor Blob': '9.4', 'Hive Pore': '9.4', 'Insectoid Worker': '9.4', 'Jellyfish': '9.4', 'Kollos': '9.4', 'Ladybug': '9.4', 'Lady Bug': '9.4', 'Lesser Swarmer': '9.4', 'Manta Ray': '9.4', 'Northern Pike (Creature)': '9.4', 'Slippery Northern Pike': '9.4', 'Shark': '9.4', 'Spidris': '9.4', 'Spidris Elite': '9.4', 'Spitter': '9.4', 'Swarmer': '9.4', 'Swarmer Hatchling': '9.4', 'Waspoid': '9.4', 'Askarak Demon': '9.1', 'Askarak Lord': '9.1', 'Askarak Prince': '9.1', 'Bog Frog': '9.1', 'Clay Guardian': '9.1', 'Crystal Wolf': '9.1', 'Death Priest': '9.1', 'Deepling Scout': '9.1', 'Desperate White Deer': '9.1', 'Diamond Servant': '9.1', 'Donkey': '9.1', 'Dromedary': '9.1', 'Elder Mummy': '9.1', 'Elf Overseer': '9.1', 'Energized Raging Mage': '9.1', 'Enraged White Deer': '9.1', 'Feverish Citizen': '9.1', 'Filth Toad': '9.1', 'Firestarter': '9.1', 'Ghoulish Hyaena': '9.1', 'Golden Servant': '9.1', 'Grave Guard': '9.1', 'Groam': '9.1', 'Honour Guard': '9.1', 'Horestis': '9.1', 'Horse': '9.1', 'Insectoid Scout': '9.1', 'Iron Servant': '9.1', 'Kraknaknork': '9.1', 'Kraknaknork\'s Demon': '9.1', 'Mad Mage': '9.1', 'Raging Mage': '9.1', 'Sacred Spider': '9.1', 'Sandstone Scorpion': '9.1', 'Shaburak Demon': '9.1', 'Shaburak Lord': '9.1', 'Shaburak Prince': '9.1', 'Slug': '9.1', 'Spider Queen': '9.1', 'Starving Wolf': '9.1', 'Thornfire Wolf': '9.1', 'Tomb Servant': '9.1', 'Weakened Demon': '9.1', 'White Deer': '9.1', 'Yielothax': '9.1' } }, droppedby_perc_data = {}, loot_perc_data = {}, loot_perc_datao = , loot_perc_datap = , loot_perc_dataoa = true, droppedby_inaccurate = [], droppedby_minimum = 500, loot_minimum = 500, loot_perc_sort = function (sid) { $('#' + sid).each(function { var t = $(this).html.replace(/<img[^>]*id="(?:loot|droppedby)_perc_load"[^>]*>/, ''), sp = t.match(/(<span[\s\S]*>[^\d]*?<\/span>)/i); sp = (sp === null ?  : sp[1]); t = $.trim(t.replace(sp, )); while (t.substr(-1) === '.') { t = t.substr(0, t.length - 1); } t = t.split(','); t.sort(function (a, b) {b = (b.match(/\(([\d\.]+)%\)/) || [0, 0])[1]; a = (a.match(/\(([\d\.]+)%\)/) || [0, 0])[1]; return parseFloat(b) - parseFloat(a); }); $.each(t, function (i, v) { t[i] = $.trim(v); }); $(this).html(t.join(', ') + '. ' + sp); }); }, loot_perc_get_data = function (text, cname) { var get_it = function (version) { version = version.replace(/\\/g, '').replace(/\./g, '\\.'); var items, x, r = new RegExp('version[\\s]?=[\\s]?' + version + '[^}\\d]*?kills[\\s]?=[\\s]?(\\d*)([\\s\\S]*?)}' + '}'), matches = text.match(r); if (matches !== null && matches.length === 3 && parseInt(matches[1], 10) > 0) { loot_perc_data.kills = parseInt(matches[1], 10); items = matches[2].split('|'); for (x = 0; x < items.length; x++) { if (items[x].match(/times:/)) { loot_perc_data[$.trim(items[x].split(',')[0])] = (Math.round((parseInt(items[x].split('times:')[1].split(',')[0], 10) / parseInt(matches[1], 10)) * 10000) / 100) + '%'; }     }    }  };  if (text !== false) { cname = cname.replace(/_/g, ' '); if (lootparser_versions_ex.hasOwnProperty(current_tibia_version) &&   lootparser_versions_ex[current_tibia_version].hasOwnProperty(cname)) { get_it(lootparser_versions_ex[current_tibia_version][cname]); }   else { get_it(current_tibia_version); } } }, loot_perc_put_data = function { var t, off, ex; if (typeof loot_perc_data.kills === 'undefined') { off = $('#loot_perc_text').offset; $('body:first').append(     $(' There is no statistics information to show percentages ').attr('id', 'loot_perc_not_enough')     .css({'display': 'none', 'z-index': '999', 'top': String(off.top - 20) + 'px', 'left': String(off.left - 35) + 'px', 'position': 'absolute', 'background-color': '#0038d8', 'border-radius': '4px', 'box-shadow': '0px 0px 5px', 'color': '#ffffff', 'margin': '0px', 'padding': '10px 20px' }).fadeIn('slow', function { setTimeout(function  { $('#loot_perc_text').hide; $('#loot_perc_not_enough').fadeOut('slow'); }, 4000); })    ); $('#loot_perc_loot').html(loot_perc_datao); } else { if (loot_perc_data.kills < loot_minimum) { if ($('#loot_perc_inaccurate').size === 0) { $('#loot_perc_text').after(         $('  ').attr('id', 'loot_perc_inaccurate').append( $(' i ').attr('title', '%s are not accurate because the low amount of kills (' + loot_perc_data.kills + ' kills).').css({             'display': 'inline-block', 'color': '#FFFFFF', 'background-color': '#003AD9',              'border-radius': '14px', 'font-size': '10px', 'line-height': '14px', 'width': '14px',              'text-align': 'center', 'cursor': 'pointer'            }).click(function  { alert('%s are not accurate because the low amount of kills (' + loot_perc_data.kills + ' kills).'); }) ).css('text-align', 'center')       ); }     $('#loot_perc_text').show; }   $('#loot_perc_text').attr('title', 'Based on ' + loot_perc_data.kills + ' kills'); $('#loot_perc_loot a').each(function {      ex = {'gp': 'Gold Coin', 'skull (item)': 'Skull', 'black skull (item)': 'Black Skull',            'rusty armor (common)': 'Rusty Armor', 'rusty armor (semi-rare)': 'Rusty Armor', 'rusty armor (rare)': 'Rusty Armor',            'rusty legs (common)': 'Rusty Legs', 'rusty legs (semi-rare)': 'Rusty Legs', 'rusty legs (rare)': 'Rusty Legs'      };      t = decodeURI($(this).attr('href').replace(/.*\/(.*?)$.*/, '$1').replace(/_/g, ' '));      if (ex.hasOwnProperty(t.toLowerCase)) { t = ex[t.toLowerCase]; }      if (loot_perc_data.hasOwnProperty(t)) { $(this).after(' (' + loot_perc_data[t] + ')'); }    }); loot_perc_sort('loot_perc_loot'); loot_perc_datap = $('#loot_perc_loot').html; } }, loot_perc_loaded = function (text, cname) { loot_perc_get_data(text, cname); $('#loot_perc_load').hide; loot_perc_put_data; loot_perc_dataoa = false; }, loot_perc_load = function { if (loot_perc_dataoa && loot_perc_datap === '') { $('#loot_perc_loot').html($('#loot_perc_loot').html.replace(/[\s]?\((?:semi-|very )?rare\)[\s]?/g, '')) .prepend('<img id="loot_perc_load" src="http://images4.wikia.nocookie.net/tibia/en/images/8/87/Ajax_Load_Image.gif" alt="Loading %s" />'); $.ajax({url: '/index.php?title=Loot_Statistics:' + wgTitle + '&action=raw', dataType: 'text', timeout: 15000,     success: function (text) { loot_perc_loaded(text, wgTitle); }, error: function  { loot_perc_loaded(false); }}); } else if (loot_perc_dataoa) { $('#loot_perc_loot').html(loot_perc_datap); $('#loot_perc_inaccurate').show; loot_perc_dataoa = false; } else { $('#loot_perc_loot').html(loot_perc_datao); $('#loot_perc_inaccurate').hide; loot_perc_dataoa = true; } }, droppedby_perc_put_data = function { var t; $('#droppedby_perc_creat a').each(function  {    var d, t = $(this).text; if (droppedby_perc_data.hasOwnProperty(t)) {      d = droppedby_perc_data[t]; if (d[1] < droppedby_minimum) { droppedby_inaccurate.push(t); }      $(this).after($(' (' + d[0] + ') ').attr('title', 'Based on ' + d[1] + ' kills').css('cursor', 'pointer'));    }  }); loot_perc_sort('droppedby_perc_creat'); $('#droppedby_perc_creat span').css('color', '#0148C2').click(function { window.open('/wiki/Loot_Statistics:' + $(this).prev.text); }); if (droppedby_inaccurate.length > 0) { t = 'Some %s are not accurate because the low amount of kills:\n' + droppedby_inaccurate.join('\n'); $('#droppedby_perc_text').after( $(' ').append( $(' i ').attr('title', t).css({       'display': 'inline-block', 'color': '#FFFFFF', 'background-color': '#003AD9',        'border-radius': '14px', 'font-size': '10px', 'line-height': '14px', 'width': '14px',        'text-align': 'center', 'cursor': 'pointer'      }).click(function  { alert(t); }) ).css('text-align', 'center') ); } }, droppedby_perc_get_data = function (text, cname, item) { if (typeof item === 'undefined') { item = wgTitle; } var ex = {'skull (item)': 'Skull', 'black skull (item)': 'Black Skull', 'rusty armor (common)': 'Rusty Armor', 'rusty armor (semi-rare)': 'Rusty Armor', 'rusty armor (rare)': 'Rusty Armor', 'rusty legs (common)': 'Rusty Legs', 'rusty legs (semi-rare)': 'Rusty Legs', 'rusty legs (rare)': 'Rusty Legs' }, get_it = function (version) { version = version.replace(/\\/g, '').replace(/\./g, '\\.'); var r = new RegExp('version[\\s]?=[\\s]?' + version + '[^}\\d]*?kills[\\s]?=[\\s]?(\\d*)[^}]*?name[\\s]?=[\\s]?(.*)[|\\r\\n][^}]*?[|][\\s]?(' + (item.replace(/[-[\]{}*+?.,\\^$|#\s]/g, "\\$&")) + ')[\\s]?,[^}\\r\\n]*?times:(\\d*)'), matches = text.match(r); if (matches !== null && matches.length === 5 && matches[2] && parseInt(matches[1], 10) > 0) { droppedby_perc_data[matches[2]] = [(Math.round((parseInt(matches[4], 10) / parseInt(matches[1], 10)) * 10000) / 100) + '%', parseInt(matches[1], 10)]; } };  if (text !== false) { if (ex.hasOwnProperty(item.toLowerCase)) { item = ex[item.toLowerCase]; } cname = cname.replace(/_/g, ' '); if (lootparser_versions_ex.hasOwnProperty(current_tibia_version) &&   lootparser_versions_ex[current_tibia_version].hasOwnProperty(cname)) { get_it(lootparser_versions_ex[current_tibia_version][cname]); }   else { get_it(current_tibia_version); } } }, droppedby_perc_loading = 0, droppedby_perc_loaded = function (text, cname) { droppedby_perc_loading--; droppedby_perc_get_data(text, cname); if (droppedby_perc_loading < 1) { $('#droppedby_perc_load').hide; droppedby_perc_put_data; } }, droppedby_perc_load = function { $('#droppedby_perc_text').hide; var t = $('#droppedby_perc_creat').text.replace(/\./g, '').split(','); droppedby_perc_loading = t.length; $('#droppedby_perc_creat').prepend('<img id="droppedby_perc_load" src="http://images4.wikia.nocookie.net/tibia/en/images/8/87/Ajax_Load_Image.gif" alt="Loading %s" />'); $.each(t, function (i, v) {   t[i] = $.trim(v);    $.ajax({url: '/index.php?title=Loot_Statistics:' + t[i] + '&action=raw', dataType: 'text', timeout: 15000, success: function (text) { droppedby_perc_loaded(text, t[i]); }, error: function { droppedby_perc_loaded(false); }});  }); }; $('#droppedby_perc_tr>td:eq(0)') .append($('<a id="droppedby_perc_text" style="font-size:80%" href="#">(Load %)</a>').click(function {droppedby_perc_load; return false; })) .next.attr('id', 'droppedby_perc_creat'); loot_perc_datao = $('#loot_perc_tr>td:eq(0)') .append($('<a id="loot_perc_text" style="font-size:80%" href="#"">(Toggle % view)</a>').click(function {loot_perc_load; return false; })) .next.attr('id', 'loot_perc_loot').html; }); /* End of Loot percentage data */ /* Calculators */ if (wgPageName === 'Calculators') { $(document).ready(function  { $.ajax({ url: '/index.php?title=Calculators/Code&action=raw', dataType:'text', success: function(text) {  text = text.slice(text.search('id="pre_calculators">')+21, text.search('<\/pre>'));  $('body:first').append('<script type="text/javascript">'+text+' '); }}); }); } /* End of Calculators */ /* Quest transcript linker start */ $(document).ready(function  {  if ($.inArray('Quest Spoiling Pages', wgCategories) === -1) { return; }  var transcripts = [], container = (skin === 'oasis' ? 'WikiaArticle' : 'bodyContent'),  acss = {'font-size': 'x-small', 'font-weight': 'normal', 'margin-left': '30px'}, $transcripts_parent_lis = $('table#toc').find('a[href*="\\#Transcript"]') /*.filter(function { return !new RegExp('_\\d+$', 'i').test($(this).attr('href')); })*/ .parent, jq_escape = function (t) { return t.replace(/([\]\\!"#$%&'*+,.\/:;<=>?@\[\^`{|}~])/g, '\\$1'); }, re_escape = function (t) { return t.replace(/[\-\[\]{}*+?.,\\\^$|#\s]/g, '\\$&'); };  $transcripts_parent_lis.find('a[href$="_2"][href*="\\#"]').each(function  {    var t = $(this).attr('href').split(/#/);    if (t.length > 1) { transcripts.push(t[t.length - 1]); }  });  $.each(transcripts, function (i) {    var v = transcripts[i], v1 = v.replace(/_2$/, ),    $method_a, t, jump_to_text = ;    if ($transcripts_parent_lis.find('a').filter(function  {      return new RegExp('#' + re_escape(v1) + '$', 'i').test($(this).attr('href') || );    }).length === 0) {      if (($method_a = $('table#toc').find('a').filter(function  {        return new RegExp('#' + re_escape(v1) + '$', 'i').test($(this).attr('href') || );      })).length === 1) {        v1 = $method_a.attr('href').split(/#/); v1 = v1[v1.length - 1]; while ($method_a.closest('li').parent.closest('li').length) { $method_a = $method_a.closest('li').parent.closest('li').children('a:first'); t = $method_a.children('.toctext').text; if (t.match(/spoiler|method/i)) { jump_to_text = t; } }       $('#' + container + ' #' + jq_escape(v)).parent.append(          $('<a />', {'href': '#' + v1}).css(acss).text('Jump to ' + (jump_to_text || 'matching title')),          $('<a />', {'href': '#toc'}).css(acss).css('margin-left', '10px').text('Jump to TOC')        ); $('#' + container + ' #' + jq_escape(v1)).parent.append(         $('<a />', {'href': '#' + v}).css(acss).text('Jump to Transcript'),          $('<a />', {'href': '#toc'}).css(acss).css('margin-left', '10px').text('Jump to TOC')        ); }   }  }); }); /* Quest transcript linker end */ }

(function {    "use strict";    // button to display all spoilers on the Achievements page    if (wgPageName === 'Achievements') {        addOnloadHook(function  { var ach_shown = false, button = document.createElement('button'); button.appendChild(document.createTextNode("Show/Hide all spoilers")); $('#ach-tools').append(button).click(function {                $('div[id$=_content]').each(function  { this.parentNode.style.visibility = ach_shown ? 'hidden' : 'visible'; this.parentNode.style.position = ach_shown ? 'absolute' : 'static'; });               ach_shown = !ach_shown;            }); });   } });

/* custom spoiler toggle (used by Template:Infobox Achievement) */ function custom_spoiler { var button = document.createElement('button'); //define variable button button.appendChild(document.createTextNode("Show/Hide spoiler")); //add text to this button $(".custom_spoiler_button").append(button).click(function {      $(".custom_spoiler_content").toggle('slow');    }); } if (wgAction === 'view' || wgAction === 'submit' || wgAction === 'purge') { addOnloadHook(custom_spoiler); } /* end of custom spoiler toggle */