• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Difference between revisions of "User:Dragonjet/scripts/FleetReporting.js"

From Kancolle Wiki
Jump to navigation Jump to search
m (thisRoute fix)
m (remove symbols from routes)
Line 11: Line 11:
 
if($(".FleetCompilation").length > 0){
 
if($(".FleetCompilation").length > 0){
 
$(".FleetReport").each(function(){
 
$(".FleetReport").each(function(){
thisRoute = $(this).data("route");
+
thisRoute = $(this).data("route").replace(/\W+/g, "");
 
thisFleet = [ $(this).data("ship1"), $(this).data("ship2"), $(this).data("ship3"), $(this).data("ship4"), $(this).data("ship5"), $(this).data("ship6"), ];
 
thisFleet = [ $(this).data("ship1"), $(this).data("ship2"), $(this).data("ship3"), $(this).data("ship4"), $(this).data("ship5"), $(this).data("ship6"), ];
 
thisFleet.sort();
 
thisFleet.sort();

Revision as of 02:22, 31 January 2015

(function($){
	"use strict";
	console.log("Fleet Reporting v0.4");
	
	var routes = {};
	var thisRoute = [];
	var thisFleet = [];
	var fleetIndexer = "";
	
	$(document).ready(function(){
		if($(".FleetCompilation").length > 0){
			$(".FleetReport").each(function(){
				thisRoute = $(this).data("route").replace(/\W+/g, "");
				thisFleet = [ $(this).data("ship1"), $(this).data("ship2"), $(this).data("ship3"), $(this).data("ship4"), $(this).data("ship5"), $(this).data("ship6"), ];
				thisFleet.sort();
				fleetIndexer = thisFleet.join("-");
				if(typeof routes[thisRoute] == "undefined"){
					routes[thisRoute] = {};
				}
				if(typeof routes[thisRoute][fleetIndexer] == "undefined"){
					routes[thisRoute][fleetIndexer] = 0;
				}
				routes[thisRoute][fleetIndexer]++;
			});
			console.log(routes);
		}
	});

}(jQuery));