Loot Statistics/Code

//  /*jslint devel: true, browser: true, white: true, indent: 2, plusplus: true, sloppy: true */ /*global $, wgUserName */

var current_tibia_version = '8.6', lootparser_template1_max_tibia_version = '8.54', lootparser_tibia_versions = {'8.4': '8.4', '8.5': '8.5', '8.54': '8.54', '8.6': '8.6 to 9.1'}, lootparser_versions_ex = {'8.6': { 'Witch': '9.1', 'Draken Abomination': '9.1', 'Draken Spellweaver': '9.1', 'Worker Golem': '9.1', 'Stone Golem': '9.1', 'Jagged Earth Elemental': '9.1', 'Earth Elemental': '9.1', 'Muddy Earth Elemental': '9.1', 'Fire Overlord': '9.1', 'Blistering Fire Elemental': '9.1', 'Blazing Fire Elemental': '9.1', 'Carrion Worm': '9.1', 'Dwarf Guard': '9.1', 'Hellfire Fighter': '9.1', 'Eternal Guardian': '9.1', 'Swamp Troll': '9.1', 'Behemoth': '9.1', 'Vampire': '9.1', 'Tarantula': '9.1' } }, /* Code used for Loot_Statistics */ lootparser_use_version, lootparser_use_loot2, ajax_load_bar = new Image; ajax_load_bar.src = "http://images3.wikia.nocookie.net/tibia/en/images/d/de/Ajax_Load_Bar.gif";

function stripslashes(str) { /*jslint regexp: true, unparam: true */ var r = String(str).replace(/\\(.?)/g, function (s, n1) {   switch (n1) {      case '\\': return '\\';      case : return ;      default: return n1;    }  }); /*jslint regexp: false, unparam: false */ return r; }

function ucwords(str) { /*jslint regexp: true */ str = String(str).replace(/^(.)|\s(.)|-(.)/g, function ($1) { return $1.toUpperCase; }); /*jslint regexp: false */ return str.replace(/( Of The | Of A | Of A | On A | Of | The )/, function ($1) { return $1.toLowerCase; }); } function array_sort(inputArr, numeric, by_key, reverse, sub_key) { var tmp_arr = {}, valArr = [], keyArr = [], keys = [], sorter, i, k, populateArr = [], is_numeric = function (v) { v = parseFloat(String(v).replace('|', '')); return (typeof v === 'number' && !isNaN(v)); }, bubbleSort; if (typeof numeric === 'undefined') { numeric = false; } if (typeof by_key === 'undefined') { by_key = false; } if (typeof reverse === 'undefined') { reverse = false; } if (typeof sub_key === 'undefined') { sub_key = ''; } if (numeric) { sorter = function (a, b) { a = parseFloat(String(a).replace('|', )) || 0; b = parseFloat(String(b).replace('|', )) || 0; return (reverse ? b - a : a - b); }; } else { sorter = function (a, b) { var x = a, y = b, tmp; if (!is_numeric(a) && !is_numeric(b)) { tmp = (function (a, b) { a = a.search(/[a-z]/); b = b.search(/[a-z]/); if ((a !== 0 && b !== 0) || a === b) { return 0; } if (a === 0) { return -1; } if (b === 0) { return 1; } }(x, y)); if (tmp !== 0) { return tmp * (reverse ? -1 : 1); } if (a.search(/a[n]? /i) === 0) { a = a.substr(a.indexOf(' ') + 1); } if (b.search(/a[n]? /i) === 0) { b = b.substr(b.indexOf(' ') + 1); } if (a === b) { return 0; } if (a > b) { return (reverse ? -1 : 1); } return (reverse ? 1 : -1); }     else { a = parseFloat(a) || 0; b = parseFloat(a) || 0; return (reverse ? b - a : a - b); } }; }  if (by_key) { /*Make a list of key names*/ for (k in inputArr) { if (inputArr.hasOwnProperty(k)) { keys.push(k); } } keys.sort(sorter); /*Rebuild array with sorted key names*/ for (i = 0; i < keys.length; i++) { k = keys[i]; tmp_arr[k] = inputArr[k]; } for (i in tmp_arr) { if (tmp_arr.hasOwnProperty(i)) { populateArr[i] = tmp_arr[i]; } } } else { bubbleSort = function (keyArr, inputArr, sub_key) { var i, j, tempValue, tempKeyVal, ret; for (i = inputArr.length - 2; i >= 0; i--) { for (j = 0; j <= i; j++) { ret = (sub_key === '') ? sorter(inputArr[j + 1], inputArr[j]) : sorter(inputArr[j + 1][sub_key], inputArr[j][sub_key]); if (ret < 0) { tempValue = inputArr[j]; inputArr[j] = inputArr[j + 1]; inputArr[j + 1] = tempValue; tempKeyVal = keyArr[j]; keyArr[j] = keyArr[j + 1]; keyArr[j + 1] = tempKeyVal; }       }      }    }; /*Get key and value*/ for (k in inputArr) { if (inputArr.hasOwnProperty(k)) { valArr.push(inputArr[k]); keyArr.push(k); } } /*Sort our new temporary arrays*/ try { bubbleSort(keyArr, valArr, sub_key); } catch (e) { return false; } /*Repopulate the old array*/ for (i = 0; i < valArr.length; i++) { populateArr[keyArr[i]] = valArr[i]; } } return populateArr; } function lootparser_numcs(n) { n = String(n); while ((/\d{4}/).test(n)) { n = n.replace(/(\d{3},|\d{3}$)/, ',$1'); } return n; }

