rdfs:comment
| - // File:Lock Icon.png This page is protected to prevent harmful edits. Contact an administrator if you want to suggest changes to the page. If you think this page should be unprotected, then use {{unprotect}} on the talk page. Reason: this page contains javascript and therefore VERY vulnerable to vandalism or hackers /*jslint devel: true, browser: true, white: true, indent: 2, plusplus: true, vars: true, sloppy: true*/ /*global $, mw*/ var ajax_load_bar = new Image(); ajax_load_bar.src = "http://images3.wikia.nocookie.net/tibia/en/images/d/de/Ajax_Load_Bar.gif"; var creature_statistics_string = ''; var creature_statistics_obj = {}; var creature_statistics_basetimestamp, creature_statistics_token; var sysop = false; var array_sort = function (inputArr, numeric, by_key, reverse, sub_k
|
abstract
| - // File:Lock Icon.png This page is protected to prevent harmful edits. Contact an administrator if you want to suggest changes to the page. If you think this page should be unprotected, then use {{unprotect}} on the talk page. Reason: this page contains javascript and therefore VERY vulnerable to vandalism or hackers /*jslint devel: true, browser: true, white: true, indent: 2, plusplus: true, vars: true, sloppy: true*/ /*global $, mw*/ var ajax_load_bar = new Image(); ajax_load_bar.src = "http://images3.wikia.nocookie.net/tibia/en/images/d/de/Ajax_Load_Bar.gif"; var creature_statistics_string = ''; var creature_statistics_obj = {}; var creature_statistics_basetimestamp, creature_statistics_token; var sysop = false; var array_sort = function (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 = '';} var is_numeric = function (v) { v = parseFloat(String(v).replace('|', '')); return (typeof v === 'number' && !isNaN(v)); }; 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); } 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 { 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 numcs = function (n) { n = String(n); while ((/\d{4}/).test(n)) { n = n.replace(/(\d{3},|\d{3}$)/, ',$1'); } return n; }; var creature_statistics_merge = function (data, sort_by_occurrences) { $('#creature_statistics_block p').html('Processing'); if (typeof sort_by_occurrences === 'undefined') { sort_by_occurrences = false; } var x, y, t = '', tmp, stats = {'heal':{}, 'damage':{}}; var action, origin, target, amount; data = data.split(/(?:
||
){1,10}/g); for (x=0;x 3) { if (typeof stats[action][origin] === 'undefined') { stats[action][origin] = {}; } if (typeof stats[action][origin][target] === 'undefined') { stats[action][origin][target] = {}; } for (y=3;y'); $('#creature_statistics_block').fadeTo(400, 0.8, function () { var include = {'heal':$('#creature_statistics_generator_ch').is(':checked'), 'damage':$('#creature_statistics_generator_cd').is(':checked')}; var i = 0, times, tmp; var stats = creature_statistics_obj; $('#creature_statistics_tables').empty(); $('#creature_statistics_generator_sel option:selected').each(function () { var this_origin = $(this).val(); var action, target, amount; for (action in stats) { if (stats.hasOwnProperty(action) && include[action]) { if (typeof stats[action][this_origin] !== 'undefined') { for (target in stats[action][this_origin]) { if (stats[action][this_origin].hasOwnProperty(target)) { times = 0; tmp = ''; $('#creature_statistics_tables').append( ''+this_origin+' '+action+' '+(target==='-'?'self':target)+' ('+times+' times)'+' - ', $('', {'style':'cursor:pointer;color:#0148c2;text-decoration:underline;'}).html('Show').click(creature_statistics_table_toggle), tmp, $('', {'style':'display:none;cursor:pointer;color:#0148c2;text-decoration:underline;'}).html('up').click(creature_statistics_table_up) ); i++; } } } } } }); if (i > 0) { try { mw.loader.using('jquery.tablesorter', function () { $('table.sortable.creature_statistics').not('.jquery-tablesorter').tablesorter(); }); } catch (er) {} } else { $('#creature_statistics_tables').html('Nothing to show with the current selection'); } creature_statistics_end(); }); }; var creature_statistics_generator_init = function () { var action, origin, tmp = {}; var i = 0, options = ''; for (action in creature_statistics_obj) { if (creature_statistics_obj.hasOwnProperty(action)) { for (origin in creature_statistics_obj[action]) { if (creature_statistics_obj[action].hasOwnProperty(origin)) { tmp[origin] = 0; } } } } tmp = array_sort(tmp, false, true); for (origin in tmp) { if (tmp.hasOwnProperty(origin)) { options += ''+origin+''; i++; } } $('#creature_statistics_generator').empty().append( $('
|