Sparky
New Member
- Reaction score
- 0
I know there's a script out there for this already, but it wasn't working and I wasn't a huge fan of it anyway. This calculates how full the warehouse is of each village on the production overview screen and adds a column showing the %. It also highlights each row based on how full it is. To use it, all you do is run it once on the production overview screen. I'm intending this to be private.
JavaScript:
javascript:$(document).ready(function(){
var table = $("#production_table");
var warehouseColIndex = table.find("thead tr th:contains('Warehouse')").index();
table.find("thead tr").children().eq(warehouseColIndex).after("<th>% Full</th>");
table.find("tbody tr").each(function(){
var resources = $(this).find("td:eq(3) span.res, td:eq(3) span.warn");
var maxResource = "";
var maxAmount = 0;
resources.each(function(){
var amountStr = $(this).text().replace(/\./g,"");
var amount = parseInt(amountStr);
if(amount > maxAmount){
maxAmount = amount;
maxResource = $(this).attr("class").split(" ")[1];
}
});
var warehouseStr = $(this).find("td:eq("+(warehouseColIndex)+")").text().replace(/\./g,"");
var warehouse = parseInt(warehouseStr);
var percentage = Math.round((maxAmount/warehouse)*100);
$(this).children().eq(warehouseColIndex).after("<td>"+percentage+"% "+maxResource+"</td>");
var color;
if(percentage >= 90){
color = "#ff5555"; // red
}else if(percentage >= 70){
color = "#ff8c00"; // orange
}else if(percentage >= 50){
color = "#ffd700"; // yellow
}else{
color = "#a8ff60"; // green
}
$(this).children().css("background-color", color);
});
});