var lootparser_s_words = {'*Knife': 'Knives', '*Piece of *': 'Pieces of ', '*Bunch of *': 'Bunches of '}; /*Exceptions*/ function lootparser_to_plural(t) { var x, lastletter; for (x in lootparser_s_words) { if (lootparser_s_words.hasOwnProperty(x)) { if ((new RegExp('^' + x.replace(/\*/g, '.*?') + '$')).test(t)) { return t.replace(x.replace(/\*/g, ''), lootparser_s_words[x]); } } } if (typeof lootparser_s_words[t.substr(1 + t.lastIndexOf(' '))] !== 'undefined') { return t.substr(0, 1 + t.lastIndexOf(' ')) + lootparser_s_words[t.substr(1 + t.lastIndexOf(' '))]; } lastletter = t.substr(-1); /*jslint regexp: true */ if (lastletter === 's' || lastletter === 'h' || (lastletter === 'o' && t.match(/.*[^aeiou]o$/i))) { t += 'es'; } else if (lastletter === 'y') { t = t.substr(0, t.length - 1) + 'ies'; } else { t += 's'; } /*jslint regexp: false */ return t; } var lootparser_creature_special_names = {'Arkhothep': 'Arkhothep (Creature)', 'Armenius': 'Armenius (Creature)', 'Avalanche': 'Avalanche (Creature)', 'Gamemaster': 'Gamemaster (Creature)', 'Hacker': 'Hacker (Creature)', 'Pythius the Rotten': 'Pythius the Rotten (Creature)', 'Slime': 'Slime (Creature)', 'Thief': 'Thief (Creature)', 'Yalahari': 'Yalahari (Creature)'}; function lootparser_pagename(t, us) { if (typeof us === 'undefined') { us = false; } t = t.replace(/_/g, ' '); if (typeof lootparser_creature_special_names[t] !== 'undefined') { t = lootparser_creature_special_names[t]; } return (us ? t.replace(/ /g, '_') : t); } var lootparser_p_words = {'Cookies': 'Cookie', '*Pieces of *': 'Piece of ', '*Bunches of *': 'Bunch of ', 'Haunches of *': 'Haunch of '}; /*Exceptions*/ var lootparser_p_ends = {'she': 'sh', 'ie': 'y', 've': 'fe', 'oe': 'o', 'ze': 'z'}; /*Exceptions of endings (after removing the last 's')*/ function lootparser_to_singular(t) { var x, lastletter; for (x in lootparser_p_words) { if (lootparser_p_words.hasOwnProperty(x)) { if ((new RegExp('^' + x.replace(/\*/g, '.*?') + '$')).test(t)) { return t.replace(x.replace(/\*/g, ''), lootparser_p_words[x]); } } } lastletter = t.slice(t.length - 1); if (lastletter === 's') { t = t.slice(0, t.length - 1); /*remove the s*/ lastletter = t.slice(t.length - 3); /*check last 3 letters*/ if (typeof lootparser_p_ends[lastletter] !== 'undefined') { t = t.slice(0, t.length - 3) + lootparser_p_ends[lastletter]; } lastletter = t.slice(t.length - 2); /*check last 2 letters*/ if (typeof lootparser_p_ends[lastletter] !== 'undefined') { t = t.slice(0, t.length - 2) + lootparser_p_ends[lastletter]; } } return t; } /* a is item name in singular, b is item max count */ function lootparser_wiki_links(a, b) { a = stripslashes(a); if (a === 'Empty') { return 'Empty'; } if (b < 2) { return  + a + ; } var ap = lootparser_to_plural(a); if (ap.substr(0, a.length) === a) { return  + a +  + ap.substr(a.length); } else { return  + ap + ; } } function lootparser_array_to_wiki2(inp) { var r, x, tmp; /*Sort*/ inp = array_sort(inp, false, true); tmp = {'version': inp.version, 'kills': inp.kills, 'name': inp.name}; /*Excluding named parameters from sort*/ delete inp.version; delete inp.kills; delete inp.name; if (typeof inp.Empty !== 'undefined') { tmp.Empty = inp.Empty; delete inp.Empty; } /*Making 'Empty' the first one*/ inp = array_sort(inp, true, false, true, 'times'); for (x in inp) { if (inp.hasOwnProperty(x)) { tmp[x] = inp[x]; } } inp = tmp; r = '{' + '{Loot2\r\n|version=' + inp.version + '\r\n|kills=' + inp.kills + '\r\n|name=' + inp.name + '\r\n'; for (x in inp) { if (inp.hasOwnProperty(x)) { if (typeof inp[x] === 'object') { r += '|' + x + ', times:' + inp[x].times + (inp[x].min > 0 ? (', amount:' + (inp[x].min === inp[x].max ? inp[x].min : String(inp[x].min) + '-' + String(inp[x].max))) : '') + (inp[x].total > 0 ? ', total:' + inp[x].total : '') + '\r\n'; } } } r += '}' + '}\r\n'; return r; } function lootparser_array_to_wiki1(inp) { var r, x, tmp, av_gold = 0; /*Sort*/ inp = array_sort(inp, false, true); tmp = {'version': inp.version, 'kills': inp.kills, 'name': inp.name}; /*Excluding named parameters from sort*/ delete inp.version; delete inp.kills; delete inp.name; if (typeof inp.Empty !== 'undefined') { tmp.Empty = inp.Empty; delete inp.Empty; } /*Making 'Empty' the first one*/ inp = array_sort(inp, true, false, true, 'total'); for (x in inp) { if (inp.hasOwnProperty(x)) { tmp[x] = inp[x]; } } inp = tmp; r = '{' + '{Loot\r\n|version=' + inp.version + '\r\n|kills=' + inp.kills + '\r\n|name=' + inp.name + '\r\n'; for (x in inp) { if (inp.hasOwnProperty(x)) { if (typeof inp[x] === 'object') { if (x.substr(0, 9) === 'Gold Coin') { av_gold = Math.round((inp[x].total / inp.kills) * 100) / 100; } r += '|' + lootparser_wiki_links(x, 1) + ', ' +   inp[x].total + '\r\n'; } } } r += '}' + '}\r\n' + ' Average gold: ' + av_gold; return r; }

