Skip to content

Instantly share code, notes, and snippets.

@fuzzysteve
Created November 4, 2013 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuzzysteve/7302456 to your computer and use it in GitHub Desktop.
Save fuzzysteve/7302456 to your computer and use it in GitHub Desktop.
a little snippet of javascript from my PI stuff
function domath(){
taxrate=parseInt($("#taxrate").val())/100;
for ( x in schematiclist){
schematic=schematiclist[x];
outputvalue=(schematicdata[schematic]["price"]-(taxvalues[schematicdata[schematic]["group"]]*taxrate))*schematicdata[schematic]["quantity"];
$("#"+schematic+"-outputvalue").text(addIskCommas(outputvalue));
pitable.fnUpdate(addIskCommas(outputvalue),document.getElementById("schematic-"+schematic),4,0);
totalinputprice=0;
for (y in schematicdata[schematic]["inputs"]){
$("#"+schematic+"-"+schematicdata[schematic]["inputs"][y]["typeid"]+"-price").text(addIskCommas(((taxvalues[schematicdata[schematic]["inputs"][y]["group"]]*schematicdata[schematic]["inputs"][y]["quantity"])*taxrate*0.5)+(schematicdata[schematic]["inputs"][y]["price"]*schematicdata[schematic]["inputs"][y]["quantity"])));
totalinputprice+=(((taxvalues[schematicdata[schematic]["inputs"][y]["group"]]*schematicdata[schematic]["inputs"][y]["quantity"])*taxrate*0.5)+(schematicdata[schematic]["inputs"][y]["price"]*schematicdata[schematic]["inputs"][y]["quantity"]));
}
$("#"+schematic+"-inputcost").text(addIskCommas(totalinputprice));
pitable.fnUpdate(addIskCommas(totalinputprice),document.getElementById("schematic-"+schematic),3,0);
$("#"+schematic+"-profit").text(addIskCommas(outputvalue-totalinputprice));
pitable.fnUpdate(addIskCommas(outputvalue-totalinputprice),document.getElementById("schematic-"+schematic),5,0);
}
pitable.fnDraw();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment