User:FINNER/common.js

/* Armor Calculator START */ $(function { // what io_armor does here function io_armor {	return $(' ', { append: [ mainInput('Base Armor', 'MAIN'), titleCell(''), outputCell('Total Armor', 'OUT_ARMOR'), outputCell('Damage Reduction', 'OUT_REDUCTION'), outputCell('Effective Health multiplier', 'OUT_HEALTH'), titleCell('Mods'), ioRow('Armored Agility', 0, 5 ), ioRow('Coaction Drift', 0, 1, 'self', 'If equipped on self, supposes max rank' ], [ 0, 3, 'ally', 'Number of allies that have it equipped, supposes max rank', 1, false, true), ioRow('Focused Defense', 0, 3 ), ioRow('Gladiator Aegis', 0, 5 ), ioRow('Health Conversion', 0, 5 ], [0, 3, 'stack', 'Active stacks'), ioRow('Stand United', 0, 5 ], [ 1, 4, 'num', 'Number of SUs', 1), ioRow('Steel Fiber', 0, 10 ), ioRow('Umbral Fiber', 5, 10 ), ioRow('Umbral Vitality', [], false, true), titleCell('Abilities'), ioRow('Elemental Ward', 0, 3, 'rank', 'Ability rank'), ioRow('Hallowed Reckoning', 0, 3 ), ioRow('Ironclad Charge', 0, 3 ], [ 0, 9999, 'stack', 'Enemies hit', 1 ), ioRow('Metronome', 0, 3, 'rank', 'Ability rank'), ioRow('Renewal', 0, 3, 'rank', 'Ability rank'), ioRow('Scarab Swarm', 0, 3, 'rank', 'Ability rank'), ioRow('Vex Armor', 0, 3, 'rank', 'Ability rank'), ioRow('Warcry', 0, 3, 'rank', 'Ability rank'), titleCell('Bonus Ability Strength'), ioRow('Elemental Ward Strength', -9999, 9999, 'val', 'Bonus Ability Strength', 0, true, 'false'), ioRow('Hallowed Reckoning Strength', -9999, 9999, 'val', 'Bonus Ability Strength', 0, true, 'false'), ioRow('Ironclad Charge Strength', -9999, 9999, 'val', 'Bonus Ability Strength', 0, true, 'false'), ioRow('Metronome Strength', -9999, 9999, 'val', 'Bonus Ability Strength', 0, true, 'false'), ioRow('Renewal Strength', -9999, 9999, 'val', 'Bonus Ability Strength', 0, true, 'false'), ioRow('Vex Armor Strength', -9999, 9999, 'val', 'Bonus Ability Strength', 0, true, 'false'), ioRow('Warcry Strength', -9999, 9999, 'val', 'Bonus Ability Strength', 0, true, 'false'), titleCell('Other'), ioRow('Arcane Guardian', 0, 3, 'rank', 'Arcane rank' ], [ 1, 2, 'num', 'Number equipped', 1), ioRow('Arcane Ultimatum', 0, 3, 'rank', 'Arcane rank' ], [ 1, 2, 'num', 'Number equipped', 1), ioRow('Atlas Passive', 0, 450, 'val', 'Bonus obtained from Rubble', 'false'), ioRow('Justice (Syndicate Effect)', []), ioRow('Nidus Passive', 0, 30, 'rank', 'Nidus rank', 'false'), ioRow('Stone Skin (Focus)', 1, 4, 'rank', 'Focus school rank' ), ]	}); }

// creates a row function ioRow(name, input_array, nolink, noOutput) { var idname = name.replace(/\(| |\)/g, "").toLowerCase; var outColumn = ''; if (!noOutput) { outColumn = $(' ', {			class: 'resultingStat',			width: '8.3em',			append: [				$(' ', { id: 'out_' + idname, value: 'NaN' })			]		});   }    return $(' ', {  	    append: [    	    $(' ', { append: [ $(' ', {         	            type: 'checkbox',                        id: 'check_' + idname,                        on: {                            input: update_table                        }                    }), rowName (name, nolink) ]           }),            $(' ', {                width: '8.3em', align: 'left', append: [ input_cell_generator(idname, input_array), ]           }),            outColumn,        ]	}); }

// adds name plus a link to the proper page if remover is empty function rowName (cont, remover) { var link = cont.replace(/ \(|\)|Syndicate Effect|Focus| Strength/g, ""); link = link.replace(/Passive/g, "/Abilities"); var spanclass = ''; if (remover) { return $(' ', {			text: cont		}); } else { switch (cont) { case 'Arcane Guardian': case 'Arcane Ultimatum': spanclass = 'arcane-tooltip' break; case 'Elemental Ward': case 'Metronome': case 'Renewal': case 'Scarab Swarm': case 'Vex Armor': case 'Warcry': spanclass = 'ability-tooltip' break; case 'Justice (Syndicate Effect)': return ' ' + cont + ' ' break; case 'Stone Skin (Focus)': return ' ' + cont + ' ' break; default: spanclass = 'mod-tooltip'; }       return '' + cont + ' '; } }

// input cells cluster generator, function input_cell_generator(name, meta_array) { var size = meta_array.length; var cell = []; for (var j = 0; j < size; j++) { cell[j] = input_cell(name, meta_array[j][0], meta_array[j][1], meta_array[j][2], meta_array[j][3], meta_array[j][4], meta_array[j][5], size); }   return $(' ').append(cell); }

// Generates a single input cell function input_cell(name, minVal, maxVal, stat, tooltip, baseVal, override, size) { var classtype = ''; if (size > 1) { classtype = 'inputField2'; } else { classtype = 'inputField1'; } return $(' ', {		type: 'number',        class: classtype,        id: "in_" + name + stat_check(stat),        min: minVal,        max: maxVal,        value: valInitializer(baseVal, maxVal, override),        title: tooltip_check(tooltip, stat),        on: {			input: update_table,        }    }); }

// Gives a starting value if base is given, otherwise it just return max function valInitializer(base, max, override) { if (override) { return base; } else if (base) { return base; } else { return max; } }

//gives "_rank" to a string if no value is given function stat_check(val) { if (val) { return '_' + val; } else { return '_rank'; } }

//gives a sentence for tooltip accoding to id function tooltip_check(phrase, id) { if (phrase) { return phrase; } else { return 'Mod rank'; } } // puts a title function titleCell(title) { return $(' ', { 		append: [			$(' ', { class: 'resultTitle', text: title, }),		]	}); }

// Generates the main input cell, Used only for Base Armor function mainInput(label, id) { return $(' ', {		append: [			$(' ', { text: label + ':', }),			$(' ', {				append: $(' ', {					width: '8.3em',					min: 0,					max: 9999,					id: 'in_' + id,					type: 'number',					value: 100,					on: {						input: update_table					}				}) })		]	}); }

// generate output rows function outputCell(name, nameID) { return $(' ', {		append: [			$(' ', { class: 'textWidth', text: name, }),			$(' ', {				append: [ $(' ', {						id: nameID,						class: 'resultingStat',						value: 'NaN'					}) ]			})		]	}); } // with every updade, gives a value to every stat function update_table { var Armor = reasonableInput('#in_MAIN'); var setCount = 0; if ($('#check_umbralfiber').prop('checked')) { setCount += 1; }   if ($('#check_umbralintensify').prop('checked')) { setCount += 1; }   if ($('#check_umbralvitality').prop('checked')) { setCount += 1; }   var modMap = { armoredagility: [2.5 * ( 1 + reasonableInput('#in_armoredagility_rank', 5) ), 'rank'], coactiondrift: [0, 'self', 'ally'], focuseddefense: [5 * ( 1 + reasonableInput('#in_focuseddefense_rank', 3)), 'rank'], healthconversion: [75 * ( 1 + reasonableInput('#in_healthconversion_rank', 5)) * reasonableInput('#in_healthconversion_stack', 3), 'rank', 'stack'], standunited: [ (4.25 * (reasonableInput('#in_standunited_rank', 5) + 1) * (reasonableInput('#in_standunited_num', 4) + (0.15 * (verifyCoactionDrift('self') + verifyCoactionDrift('ally')))) ) * (1 + (0.15 * verifyCoactionDrift('self'))), 'rank', 'num' ], steelfiber: [10 * (1 + parseInt($('#in_steelfiber_rank').val)), 'rank' ], gladiatoraegis: [7.5 * (1 + parseInt($('#in_gladiatoraegis_rank').val)), 'rank' ], umbralfiber: [10 * (reasonableInput('#in_umbralfiber_rank', 10) + 1) * (1 + 0.25 * setMultiplier(setCount)), 'rank'], };	var abilityMap = { elementalward: [abilityBonus("elementalward", reasonableInput('#in_elementalward_rank', 3)), 'rank'], hallowedreckoning: [abilityBonus("hallowedreckoning", reasonableInput('#in_hallowedreckoning_rank', 3)), 'rank'], ironcladcharge: [(abilityBonus("ironcladcharge", reasonableInput('#in_ironcladcharge_rank', 3))) * reasonableInput('#in_ironcladcharge_stack', 9999), 'rank', 'stack'], metronome: [abilityBonus("metronome", reasonableInput('#in_metronome_rank', 3)), 'rank'], renewal: [abilityBonus("renewal", reasonableInput('#in_renewal_rank', 3)), 'rank'], scarabswarm: [abilityBonus("scarabswarm", reasonableInput('#in_scarabswarm_rank', 3)), 'rank'], vexarmor: [abilityBonus("vexarmor", reasonableInput('#in_vexarmor_rank', 3)), 'rank'], warcry: [abilityBonus("warcry", reasonableInput('#in_warcry_rank', 3)), 'rank'], };   var strengthMap = { elementalwardstrength: [reasonableInput('#in_elementalwardstrength_val', 9999, -9999), 'val'], hallowedreckoningstrength: [reasonableInput('#in_hallowedreckoningstrength_val', 9999, -9999), 'val'], ironcladchargestrength: [reasonableInput('#in_ironcladchargestrength_val', 9999, -9999), 'val'], metronomestrength: [reasonableInput('#in_metronomestrength_val', 9999, -9999), 'val'], renewalstrength: [reasonableInput('#in_renewalstrength_val', 9999, -9999), 'val'], vexarmorstrength: [reasonableInput('#in_vexarmorstrength_val', 9999, -9999), 'val'], warcrystrength: [reasonableInput('#in_warcrystrength_val', 9999, -9999), 'val'], };   var nidusrank = reasonableInput('#in_niduspassive_rank', 30); if (nidusrank >= 26) { nidusrank = 5; } else if (nidusrank >= 20) { nidusrank = 4; } else if (nidusrank >= 14) { nidusrank = 3; } else if (nidusrank >= 8) { nidusrank = 2; } else if (nidusrank >= 2) { nidusrank = 1; } else { nidusrank = 0; }   var otherMap = { arcaneguardian: [150 * (1 + reasonableInput('#in_arcaneguardian_rank', 3)) * (reasonableInput('#in_arcaneguardian_num', 2)), 'rank', 'num'], arcaneultimatum: [150 * (1 + reasonableInput('#in_arcaneultimatum_rank', 3)) * (reasonableInput('#in_arcaneultimatum_num', 2)), 'rank', 'num'], justicesyndicateeffect: [15], stoneskinfocus: [irregularFormula('#in_stoneskinfocus_rank', [20, 30, 40, 60]), 'rank'], atlaspassive:[reasonableInput('#in_atlaspassive_val', 450), 'val'], niduspassive: [10 * nidusrank, 'rank'], };   function abilityBonus(ability, rank) { switch (ability) { case "elementalward": if (rank == 3) { return 150; } else if (rank == 2) { return 100; } else if (rank == 1) { return 75; } else { return 25; }           break; case "hallowedreckoning": if (rank == 3) { return 250; } else { return 150 + 30 * rank; }           break; case "ironcladcharge": return Math.floor(12.5 * (1 + rank)) break; case "metronome": if (rank == 3) { return 35; } else { return 10 + 5 * rank; }           break; case "renewal": return 125 + 25 * rank break; case "scarabswarm": if (rank === 0) { return 100; } else { return 125 + 25 * rank; }           break; case "vexarmor": return 200 + 50 * rank break; case "warcry": if (rank == 3) { return 50; } else { return 25 + 10 * rank; }           break; }   }

// for formulas that require a definition for cases function irregularFormula(string, array) { var value = parseInt($(string).val); return array[value-1]; }

// limits the input to a [min, max] range function reasonableInput(num, max, min) { var value = parseInt($(num).val); if (min && value < min) { return min; } else if (!min && value < 0) { return 0; } else if (value > max) { return max; } else { return value; }   }

// because Umbral Fiber's set bonus is wacky function setMultiplier(num) { if (num == 1) { return 0; } else if (num == 2) { return 1; } else { return 3; }   }

// check Coaction Drift's type and decides its reasonableInput function verifyCoactionDrift(type) { if ($('#check_coactiondrift').prop('checked')){ var name = '#in_coactiondrift_' + type; if (type == 'self') { return reasonableInput(name, 1); } else if (type == 'ally') { return reasonableInput(name, 3); }       } else { return 0; }   }

// checkboxes interaction checker(modMap); checker(strengthMap); checker(abilityMap); checker(otherMap);

// See the input (maps), uses the key as part of the IDs and updates the state of those according to their checkbox, assigning to the corresponding key the value of 0 or itself function checker(varmap) { for (key in varmap) { var formula = varmap[key][0]; if ($('#check_' + key).prop('checked')) { for (j = 1; j < varmap[key].length; j++) { $('#in_' + key + '_' + varmap[key][j]).prop('disabled', false); //here the single cell changes according to input }               $('#out_' + key).css('color', 'black'); varmap[key][0] = formula; } else { for (j = 1; j < varmap[key].length; j++) { $('#in_' + key + '_' + varmap[key][j]).prop('disabled', true); }               $('#out_' + key).css('color', '#dadada'); varmap[key][0] = 0; }       }    }

// loaders, 1st part if ($('#calculator_armor').length) { var multipliers = 1 + (modMap.armoredagility[0] + modMap.focuseddefense[0] + modMap.standunited[0] + modMap.steelfiber[0] + modMap.gladiatoraegis[0] + modMap.umbralfiber[0] + (1 + strengthMap.elementalwardstrength[0]/100)*abilityMap.elementalward[0] + (1 + strengthMap.metronomestrength[0]/100)*abilityMap.metronome[0] + (1 + strengthMap.vexarmorstrength[0]/100)*abilityMap.vexarmor[0] + (1 + strengthMap.warcrystrength[0]/100)*abilityMap.warcry[0] + otherMap.niduspassive[0])/100; var additions = modMap.healthconversion[0] + (1 + strengthMap.hallowedreckoningstrength[0]/100)*abilityMap.hallowedreckoning[0] + (1 + strengthMap.renewalstrength[0]/100)*abilityMap.renewal[0] + abilityMap.scarabswarm[0] + otherMap.arcaneguardian[0] + otherMap.arcaneultimatum[0] + otherMap.justicesyndicateeffect[0] + otherMap.stoneskinfocus[0] + otherMap.atlaspassive[0]; var metamultipliers = 1 + ((1 + strengthMap.ironcladchargestrength[0]/100)*abilityMap.ironcladcharge[0])/100; var total_armor = (Armor * multipliers + additions) * metamultipliers; formula_loader([           ['#out_armoredagility', (modMap.armoredagility[0]).toFixed(2) + "%"],            ['#out_focuseddefense', (modMap.focuseddefense[0]).toFixed(2) + "%"],            ['#out_healthconversion', "+" + (modMap.healthconversion[0]).toFixed(2)],            ['#out_standunited', (modMap.standunited[0]).toFixed(2) + "%"],            ['#out_steelfiber', (modMap.steelfiber[0]).toFixed(2) + "%"],            ['#out_gladiatoraegis', (modMap.gladiatoraegis[0]).toFixed(2) + "%"],            ['#out_umbralfiber', (modMap.umbralfiber[0]).toFixed(2) + "%"],            ['#out_elementalward', (abilityMap.elementalward[0]).toFixed(2) + "%"],            ['#out_hallowedreckoning', "+" + (abilityMap.hallowedreckoning[0]).toFixed(2)],            ['#out_ironcladcharge', (abilityMap.ironcladcharge[0]).toFixed(2) + "%"],            ['#out_metronome', (abilityMap.metronome[0]).toFixed(2) + "%"], ['#out_renewal', "+" + (abilityMap.renewal[0]).toFixed(2)], ['#out_scarabswarm', "+" + (abilityMap.scarabswarm[0]).toFixed(2)], ['#out_vexarmor', (abilityMap.vexarmor[0]).toFixed(2) + "%"], ['#out_warcry', (abilityMap.warcry[0]).toFixed(2) + "%"], ['#out_elementalwardstrength', (strengthMap.elementalwardstrength[0]).toFixed(2) + "%"], ['#out_hallowedreckoningstrength', (strengthMap.hallowedreckoningstrength[0]).toFixed(2) + '%'], ['#out_ironcladchargestrength', (strengthMap.ironcladchargestrength[0]).toFixed(2) + "%"], ['#out_metronomestrength', (strengthMap.metronomestrength[0]).toFixed(2) + "%"], ['#out_renewalstrength', (strengthMap.renewalstrength[0]).toFixed(2) + '%'], ['#out_vexarmorstrength', (strengthMap.vexarmorstrength[0]).toFixed(2) + "%"], ['#out_warcrystrength', (strengthMap.warcrystrength[0]).toFixed(2) + "%"], ['#out_arcaneguardian', "+" + (otherMap.arcaneguardian[0]).toFixed(2)], ['#out_arcaneultimatum', "+" + (otherMap.arcaneultimatum[0]).toFixed(2)], ['#out_justicesyndicateeffect', (otherMap.justicesyndicateeffect[0]).toFixed(2) + "%"], ['#out_stoneskinfocus', '+' + (otherMap.stoneskinfocus[0]).toFixed(2)], ['#out_atlaspassive', "+" + (otherMap.atlaspassive[0]).toFixed(2)], ['#out_niduspassive', (otherMap.niduspassive[0]).toFixed(2) + "%"], ['#OUT_ARMOR', ( total_armor ).toFixed(0)], ['#OUT_REDUCTION',  (100 * total_armor/(300 + total_armor)).toFixed(2) + "%" ], ['#OUT_HEALTH', ((300 + total_armor)/300).toFixed(2) + 'x' ] ]);   } }

// prepares formulas function formula_loader(meta_array) { var j;   for (j = 0; j < meta_array.length; j++) { $(meta_array[j][0]).text(meta_array[j][1]); } } // loaders, 2nd part table_loader("#calculator_armor", io_armor);

// if the proper ID is called, it uses a function function table_loader(idCall, func) { if ($(idCall).length) { $(idCall).html(func); }	update_table; }

});   /* Armor Calculator END */

/////////////////////////////////////////////////////////////////////////////////   /* FINNER/Dupes START *

dil = new Array; function findDupImages(gf) { output = ""; url = "/api.php?action=query&generator=allimages&prop=duplicatefiles&gailimit=5000&format=json"; if (gf) url += "&gaifrom=" + gf; $.getJSON(url,function (data) { if (data.query) { pages = data.query.pages; for (pageID in pages) { dils = ","+dil.join; if (dils.indexOf(","+pages[pageID].title) == -1 && pages[pageID].title.indexOf("File::") == -1 && pages[pageID].duplicatefiles) { output += " "+pages[pageID].title+" \n\n"; for (x=0;xFile:"+pages[pageID].duplicatefiles[x].name+"\n"; dil.push("File:"+pages[pageID].duplicatefiles[x].name.replace(/_/g," ")); } output += "\n\n"; } } $("#mw-dupimages").append(output); if (data["query-continue"]) setTimeout("findDupImages('"+data["query-continue"].allimages.gaifrom+"');",5000); } }); } $(function { if ($("#mw-dupimages").length) findDupImages; });

/* FINNER/Dupes END */