MediaWiki:LootStatistics.js

 var current_tibia_version = 8.54; /* Code used for Loot_Statistics */

var ajax_load_bar = new Image; ajax_load_bar.src = "http://images3.wikia.nocookie.net/tibia/en/images/d/de/Ajax_Load_Bar.gif";

function gebi(id) { return document.getElementById(id); } function hebi(id) { gebi(id).style.display = 'none'; } function sebi(id, b) { gebi(id).style.display = (b ? 'block' : 'inline'); } function shebi(id, bt, a, b) { var d = gebi(id).style.display; gebi(id).style.display = (d == 'none' ? 'inline' : 'none'); if (typeof bt != 'undefined') { bt.value = (d == 'none' ? b : a); } } hebi('lootparser_loot'); hebi('lootparser_add');

function trim(str) { str = str.replace(/^\s\s*/, ''); var ws = /\s/, i = str.length; while (ws.test(str.charAt(--i))){} return str.slice(0, i + 1); } function stripslashes(str) { return (str+).replace(/\\(.?)/g, function (s, n1) {   switch (n1) {      case '\\': return '\\';      case : return '';      default: return n1;    }  }); } function is_numeric(v) { v = parseFloat(v); return (typeof v === 'number' && !isNaN(v)); } function ucwords(str) { str = (str+'').replace(/^(.)|\s(.)/g, function ($1) { return $1.toUpperCase; }); return str.replace(' Of The ', ' of the ').replace(' Of ', ' of '); } function array_sort(inputArr, numeric, by_key, reverse, sub_key) { var tmp_arr={}, valArr=[], keyArr=[], keys=[], sorter, i, k, populateArr = []; 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) { if (a == b) { return 0; } if (a > b) { return (reverse ? -1 : 1); } return (reverse ? 1 : -1); }; } else { sorter = function (a, b) { if (!is_numeric(a) && !is_numeric(b)) { 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); } var ac = (a.substr(0,1).toUpperCase == a.substr(0,1)), bc = (b.substr(0,1).toUpperCase == b.substr(0,1)); if (a == b) { return 0; } if (ac && !bc) { return (reverse ? -1 : 1); } if (!ac && bc) { return (reverse ? 1 : -1); } if (a > b) { return (reverse ? -1 : 1); } return (reverse ? 1 : -1); }     else { a = parseFloat(a) || 0; b = parseFloat(b) || 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 { var 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; }

var lootparser_s_words = {'*Knife':'Knives', '*Piece of *':'Pieces of '};/*Exceptions*/

function lootparser_to_plural(t) { var x; 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(' '))]; } var lastletter = t.substr(-1); if (lastletter == 's' || lastletter == 'h') { t += 'es'; } else if (lastletter == 'y') { t = t.substr(0, t.length-1)+'ies'; } else { t += 's'; } return t; }

var lootparser_p_words = {'Cookies':'Cookie', '*Pieces of *':'Piece of '};/*Exceptions*/ function lootparser_to_singular(t) { var x; 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]); } } } var lastletter = t.substr(-1); if (lastletter == "s") {/*remove the s*/ t = t.substr(0, t.length - 1); lastletter = t.substr(-2);/*need to check last 2 letters*/ if (lastletter == "ie") { t = t.substr(0, t.length - 2) + 'y'; } else if (lastletter == "ve") { t = t.substr(0, t.length - 2) + 'fe'; } } 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_wiki(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; }

var newdiv; function lootparser_loot_process { /*execution time counter */ var starttime = new Date; starttime = starttime.getTime;

/*Cleaning DOM*/ var rdel, i = 0, results = document.getElementById('lootparser_loot_results'); while ((rdel = gebi('lootparser_loot_results'+i))) { results.removeChild(rdel); i++; } results.innerHTML = ""; gebi('lootparser_loot_totallines').innerHTML = ""; gebi('lootparser_loot_totaltime').innerHTML = "";

/* 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*/ var monsters = {}, loot_exp = {}, loot_tem = {}, loot_tmp = {};/*temp loot info for template*/

/*lets analyse the data*/ var data = trim(gebi('lootparser_loot_log').value).split("\n"); var totallines = data.length; gebi('lootparser_loot_totallines').innerHTML = "Analysing "+totallines+" lines...";

var x, line, loot, monster; var y, itemlooted, amount; for (x in data) { if (data.hasOwnProperty(x)) { line = data[x].indexOf("Loot of"); if (line === -1) { continue; } line = data[x].substr(line + 8); loot = trim(line.substr(line.indexOf(":") + 1)); monster = trim(line.slice(0, line.indexOf(":"))); if (typeof monsters[monster] == 'undefined') { monsters[monster] = 0; loot_tem[monster] = {}; loot_exp[monster] = {}; } monsters[monster]++;

loot_tmp = {}; loot = 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_tem*/ 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 (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 (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];

} } } }

