User:Foodbandlt/CharmCounter.js

//__NOWYSIWYG__ ');		// Add click listener		$(".CharmCounterButton").on("click", function{ CharmCounter.addDrop($(this).attr("data-charm-type")); });		CharmCounter.updateTable;	},	charmCounts: {},	lastUpdate: [],	charmIndex: ["No", "Gold", "Green", "Crimson", "Blue"],	addDrop: function(type){		CharmCounter.charmCounts[type]++;		CharmCounter.lastUpdate.push(type);		CharmCounter.updateTable;	},	undoLast: function{		if ( CharmCounter.lastUpdate.length == 0)			return;		CharmCounter.charmCounts[ CharmCounter.lastUpdate.pop ]--;		CharmCounter.updateTable;	},	reset: function{		delete localStorage[wgUserName + "_CharmCounterCounts"];		delete localStorage[wgUserName + "_CharmCounterLastUpdate"];		CharmCounter.zeroCounts;		CharmCounter.lastUpdate = [];		CharmCounter.updateTable;	},	zeroCounts: function{		for (var i in CharmCounter.charmIndex)			CharmCounter.charmCounts[ CharmCounter.charmIndex[i] ] = 0;	},	getPercent: function(type){		if (CharmCounter.getTotal == 0)			return 0;		else			return Math.round( (CharmCounter.charmCounts[type] / CharmCounter.getTotal) * 100 ); },	getTotal: function{ var total = 0; for (var i in CharmCounter.charmCounts) total += CharmCounter.charmCounts[i]; return total; },	updateTable: function{ for (var i in CharmCounter.charmIndex){ $("#" + CharmCounter.charmIndex[i] + "CharmNum").html( CharmCounter.charmCounts[ CharmCounter.charmIndex[i] ] ); $("#" + CharmCounter.charmIndex[i] + "CharmPercent").html( CharmCounter.getPercent( CharmCounter.charmIndex[i] ) ); }		$("#TotalKillsNum").html( CharmCounter.getTotal ); localStorage[wgUserName + "_CharmCounterCounts"] = JSON.stringify(CharmCounter.charmCounts); localStorage[wgUserName + "_CharmCounterLastUpdate"] = JSON.stringify(CharmCounter.lastUpdate); } } $(document).ready(function{	CharmCounter.init; });

// //