/* Returns [, , ] textold can be an input from a wiki textarea textnew should be generated by lootparser_loot_process Gives alert and returns false on failure*/ function lootparser_add(textold, textnew, wysiwygtag) { var errors = ['Wrong data in New Statistics', 'Wrong data in Old Statistics', 'Names of creatures doesn\'t match', 'names/kills/version is missing'], textolda, textoldo, textnewa, textoldao = {}, textnewao = {}, x, tmp, matches, matches_len = 0, vo, vn, textold_match = false, out, res; if (typeof wysiwygtag === 'undefined') { wysiwygtag = true; } textoldo = textold; /*original old text*/ textnew = textnew.slice(textnew.search('{' + '{'), textnew.search('}' + '}') + 2); /*Take only the Template part*/ lootparser_use_loot2 = (textnew.match(/\{\{Loot[2]{0,1}/).join('').indexOf('2') >= 0); /*Determine version of loot data on "new"*/ textnew = textnew.slice(textnew.search(/\|/) + 1, textnew.search('}')); /*Take only the parameters*/ textnewa = textnew.split(/[\s]{1,2}\|/); /*make it an array*/ for (x in textnewa) { if (textnewa.hasOwnProperty(x) && typeof textnewa[x] !== 'undefined') {/*parse values into an associative array*/ if (textnewa[x].search('=') !== -1) { tmp = textnewa[x].split('='); tmp[0] = $.trim(tmp[0]); if (tmp[0] === 'version') { textnewao.version = $.trim(tmp[1]); } else if (tmp[0] === 'kills') { textnewao.kills = parseInt($.trim(tmp[1]), 10); } else if (tmp[0] === 'name') { textnewao.name = ucwords($.trim(tmp[1])); } }   else { if (textnewa[x].search(',') === -1) { alert(errors[0] + '(1)'); return false; } textnewa[x] = $.trim((textnewa[x].substr(0, 1) === '|') ? textnewa[x].substr(1) : textnewa[x]); /*jslint regexp: true */ tmp = (lootparser_use_loot2 ?           textnewa[x].match(/(.*?), ?(?:times:(\d*),? ?)(?:amount:(\d*)-?(\d*))?,? ?(?:total:(\d*))?/) :           textnewa[x].match(/(.*?), ?(?:(\d*))?/)      ); /*jslint regexp: false */ if (tmp === null || typeof tmp[1] === 'undefined' || typeof tmp[2] === 'undefined' || tmp[1] ===  || tmp[2] === ) { alert(errors[0] + '(2)'); return false; } tmp[1] = tmp[1].split('[').join().split(']', 1).join().split('|', 1).join(''); tmp[2] = parseInt(tmp[2], 10); textnewao[tmp[1]] = {}; if (lootparser_use_loot2) { tmp[3] = (typeof tmp[3] === 'undefined' || tmp[3] === '') ? 0 : parseInt(tmp[3], 10); tmp[4] = (typeof tmp[4] === 'undefined' || tmp[4] === '') ? tmp[3] : parseInt(tmp[4], 10); tmp[5] = (typeof tmp[5] === 'undefined' || tmp[5] === '') ? 0 : parseInt(tmp[5], 10); textnewao[tmp[1]].times = tmp[2]; textnewao[tmp[1]].min = tmp[3]; textnewao[tmp[1]].max = tmp[4]; }     textnewao[tmp[1]].total = (lootparser_use_loot2 ? tmp[5] : tmp[2]); } } } /*Looking for matching version number on textold & textnew*/ matches = (lootparser_use_loot2 ?           textold.match(/\{\{Loot2\s*?\|[\s]{0,1}version=[\s\S]*?[\s]{0,3}?\|[\s\S]*?\}\}(?:[\s\S]{0,20}Average [\[]{0,2}gold[\]]{0,2}:[\s]{0,3}[\d\.]*[\s]?[\w]{0,6}|[\s\S]*?)/gi) :            textold.match(/\{\{Loot\s*?\|[\s]{0,1}version=[\s\S]*?[\s]{0,3}?\|[\s\S]*?\}\}(?:[\s\S]{0,20}Average [\[]{0,2}gold[\]]{0,2}:[\s]{0,3}[\d\.]*[\s]?[\w]{0,6}|[\s\S]*?)/gi)  ); for (x in matches) { if (matches.hasOwnProperty(x)) { matches_len++; } } if (typeof textnewao.version !== 'undefined' && matches_len > 0) { for (x in matches) { if (matches.hasOwnProperty(x) && typeof matches[x] === 'string') {/* Fix for IE*/ vo = matches[x].match(/[\s\S]*version=([\s\S]*?)[\s]{0,3}?\|[\s\S]*/i)[1]; vn = textnew.match(/[\s\S]*version=([\s\S]*?)[\s]{0,3}?\|[\s\S]*/i)[1]; if (vo === vn) { textold_match = matches[x]; break; }   } }  }  if (textold_match === false) { textoldao = textnewao; }/*will insert the new loot at beginning of page*/ else { /*will add the new loot to an existing one*/ textold = textold_match; textold = textold.slice(textold.search('{' + '{'), textold.search('}' + '}') + 2); /*Take only the Template part*/ textold = textold.slice(textold.search(/\|/) + 1, textold.search('}')); /*Take only the parameters*/ textolda = textold.split(/[\s]{1,2}\|/); for (x in textolda) { if (textolda.hasOwnProperty(x) && typeof textolda[x] !== 'undefined') {/*parse values into an associative array*/ if (textolda[x].search('=') !== -1) { tmp = textolda[x].split('='); tmp[0] = $.trim(tmp[0]); if (tmp[0] === 'version') { textoldao.version = $.trim(tmp[1]); } else if (tmp[0] === 'kills') { textoldao.kills = parseInt($.trim(tmp[1]), 10); } else if (tmp[0] === 'name') { textoldao.name = ucwords($.trim(tmp[1])); if (textnewao.name !== textoldao.name) { alert(errors[2] + '(1)'); return false; } }     }      else { if (textolda[x].search(',') === -1) { alert(errors[1] + '(1)'); return false; } textolda[x] = $.trim((textolda[x].substr(0, 1) === '|') ? textolda[x].substr(1) : textolda[x]); /*jslint regexp: true */ tmp = (lootparser_use_loot2 ?             textolda[x].match(/(.*?), ?times:(\d*),? ?(?:amount:(\d*)-?(\d*))?,? ?(?:total:(\d*))?/) :             textolda[x].match(/(.*?), ?(?:(\d*))?/)        ); /*jslint regexp: false */ if (tmp === null || typeof tmp[1] === 'undefined' || typeof tmp[2] === 'undefined' || tmp[1] ===  || tmp[2] === ) { alert(errors[1] + '(2)'); return false; } tmp[1] = tmp[1].split('[').join().split(']', 1).join().split('|', 1).join(''); tmp[2] = parseInt(tmp[2], 10); textoldao[tmp[1]] = {}; if (lootparser_use_loot2) { tmp[3] = (typeof tmp[3] === 'undefined' || tmp[3] === '') ? 0 : parseInt(tmp[3], 10); tmp[4] = (typeof tmp[4] === 'undefined' || tmp[4] === '') ? tmp[3] : parseInt(tmp[4], 10); tmp[5] = (typeof tmp[5] === 'undefined' || tmp[5] === '') ? 0 : parseInt(tmp[5], 10); textoldao[tmp[1]].times = tmp[2]; textoldao[tmp[1]].min = tmp[3]; textoldao[tmp[1]].max = tmp[4]; }       textoldao[tmp[1]].total = (lootparser_use_loot2 ? tmp[5] : tmp[2]); }   } }    for (x in textnewao) { if (textnewao.hasOwnProperty(x)) {/*Sum both loots*/ if (typeof textoldao[x] === 'undefined') { textoldao[x] = textnewao[x]; } else if (x === 'kills') { textoldao[x] += textnewao[x]; } else if (x !== 'version' && x !== 'name') { if (lootparser_use_loot2) { textoldao[x].min = (textoldao[x].min === 0) ? 0 : Math.min(textoldao[x].min, textnewao[x].min); textoldao[x].max = (textoldao[x].max === 0) ? 0 : Math.max(textoldao[x].max, textnewao[x].max); textoldao[x].times = textoldao[x].times + textnewao[x].times; }       textoldao[x].total = textoldao[x].total + textnewao[x].total; }   } }  }  /*Generating wiki markup*/ if (!textoldao.hasOwnProperty('name') || !textoldao.hasOwnProperty('kills') || !textoldao.hasOwnProperty('version')) { alert(errors[3] + '(2)'); return false; } out = (lootparser_use_loot2 ? lootparser_array_to_wiki2(textoldao) : lootparser_array_to_wiki1(textoldao)); res = (!textold_match ? out + '\n\n\n' + textoldo : textoldo.replace(textold_match, out + '\n\n\n')); res = (wysiwygtag ? '__NOWYSIWYG__\n\n' : ) + res.replace(/__NOWYSIWYG__/g, ); while (res.search(/(?:\r\n|\r|\n){3,}/) !== -1) { res = res.replace(/(?:\r\n|\r|\n){3,}/g, '\n\n'); } while (res.search('&a' + 'mp;') !== -1) { res = res.replace('&a' + 'mp;', '&'); } while (res.search('&l' + 't;') !== -1) { res = res.replace('&l' + 't;', '<'); } while (res.search('&g' + 't;') !== -1) { res = res.replace('&g' + 't;', '>'); } while (res.search('') !== -1) { res = res.replace('', ''); } return [res, textnewao.kills, textnewao.version]; }

function upload_to_wikia_end(id, msg) { $('#' + id).fadeOut(800, function {    if (typeof msg !== 'undefined' && msg !== '') { alert(msg); }  }); }

function upload_to_wikia(div_id) { var tmp, parser_text, creature, token, basetimestamp, page_text, new_page_text, summary, ta_multi_version_no_ok_wrong = 0, ta_version_ok = false, cvtext, vdata, request_end = function (msg, is_error) { if (typeof is_error === 'undefined') { is_error = true; } $('input[id^="lootparser_loot_combined_b"]').removeAttr('disabled'); if (is_error) { $('#lootparser_loot_combined_b' + div_id + ', #lootparser_loot_combined_t' + div_id).show; }   upload_to_wikia_end('lootparser_loot_block' + div_id, (typeof msg === 'undefined') ? '' : msg); }, lootparser_ajax_check_upload = function  { var errort = 'There was a problem uploading statistics for ' + creature.replace(/_/g, ' ') + ', try again.'; page_text = $.trim(page_text); parser_text = parser_text.slice(parser_text.search('{' + '{'), parser_text.search('}' + '}') + 2); /*Take only the Template part*/ if ((new_page_text = lootparser_add(page_text, parser_text)) === false) { request_end(errort); } else { summary = new_page_text[1] + ' kills added with tibia wikia loot parser (' + new_page_text[2] + ')'; new_page_text = new_page_text[0]; }   $.ajax({      url: '/api.php', type: 'POST', dataType: 'json',      data : {        'action': 'edit', 'title': 'Loot_Statistics:' + lootparser_pagename(creature, true), 'format': 'json',        'summary': summary, 'text': new_page_text,        'token': token, 'basetimestamp': basetimestamp, 'minor': 'minor'      },      error: function  { request_end(errort); },      success: function (obj) {        if (typeof obj.edit !== 'undefined' && typeof obj.edit.result !== 'undefined' && obj.edit.result === 'Success') {         request_end('You added current loot view to the statistics page for:\n' + creature.replace(/_/g, ' '), false);        }        else { request_end(errort); }      }    }); }, lootparser_ajax_get_current = function  { var errort = 'There was a problem getting current statistics for ' + creature.replace(/_/g, ' ') + ', try again.'; $.ajax({     url: '/api.php', type: 'GET', dataType: 'json',      data : {        'action': 'query', 'titles': 'Loot_Statistics:' + lootparser_pagename(creature, true), 'format': 'json',        'rvprop': 'content', 'prop': 'info|revisions', 'intoken': 'edit'      },      error: function  { request_end(errort); },      success: function (obj) {        var x;        for (x in obj.query.pages) { if (obj.query.pages.hasOwnProperty(x)) {          if (typeof obj.query.pages[x].missing !== 'undefined') {            request_end(errort);          }          else {            page_text = obj.query.pages[x].revisions[0]['*'];            lootparser_ajax_check_upload;          }          break;        } }      }    }); }, lootparser_ajax_start = function  { var errort = 'There was a problem getting current statistics for ' + creature.replace(/_/g, ' ') + ', try again.'; $.ajax({     url: '/api.php', type: 'GET', dataType: 'json',      data : {        'action': 'query', 'titles': 'Loot_Statistics:' + lootparser_pagename(creature, true), 'format': 'json',        'prop': 'info|revisions', 'intoken': 'edit'      },      error: function  { request_end(errort); },      success: function (obj) {        var x;        for (x in obj.query.pages) { if (obj.query.pages.hasOwnProperty(x)) {          token = obj.query.pages[x].edittoken;          if (typeof obj.query.pages[x].missing !== 'undefined') {            basetimestamp = ;            page_text = ;            lootparser_ajax_check_upload;          }          else {            basetimestamp = obj.query.pages[x].revisions[0].timestamp;            page_text = obj.query.pages;            lootparser_ajax_get_current;          }          break;        } }      }    }); }; /*Disabling buttons, overlay div*/ $('#lootparser_loot_combined_b' + div_id).attr('disabled', 'disabled'); $('#lootparser_loot_combined_b' + div_id + ', #lootparser_loot_combined_t' + div_id).hide; $('input[id^="lootparser_loot_combined_b"]').attr('disabled', 'disabled'); if ($('#lootparser_loot_block' + div_id).size === 0) { $('#lootparser_loot_results' + div_id).append(   $('  ', {'id': 'lootparser_loot_block' + div_id, 'style': 'displaynone;position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#666666;text-align:center;'})     .html('Uploading

 ') ); }  $('#lootparser_loot_block' + div_id).fadeTo(400, 0.8);

parser_text = $('#lootparser_loot_combined' + div_id).val; if ((tmp = parser_text.match(/\{\{[\s\S]*?name=([\s\S]*?)\|[\s\S]*?\}\}/i)) === null) { request_end('There was a problem getting statistics from parser page.'); } else { creature = ucwords($.trim(tmp[1])).replace(/ /g, '_'); ta_multi_version_no_ok_wrong = 0; ta_version_ok = false; vdata = parser_text.match(/version\s*?=\s*?([.\d]{3,5})/i); if (vdata === null) { request_end('Version info couldn\'t be found, please verify in case you manually edited the statistics.'); } else { if (lootparser_tibia_versions.hasOwnProperty(vdata[1])) { ta_version_ok = true; } cvtext = lootparser_tibia_versions[current_tibia_version]; if (lootparser_versions_ex.hasOwnProperty(lootparser_use_version) &&     lootparser_versions_ex[lootparser_use_version].hasOwnProperty(creature.replace(/_/g, ' '))) { ta_multi_version_no_ok_wrong = (vdata[1] === lootparser_versions_ex[lootparser_use_version][creature.replace(/_/g, ' ')] ? 1 : 2); }     if (ta_multi_version_no_ok_wrong === 2) { request_end('There is no LOOT VERSION "' + vdata[1] + '"' + ' for ' + '"' + (creature.replace(/_/g, ' ')) + '"' +         '\n\nCurrent tibiawiki LOOT VERSION for this creature is ' +          lootparser_versions_ex[current_tibia_version][creature.replace(/_/g, ' ')] +          '\nand it is used for clients ' + cvtext +          '\n\nThe parser should give the correct version always,' +          '\nif you have any doubts about versions you can check\nthe Talk page of the parser.' +          '\n\nYou can review the version info and try to upload again.'        ); }     else if (ta_multi_version_no_ok_wrong === 0 && !ta_version_ok) { request_end('There is no LOOT VERSION "' + vdata[1] + '"' + ' for ' + '"' + (creature.replace(/_/g, ' ')) + '"' +         '\n\nCurrent tibiawiki LOOT VERSION for this creature is ' +          current_tibia_version +          '\nand it is used for clients ' + cvtext +          '\n\nThe parser should give the correct version always,' +          '\nif you have any doubts about versions you can check\nthe Talk page of the parser.' +          '\n\nYou can review the version info and try to upload again.'        ); }     else { lootparser_ajax_start; }

} } }

function lootparser_loot_process { /*Clean*/ $('#lootparser_loot_results, #lootparser_loot_totaltime, #lootparser_loot_totallines').empty; /*Display*/ $('#lootparser_loot_main1').hide; $('#lootparser_loot_main2').show; /*Scroll*/ $('html, body').scrollTop($("#lootparser_loot_main2").offset.top - 10); /* monsters[x] = y x = monster name y = amount of x killed */ /* loot_exp[x][y] = z x = monster name y = item name z = item count Holds all items seperate */ /* loot_tem[x][y][prop] = z x = monster name y = item name prop = min, max, total, times z = prop value Holds items statistics for template*/ /*lets analyse the data*/ lootparser_use_version = $('#lootparser_use_version').val; lootparser_use_loot2 = (parseFloat(lootparser_use_version, 10) > parseFloat(lootparser_template1_max_tibia_version, 10));

/*execution time counter */ var startdate = new Date, starttime = startdate.getTime, enddate, endtime, totaltime,

monsters = {}, loot_exp = {}, loot_tem = {}, loot_tmp = {}, /*temp loot info for template*/ data = $.trim($('#lootparser_loot_log').val).split("\n"), totallines = data.length,

x, y, z, theline, line, lootmatch, loot, monster, itemlooted, amount, items_with_comma_r, items_with_comma = [], trim_comma = function (iwc) {items_with_comma.push($.trim(iwc).replace(/^,|,$/g, )); return ; },

ins_tmp, tmp, line_start, origin, target, action, origin_target = {}, stats = {'heal': {}, 'damage': {}}, stats_new = {'heal': {}, 'damage': {}}, exp_got = 0,

items_with_comma_e = ['a sweet, sugary substance'],

//'-','player', not_player_names = ['-', 'player', 'Anmothra', 'Annihilon', 'Apocalypse', 'Apprentice Sheng', 'Arachir the Ancient One', 'Armenius (Creature)', 'Arthei', 'Azerus', 'Barbaria', 'Baron Brute', 'Battlemaster Zunzu', 'Bazir', 'Big Boss Trolliver', 'Bloom of Doom', 'Bones', 'Boogey', 'Boreth', 'Brutus Bloodbeard', 'Captain Jones', 'Chikhaton', 'Chizzoron the Distorter', 'Cocoon', 'Coldheart', 'Countess Sorrow', 'Cublarc the Plunderer', 'Deadeye Devious', 'Demodras', 'Devovorga', 'Dharalion', 'Diblis the Fair', 'Dire Penguin', 'Dirtbeard', 'Diseased Bill', 'Diseased Dan', 'Diseased Fred', 'Doctor Perhaps', 'Doomhowl', 'Dracola', 'Dreadmaw', 'Dreadwing', 'Earth Overlord', 'Energized Raging Mage', 'Energy Overlord', 'Esmeralda', 'Evil Mastermind', 'Fahim the Wise', 'Fernfang', 'Ferumbras', 'Fire Overlord', 'Flamecaller Zazrak', 'Fleabringer', 'Fluffy', 'Foreman Kneebiter', 'Freegoiz', 'Fury of the Emperor', 'General Murius', 'Ghazbaran', 'Glitterscale', 'Golgordan', 'Grand Mother Foulscale', 'Grandfather Tridian', 'Gravelord Oshuran', 'Groam', 'Grorlam', 'Hairman The Huge', 'Hatebreeder', 'Haunter', 'Hellgorak', 'Heoni', 'Hide', 'High Templar Cobrass', 'Horestis', 'Ice Overlord', 'Incineron', 'Infernatil', 'Inky', 'Irahsae', 'Koshei the Deathless', 'Kraknaknork', 'Kraknaknork\'s Demon', 'Latrivan', 'Lersatio', 'Lethal Lissy', 'Leviathan', 'Lizard Abomination', 'Lizard Gate Guardian', 'Lord of the Elements', 'Mad Mage', 'Mad Technomancer', 'Madareth', 'Man in the Cave', 'Marziel', 'Massacre', 'Mephiles', 'Merikh the Slaughterer', 'Minishabaal', 'Monstor', 'Mooh\'Tah Master', 'Morgaroth', 'Morik the Gladiator', 'Mr. Punish', 'Munster', 'Mutated Zalamon', 'Necropharus', 'Orshabaal', 'Phrodomo', 'Pythius the Rotten (Creature)', 'Renegade Orc', 'Rocko', 'Ron the Ripper', 'Rottie the Rotworm', 'Rotworm Queen', 'Rukor Zad', 'Scorn of the Emperor', 'Shadow of Boreth', 'Shadow of Lersatio', 'Shadow of Marziel', 'Shard of Corruption', 'Shardhead', 'Sharptooth', 'Sir Valorcrest', 'Smuggler Baron Silvertoe', 'Snake God Essence', 'Snake Thing', 'Spawn of Devovorga', 'Spite of the Emperor', 'Splasher', 'Stonecracker', 'Teleskor', 'Teneshpar', 'The Abomination', 'The Axeorcist', 'The Big Bad One', 'The Blightfather', 'The Bloodtusk', 'The Collector', 'The Count', 'The Dreadorian', 'The Evil Eye', 'The Frog Prince', 'The Handmaiden', 'The Horned Fox', 'The Imperor', 'The Keeper', 'The Many', 'The Mutated Pumpkin', 'The Noxious Spawn', 'The Old Whopper', 'The Old Widow', 'The Plasmother', 'The Snapper', 'The Voice of Ruin', 'The Weakened Count', 'Thul', 'Tiquandas Revenge', 'Tirecz', 'Tremorak', 'Ungreez', 'Ushuriel', 'Verminor', 'Vulnerable Cocoon', 'Vuuzuhla', 'Warlord Ruzad', 'Wrath of the Emperor', 'Xenia', 'Yaga the Crone', 'Yakchal', 'Zarabustor', 'Zevelon Duskbringer', 'Zoralurk', 'Zugurosh', 'Zulazza the Corruptor'],

got_stats, name_is_player, in_tmp, i,

killed, k1, k2, monstername, id_inc, tmp_version;

for (x = 0; x < not_player_names.length; x++) { not_player_names[x] = $.trim(not_player_names[x].replace(/(creature)/gi, '')); }

$('#lootparser_loot_totallines').html('Analysing ' + totallines + ' lines...');

for (x = 0; x < data.length; x++) { theline = $.trim(data[x]); lootmatch = theline.indexOf('Loot of '); if (lootmatch !== -1) { line = theline.substr(lootmatch + 8); loot = line.substr(line.indexOf(':') + 2); monster = line.slice(0, line.indexOf(':')); if (typeof monsters[monster] === 'undefined') { monsters[monster] = 0; loot_tem[monster] = {}; loot_exp[monster] = {}; } monsters[monster]++; loot_tmp = {}; /*items with comma*/ items_with_comma = []; for (z in items_with_comma_e) { if (items_with_comma_e.hasOwnProperty(z)) { items_with_comma_r = new RegExp(items_with_comma_e[z] + ', |, ' + items_with_comma_e[z], 'i'); if (items_with_comma_r.test(loot)) { loot = loot.replace(items_with_comma_r, trim_comma); } } }     loot =  items_with_comma.concat(loot.split(',')); for (y in loot) { if (loot.hasOwnProperty(y)) { itemlooted = ucwords($.trim(loot[y])); /*the name of the looted item, capitalised*/ /*loot_exp*/ if (typeof loot_exp[monster][itemlooted] === 'undefined') { loot_exp[monster][itemlooted] = 0; } loot_exp[monster][itemlooted]++; /*loot_tmp*/ amount = parseInt(itemlooted.match(/^a[n]? /i) ? 1 : (itemlooted.match(/^\d+ /i) ? itemlooted.match(/^\d+ /i) : 0), 10); itemlooted = itemlooted.substr((amount > 0) ? itemlooted.indexOf(' ') + 1 : 0); itemlooted = (amount > 1) ? lootparser_to_singular(itemlooted) : itemlooted; if (!lootparser_use_loot2) { if (amount === 0) { amount = 1; } if (itemlooted === 'Nothing') { itemlooted = 'Empty'; } }       if (typeof loot_tmp[itemlooted] === 'undefined') { loot_tmp[itemlooted] = 0; } loot_tmp[itemlooted] += amount; } }     for (y in loot_tmp) { if (loot_tmp.hasOwnProperty(y)) {/*loot_tem*/ if (lootparser_use_loot2) { if (y === 'Nothing') { y = 'Empty'; } } if (typeof loot_tem[monster][y] === 'undefined') { loot_tem[monster][y] = {}; } if (typeof loot_tem[monster][y].total === 'undefined') { loot_tem[monster][y].total = 0; } loot_tem[monster][y].total += loot_tmp[y]; if (lootparser_use_loot2) { if (typeof loot_tem[monster][y].times === 'undefined') { loot_tem[monster][y].times = 0; } loot_tem[monster][y].times++; if (typeof loot_tem[monster][y].min === 'undefined' || loot_tmp[y] < loot_tem[monster][y].min) { loot_tem[monster][y].min = loot_tmp[y]; }         if (typeof loot_tem[monster][y].max === 'undefined' || loot_tmp[y] > loot_tem[monster][y].max) { loot_tem[monster][y].max = loot_tmp[y]; }       }      } }    }    else {/*statistics*/ tmp = []; line = theline.substr(0, theline.length - (theline.substr(theline.length - 1) === '.' ? 1 : 0));     line_start = line.substr(2, 1) === ':' ? 6 : 0;     if ((tmp[0] = line.indexOf(' healed ')) !== -1 && (tmp[1] = line.indexOf('self ')) !== -1 && line.indexOf('You ') === -1) { action = 'heal'; origin = line.slice(line_start, tmp[0]); target = '-'; amount = String(parseInt(line.substr(tmp[1] + 9, 5), 10)); if (typeof stats[action][origin] === 'undefined') { stats[action][origin] = {}; } if (typeof stats[action][origin][target] === 'undefined') { stats[action][origin][target] = {}; } if (typeof stats[action][origin][target][amount] === 'undefined') { stats[action][origin][target][amount] = 0; } stats[action][origin][target][amount]++; }     else if ((tmp[0] = line.indexOf(' loses ')) !== -1 && (tmp[1] = line.indexOf(' by ')) !== -1) { action = 'damage'; target = line.slice(line_start, tmp[0]); origin = line.substr(tmp[1] + 4); amount = String(parseInt(line.substr(tmp[0] + 7, 5), 10)); if (typeof stats[action][origin] === 'undefined') { stats[action][origin] = {}; } if (typeof stats[action][origin][target] === 'undefined') { stats[action][origin][target] = {}; } if (typeof stats[action][origin][target][amount] === 'undefined') { stats[action][origin][target][amount] = 0; } stats[action][origin][target][amount]++; }     else if ((tmp[0] = line.indexOf('You lose ')) !== -1 && (tmp[1] = line.indexOf(' by ')) !== -1) { action = 'damage'; target = 'player'; origin = line.substr(tmp[1] + 4); amount = String(parseInt(line.substr(tmp[0] + 9, 5), 10)); if (typeof stats[action][origin] === 'undefined') { stats[action][origin] = {}; } if (typeof stats[action][origin][target] === 'undefined') { stats[action][origin][target] = {}; } if (typeof stats[action][origin][target][amount] === 'undefined') { stats[action][origin][target][amount] = 0; } stats[action][origin][target][amount]++; }     else if ((tmp[0] = line.indexOf('You gained ')) !== -1 && (tmp[1] = line.indexOf(' experience ')) !== -1) { exp_got += (parseInt(line.slice(tmp[0] + 11, tmp[1]), 10) || 0); }   }  }  /*Sort*/ monsters = array_sort(monsters, false, true); for (x in loot_exp) { if (loot_exp.hasOwnProperty(x)) { loot_exp[x] = array_sort(loot_exp[x], false, true); } } killed = false; got_stats = false; for (x in loot_tem) { if (loot_tem.hasOwnProperty(x)) { killed = true; break; } } for (action in stats) { if (stats.hasOwnProperty(action)) { for (origin in stats[action]) { if (stats[action].hasOwnProperty(origin)) { got_stats = true; break; } } } } if (got_stats) {/*statistics*/ name_is_player = function (c) { if ((c === 'You') || (c.substr(0, 2).toLowerCase !== 'a ' && c.substr(0, 3).toLowerCase !== 'an ' && $.inArray(c, not_player_names) === -1)) { return true; } return false; };   for (action in stats) { if (stats.hasOwnProperty(action)) {/*cleaning data*/ for (origin in stats[action]) { if (stats[action].hasOwnProperty(origin)) { if (typeof origin_target[origin] === 'undefined') { tmp = name_is_player(origin); origin_target[origin] = tmp ? 'player' : origin.toLowerCase; }       if (origin_target[origin] !== 'player') { if (typeof stats_new[action][origin_target[origin]] === 'undefined') { stats_new[action][origin_target[origin]] = {}; } for (target in stats[action][origin]) { if (stats[action][origin].hasOwnProperty(target)) { if (typeof origin_target[target] === 'undefined') { tmp = name_is_player(target); origin_target[target] = tmp ? 'player' : target.toLowerCase; }           if (typeof stats_new[action][origin_target[origin]][origin_target[target]] === 'undefined') { stats_new[action][origin_target[origin]][origin_target[target]] = {}; } for (amount in stats[action][origin][target]) { if (stats[action][origin][target].hasOwnProperty(amount)) { if (typeof stats_new[action][origin_target[origin]][origin_target[target]][amount] === 'undefined') { stats_new[action][origin_target[origin]][origin_target[target]][amount] = 0; } stats_new[action][origin_target[origin]][origin_target[target]][amount] += stats[action][origin][target][amount]; } }         } }        }      } }    } }    got_stats = false; for (action in stats_new) { if (stats_new.hasOwnProperty(action)) { for (origin in stats_new[action]) { if (stats_new[action].hasOwnProperty(origin)) { got_stats = true; break; } } } }   if (got_stats) { ins_tmp = ''; for (action in stats_new) { if (stats_new.hasOwnProperty(action)) { stats_new[action] = array_sort(stats_new[action], false, true); for (origin in stats_new[action]) { if (stats_new[action].hasOwnProperty(origin)) { stats_new[action][origin] = array_sort(stats_new[action][origin], false, true); for (target in stats_new[action][origin]) { if (stats_new[action][origin].hasOwnProperty(target)) { ins_tmp += origin + '|' + action + '|' + (target === '-' ? '' : target); for (amount in stats_new[action][origin][target]) { if (stats_new[action][origin][target].hasOwnProperty(amount) && amount.substr(0, 1) !== '|') { stats_new[action][origin][target]['|' + amount] = stats_new[action][origin][target][amount]; delete (stats_new[action][origin][target][amount]); } }           stats_new[action][origin][target] = array_sort(stats_new[action][origin][target], true, true); for (amount in stats_new[action][origin][target]) { if (stats_new[action][origin][target].hasOwnProperty(amount)) { ins_tmp += amount + ',' + stats_new[action][origin][target][amount]; } }           ins_tmp += '|\n'; } }       } }      } }    }  }  if (!killed && !got_stats) { $('#lootparser_loot_results').html('No monsters to process!'); } else { in_tmp = ''; i = 0; if (got_stats) { in_tmp += ' '; } in_tmp += ' ";   in_tmp = ' ';      $('#lootparser_loot_results').append(        $('  ', {'id': 'lootparser_stats_results'}).css('position', 'relative').html(in_tmp)      );      $('#lootparser_stats_b').click(function  {        $(this).attr('disabled', 'disabled');        if ($('#lootparser_stats_block').size === 0) { $('#lootparser_stats_results').append(          $('  ', {'id': 'lootparser_stats_block'})            .css({'display': 'none', 'position': 'absolute', 'top': '0px', 'left': '0px', 'width': '100%', 'height': '100%', 'background-color': '#666666', 'text-align': 'center'})            .html('Uploading

 ')       ); }        $('#lootparser_stats_block').fadeTo(400, 0.8); var request_error = function { $('#lootparser_stats_b').removeAttr('disabled'); upload_to_wikia_end('lootparser_stats_block', 'There was an error uploading the Creature Statistics, try again.'); };       $.ajax({          url: '/api.php', type: 'GET', dataType: 'json',          data : {            'action': 'query', 'titles': 'TibiaWiki:Creature_Statistics/Statistics', 'format': 'json',            'prop': 'info', 'intoken': 'edit'          },          error: request_error, success: function (obj) {            var x, token;            for (x in obj.query.pages) { if (obj.query.pages.hasOwnProperty(x)) {              token = obj.query.pages[x].edittoken;              break;            } }            $.ajax({ url: '/api.php', type: 'POST', dataType: 'json', data : { 'action': 'edit', 'title': 'TibiaWiki:Creature_Statistics/Statistics', 'format': 'json', 'section': 'new', 'text': $('#lootparser_stats_t').val, 'token': token, 'minor': 'minor' },             error: request_error, success: function (obj) { if (typeof obj.edit !== 'undefined' && typeof obj.edit.result !== 'undefined'               && obj.edit.result === 'Success') { $('#lootparser_stats_b').hide; upload_to_wikia_end('lootparser_stats_block', 'You uploaded the Creature Statistics.'); }               else { request_error; } }           });          }        });      });    }    if (killed) {      id_inc = 1;      for (k1 in monsters) { if (monsters.hasOwnProperty(k1)) {/*lists and markup*/        in_tmp = 'up - Killed ' + monsters[k1] + 'x ' + k1 + ', which dropped:';        in_tmp += ' ' +                   '<div style="display: none;" id="lootparser_loot_results_list' + id_inc + '">';        for (k2 in loot_exp[k1]) { if (loot_exp[k1].hasOwnProperty(k2)) {          in_tmp += loot_exp[k1][k2] + 'x ' + stripslashes(k2.toLowerCase) + '<br/ >\r\n';        } }        in_tmp += ' ';        monstername = ucwords(k1.match(/^a[n]? /i) ? k1.substr(k1.indexOf(' ') + 1) : k1);       in_tmp += ' ';        $('#lootparser_loot_results').append( $(' ', {'id': 'lootparser_loot_results' + id_inc}).css('position', 'relative').html(in_tmp) );       id_inc++;      } }      $('input[id^="lootparser_loot_combined_b"]').click(function  { upload_to_wikia($(this).attr('id').replace(/lootparser_loot_combined_b/, '')); });     $('input[id^="lootparser_loot_showhide"]').toggle( function { var i = $(this).val('Hide').attr('id').replace(/lootparser_loot_showhide/, ''); $('#lootparser_loot_results_list' + i).show; }, function { var i = $(this).val('Show').attr('id').replace(/lootparser_loot_showhide/, ''); $('#lootparser_loot_results_list' + i).hide; }     );      $('a.lootparser_loot_up').click(function  { $('html, body').scrollTop($("#lootparser_loot_main2").offset.top - 10); return false; });   }  }  /*execution time counter */  enddate = new Date; endtime = enddate.getTime;  totaltime = Math.round((endtime - starttime) * 1000);  $('#lootparser_loot_totaltime').html('Calculation made in ' + (totaltime / 1000000) + ' seconds'); }

function lootparser_add_process { /* start execution time counter */ var startdate = new Date, starttime = startdate.getTime, endtime, enddate, totaltime, /* end execution time counter */ tmp = lootparser_add($('#lootparser_add_log1').val, $('#lootparser_add_log2').val)[0]; $('#lootparser_add_results').val(!tmp ? '' : tmp); /* start execution time counter */ endtime = new Date; enddate = endtime.getTime; totaltime = Math.round((endtime - starttime) * 1000); $('#lootparser_add_totaltime').html("Calculation made in " + (totaltime / 1000000) + " seconds"); /* end execution time counter */ } function lootparser_add_init { $('#lootparser_add').append(   $('  ', {'id': 'lootparser_add_main1'}).css('display', 'none').html( ' <font size="+1">Loot Merger ' +     'This one is provided in case you need to merge/sort some statistics. ' +     'To merge statistics, copy the "old" statistics in the left box, then copy the ones that need to be added to it into the right one. ' +     'To sort statistics, just left "old" statistics blank and paste the statistics to sort on the right. ' +     'Note that only 1 statistics table will be processed on "New statistics" field. ' +     '

' +     ' ' +      ' ' +      '<input id="lootparser_add_bp" type="button" value="Process" />' + ' ' +     '<input id="lootparser_add_bc" type="button" value="Clear" />' ),   $('  ', {'id': 'lootparser_add_main2'}).css('display', 'none').html( '<input id="lootparser_add_bb" type="button" value="Go back to the form" />' + '

' +     ' ' +      '

' +     '<div id="lootparser_add_totaltime"> ' ) )  .css({'font-size': '100%', 'border': '1px solid #bfcfcf', 'color': '#000000',        'background-color': '#f9fcff', 'padding': '5px 10px 5px 10px', 'margin': '0px 0px 10px 0px'}); $('#lootparser_add_bb').click(function { $('#lootparser_add_main2').hide; $('#lootparser_add_main1').show; }); $('#lootparser_add_bc').click(function { $('#lootparser_add_log1, #lootparser_add_log2, #lootparser_add_results').val(''); }); $('#lootparser_add_bp').click(function { $('#lootparser_add_main1').hide; $('#lootparser_add_main2').show; lootparser_add_process; }); $('#lootparser_add_main1').show; } function lootparser_go_back_to_form { $('#lootparser_loot_main2').hide; $('#lootparser_loot_main1').show; $('#lootparser_loot_log').val(''); $('#lootparser_use_version').val(current_tibia_version); } function lootparser_loot_init { var tmp = '', x; for (x in lootparser_tibia_versions) { if (lootparser_tibia_versions.hasOwnProperty(x)) { tmp += '<option value="' + x + '"' + (current_tibia_version === x ? ' selected="selected"' : '') + '>' + lootparser_tibia_versions[x] + ' '; } } $('#lootparser_loot').append(    $('  ', {'id': 'lootparser_loot_main1'}).css('display', 'none').html( ' <font size="+1">Log Analyzer/Uploader ' +     'This page will analyse your Server Log file and will then give you an overview of the monsters killed, and their loot. ' +     'If you are logged in to wikia it will give you the option to upload statistics. ' +     'All this is to make your life easier, you do not have to manually count or edit anything. ' +     '

' +     'Copy the Server Log in this box: ' +     ' <textarea id="lootparser_loot_log" rows="15" cols="60" style="width:98%;"> ' + '

' +     ' '    ),    $('  ', {'id': 'lootparser_loot_main2'}).css('display', 'none').html( '<input id="lootparser_loot_bb" type="button" value="Go back to the form" />' + '

' +     '<div id="lootparser_loot_totallines"> ' + '<div id="lootparser_loot_results"> ' + ' ' +     '<div id="lootparser_loot_totaltime"> ' ) )  .css({'font-size': '100%', 'border': '1px solid #bfcfcf', 'color': '#000000',        'background-color': '#f9fcff', 'padding': '5px 10px 5px 10px', 'margin': '0px 0px 10px 0px'}); $('#lootparser_loot_bb').click(function { lootparser_go_back_to_form; }); $('#lootparser_loot_bc').click(function { $('#lootparser_loot_log').val(''); }); $('#lootparser_loot_bp').click(function { lootparser_loot_process; }); $('#lootparser_loot_main1').show; } /* End of Code used for Loot_Statistics */ /*Hide bar and show loot parser */ lootparser_add_init; $('#lootparser_add_img').hide; $('#lootparser_add').show; lootparser_loot_init; $('#lootparser_loot_img').hide; $('#lootparser_loot').show;

//