var id_inc = 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); } }

var killed = false; for (x in loot_tem) { if (loot_tem.hasOwnProperty(x)) { killed = true; break; } } if (!killed) { results.innerHTML = "No monsters killed!"; } else { newdiv = document.createElement('div'); newdiv.setAttribute('id', 'lootparser_loot_results'+id_inc); newdiv.style.position = 'relative'; id_inc++; var in_tmp = ''; i = 0; for (x in monsters) { if (monsters.hasOwnProperty(x)) {/*Contents*/ if ((i / 15) == Math.floor(i / 15)) { if (i !== 0) { in_tmp += ' '; } in_tmp += '     ";    in_tmp = '   ';      newdiv.innerHTML = out_exp + out_tem;      results.appendChild(newdiv);      id_inc++;    } }  } /*execution time counter */  var endtime = new Date; endtime = endtime.getTime;  var totaltime = Math.round((endtime - starttime)*1000);  gebi('lootparser_loot_totaltime').innerHTML = "Calculation made in "+(totaltime/1000000)+" seconds"; }

/* 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'];

if (typeof wysiwygtag == 'undefined') { wysiwygtag = true; } var textoldo = textold; /*original old text*/ textnew = textnew.slice(textnew.search('{'+'{'), textnew.search('}'+'}')+2);/*Take only the Template part*/ textnew = textnew.slice(textnew.search(/\|/)+1, textnew.search('}'));/*Take only the parameters*/ var textnewa = textnew.split(/[\s]{1,2}\|/);/*make it an warray*/ var textoldao = {}, textnewao = {}, x, tmp; for (x in textnewa) { if (textnewa.hasOwnProperty(x)) {/*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])); } continue; }   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]);

tmp = textnewa[x].match(/(.*?), ?(?:(\d*))?/); 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]] = {}; textnewao[tmp[1]].total = tmp[2]; } } /*Looking for matching version number on textold & textnew*/ var matches, vo, vn, textold_match = false; matches = 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)) { 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*/ var textolda = textold.split(/[\s]{1,2}\|/); for (x in textolda) { if (textolda.hasOwnProperty(x)) {/*parse values into an associative array*/

if (textolda[x].search('=') != -1) { tmp = textolda[x].split('='); tmp[0] = trim(tmp[0]); if (tmp[0] == 'version') { textolda.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; } }       continue; }     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]);

tmp = textolda[x].match(/(.*?), ?(?:(\d*))?/); 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]] = {}; textoldao[tmp[1]].total = 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') { textoldao[x].total = textoldao[x].total + textnewao[x].total; }   } }

} /*Generating wiki markup*/

if (!('name' in textoldao) || !('kills' in textoldao) || !('version' in textoldao)) { alert(errors[3]+'(1)'); return false; } var out = lootparser_array_to_wiki(textoldao); var res = (!textold_match ? out+'\n\n\n'+textoldo : textoldo.replace(textold_match, out)); res = (wysiwygtag ? '__NOWYSIWYG__\n\n' : ) + res.replace(/__NOWYSIWYG__/g, );

while (res.search('\r\n\r\n\r\n') != -1) { res = res.replace('\r\n\r\n\r\n', '\r\n\r\n'); } while (res.search('\r\r\r') != -1) { res = res.replace('\r\r\r', '\r\r'); } while (res.search('\n\n\n') != -1) { res = res.replace('\n\n\n', '\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]; }

function set_opacity(id, op) { if ((id = gebi(id))) { id.style.opacity = op / 100; id.style.filter = 'alpha(opacity='+op+')'; } }

function upload_to_wikia_end(id, msg) { var i, timer = 0; for (i=80; i>=1; i--) { setTimeout("set_opacity('"+id+"',"+i+")", timer * 4); timer++; } setTimeout("hebi('"+id+"')", 330); if (typeof msg != 'undefined') { setTimeout("alert('"+msg+"')", 340); } }

function upload_to_wikia(div_id) { gebi('lootparser_loot_combined_b'+div_id).disabled = true; hebi('lootparser_loot_combined_b'+div_id); hebi('lootparser_loot_combined_t'+div_id); var divtodo = gebi('lootparser_loot_combined'+div_id); /*Function to add data to each monster page*/ var lootparser_ajax_add = function (newtext, monster, wpp) { var lootparser_loot_t; if (typeof (lootparser_loot_t = getXmlHttpRequestObject) == 'boolean') { return; } lootparser_loot_t.onreadystatechange = function { if (lootparser_loot_t.readyState != 4) { return; } upload_to_wikia_end('lootparser_loot_block'+div_id, (lootparser_loot_t.status == 200) ?        'You added current loot view to the statistics page for '+monster.replace(/_/g,' ') :         'Problems found while uploading loot, you may need to check the loot statistics page for '+monster.replace(/_/g,' ')      );/*fade out*/ var i = 1, x;     while ((x = gebi('lootparser_loot_combined_b'+i))) { if (x.value == 'Upload') { x.disabled = false; } i++; } };   var bound2 = '--u9NhcWCckcbMykvMxYdPSR'; var bound = '--'+bound2; var params = '\r\n'+bound+'\r\n'+'Content-Disposition: form-data; name="wpCategorySelectWikitext"\r\n\r\n'+'[]'+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpCategorySelectSourceType"\r\n\r\n'+'json'+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpLogin"\r\n\r\n'+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpSection"\r\n\r\n'+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpStarttime"\r\n\r\n'+wpp.wpStarttime+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpEdittime"\r\n\r\n'+wpp.wpEdittime+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpScrolltop"\r\n\r\n'+'0'+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpAutoSummary"\r\n\r\n'+wpp.wpAutoSummary+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpTextbox1"\r\n\r\n'+newtext+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="csWikitext"\r\n\r\n'+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpSummary"\r\n\r\n'+wpp.wpSummary+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpMinoredit"\r\n\r\n'+'1'+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpSave"\r\n\r\n'+'Save page'+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="wpEditToken"\r\n\r\n'+wpp.wpEditToken+'\r\n'+ bound+'\r\n'+'Content-Disposition: form-data; name="antispam"\r\n\r\n'+wpp.antispam+'\r\n'+ bound+'--'; lootparser_loot_t.open("POST", '/index.php?title='+monster+'/Loot_Statistics&action=submit'); lootparser_loot_t.setRequestHeader("Content-length", params.length); lootparser_loot_t.setRequestHeader("Content-Type", 'multipart/form-data; boundary='+bound2); lootparser_loot_t.send(params); };

/*Function to check data to be added to each monster page*/ var lootparser_ajax_addcheck = function(newtext, monster, div_id) { var lootparser_loot_t; if (typeof (lootparser_loot_t = getXmlHttpRequestObject) == 'boolean') { return; }

var x, i = 1, timer, b_id = 'lootparser_loot_block'+div_id; /*Disabling buttons, overlay div*/ while ((x = gebi('lootparser_loot_combined_b'+i))) { x.disabled = true; i++; } newdiv = document.createElement('div'); newdiv.setAttribute('id', b_id); newdiv.style.display = 'none'; newdiv.style.position = 'absolute'; newdiv.style.top = '0px'; newdiv.style.left = '0px'; newdiv.style.width = '100%'; newdiv.style.height = '100%'; newdiv.style.backgroundColor = '#666666'; newdiv.style.textAlign = 'center'; newdiv.innerHTML = 'Uploading   '; gebi('lootparser_loot_results'+div_id).appendChild(newdiv); set_opacity(b_id, 0); sebi(b_id, true);/*fade in*/ for (i=1; i<=80; i++) { setTimeout("set_opacity('"+b_id+"',"+i+")", timer * 5); timer++; }

lootparser_loot_t.onreadystatechange = function { if (lootparser_loot_t.readyState != 4) { return; } var text, i, x;     var oldtext = (text = lootparser_loot_t.responseText); if ((oldtext = oldtext.match(/([\s\S]*?)<\/textarea>/i)) === null) { alert('There was a problem trying to get current statistics for '+monster); upload_to_wikia_end('lootparser_loot_block'+div_id);/*fade out*/ i = 1; while ((x = gebi('lootparser_loot_combined_b'+i))) { if (x.value == 'Upload') { x.disabled = false; } i++; } return false; }     oldtext = trim(oldtext[1]);/*oldtext = wikia textarea contents*/ newtext = newtext.slice(newtext.search('{'+'{'), newtext.search('}'+'}')+2);/*Take only the Template part*/ if ((newtext = lootparser_add(oldtext, newtext)) === false) { upload_to_wikia_end('lootparser_loot_block'+div_id);/*fade out*/ i = 1; while ((x = gebi('lootparser_loot_combined_b'+i))) { if (x.value == 'Upload') { x.disabled = false; } i++; } return; }     var matches, wpp = {'wpStarttime':, 'wpEdittime':, 'wpAutoSummary':, 'wpEditToken':, 'antispam':''}; for (x in wpp) {/*Extra data for wikia edits*/ if (wpp.hasOwnProperty(x)) { matches = text.match(new RegExp(']*name=["\']'+x+'["\'][^>]*)>', 'i')); wpp[x] = matches[1].match(/value=["']([\s\S]*?)["']/i)[1] || ''; }     }      wpp.wpSummary = newtext[1]+' kills added with tibia wikia loot parser'; lootparser_ajax_add(newtext[0], monster, wpp); };   lootparser_loot_t.open('GET', '/index.php?title='+monster+'/Loot_Statistics&action=edit'); lootparser_loot_t.send(null); }; var mdata, wdata; wdata = divtodo.innerHTML; if ((mdata = wdata.match(/\{\{[\s\S]*?name=([\s\S]*?)\|[\s\S]*?\}\}/i)) === null) { alert('There was a problem trying to get statistics from page(2)'); return; } mdata = ucwords(trim(mdata[1])).replace(/ /g,"_"); lootparser_ajax_addcheck(wdata, mdata, div_id); }

function lootparser_add_process { /* start execution time counter */ var starttime = new Date; starttime = starttime.getTime; /* end execution time counter */ var tmp = lootparser_add(gebi('lootparser_add_log1').value, gebi('lootparser_add_log2').value)[0]; gebi('lootparser_add_results').value = (!tmp ? '' : tmp); /* start execution time counter */ var endtime = new Date; endtime = endtime.getTime; var totaltime = Math.round((endtime - starttime)*1000); gebi('lootparser_add_totaltime').innerHTML = "Calculation made in "+(totaltime/1000000)+" seconds"; /* end execution time counter */ }

function lootparser_add_init { newdiv = document.createElement('div'); newdiv.setAttribute('id', 'lootparser_add_main1'); newdiv.setAttribute('style', 'display: none;'); newdiv.innerHTML = ' 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. '+ '  '+  ' '+  ' '+  ' '+ ''; document.getElementById('lootparser_add').appendChild(newdiv);

newdiv = document.createElement('div'); newdiv.setAttribute('id', 'lootparser_add_main2'); newdiv.setAttribute('style', 'display: none;'); newdiv.innerHTML = ''+ ' '+  ' '+  '  '+  ' '; document.getElementById('lootparser_add').appendChild(newdiv); document.getElementById('lootparser_add').style.fontSize= '100%'; document.getElementById('lootparser_add').style.border= '1px solid #bfcfcf'; document.getElementById('lootparser_add').style.color = '#000000'; document.getElementById('lootparser_add').style.backgroundColor = '#f9fcff'; document.getElementById('lootparser_add').style.paddingLeft='10px'; document.getElementById('lootparser_add').style.paddingRight='10px'; document.getElementById('lootparser_add').style.paddingTop='5px'; document.getElementById('lootparser_add').style.paddingBottom='5px'; document.getElementById('lootparser_add').style.marginBottom='10px'; sebi('lootparser_add_main1'); } function lootparser_loot_init { newdiv = document.createElement('div'); newdiv.setAttribute('id', 'lootparser_loot_main1'); newdiv.setAttribute('style', 'display: none;'); newdiv.innerHTML = ' 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 yu are logged in to wikia it will give you the option to upload statistics to corresponding monster loot statistics page. '+ '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: '+ ' '+ ' '+  '<input type="button" value="Process" onclick="hebi(\'lootparser_loot_main1\'); sebi(\'lootparser_loot_main2\');lootparser_loot_process;"> '+ '<input type="button" value="Clear" onclick="gebi(\'lootparser_loot_log\').value = \'\'">'; document.getElementById('lootparser_loot').appendChild(newdiv);

newdiv = document.createElement('div'); newdiv.setAttribute('id', 'lootparser_loot_main2'); newdiv.setAttribute('style', 'display: none;'); newdiv.innerHTML = '<input type="button" value="Go back to the form" onclick="hebi(\'lootparser_loot_main2\'); sebi(\'lootparser_loot_main1\');">'+ ' '+  '<div id="lootparser_loot_totallines"> '+ '<div id="lootparser_loot_results"> '+ ' '+ '<div id="lootparser_loot_totaltime"> '; document.getElementById('lootparser_loot').appendChild(newdiv); document.getElementById('lootparser_loot').style.fontSize= '100%'; document.getElementById('lootparser_loot').style.border= '1px solid #bfcfcf'; document.getElementById('lootparser_loot').style.color = '#000000'; document.getElementById('lootparser_loot').style.backgroundColor = '#f9fcff'; document.getElementById('lootparser_loot').style.paddingLeft='10px'; document.getElementById('lootparser_loot').style.paddingRight='10px'; document.getElementById('lootparser_loot').style.paddingTop='5px'; document.getElementById('lootparser_loot').style.paddingBottom='5px'; document.getElementById('lootparser_loot').style.marginBottom='10px'; sebi('lootparser_loot_main1'); } /* End of Code used for Loot_Statistics */

/*Hide bar and show loot parser */ lootparser_add_init; hebi('lootparser_add_img'); sebi('lootparser_add', true); hebi('lootparser_add_main2'); sebi('lootparser_add_main1');/* Fix for IE*/ lootparser_loot_init; hebi('lootparser_loot_img'); sebi('lootparser_loot', true); hebi('lootparser_loot_main2'); sebi('lootparser_loot_main1');/* Fix for IE*/