Initial commit
This commit is contained in:
0
js/-Old/Icon
Normal file
0
js/-Old/Icon
Normal file
67
js/-Old/Weight Calculation Script-Edited-Jquery-V2.js
Normal file
67
js/-Old/Weight Calculation Script-Edited-Jquery-V2.js
Normal file
@@ -0,0 +1,67 @@
|
||||
var weighttolift = 0;
|
||||
var percentage = 0;
|
||||
var target = 0;
|
||||
var weightsNeeded = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
// calculation function starts here
|
||||
|
||||
function startcalc() {
|
||||
|
||||
var weighttolift = jQuery(".input-weight").val();
|
||||
var percentage = jQuery(".input-percentage").val();
|
||||
var bar = jQuery(".input-bar").val();
|
||||
|
||||
|
||||
// targeted values
|
||||
var final = Math.floor(weighttolift * percentage);
|
||||
console.log("final", final);
|
||||
|
||||
var finalPlateWeights = final - bar;
|
||||
|
||||
jQuery(".input-final").val(final);
|
||||
|
||||
|
||||
|
||||
|
||||
//This creates an arrary for the weights available
|
||||
var plateWeights = [];
|
||||
|
||||
$( ".input-weightsavailable" ).each( function(){
|
||||
plateWeights.push( $( this ).data( "weight" ));
|
||||
});
|
||||
|
||||
|
||||
|
||||
//This creates an arrary for the number of plates available
|
||||
var platesAvailable = [];
|
||||
|
||||
$( ".input-weightsavailable" ).each( function(){
|
||||
platesAvailable.push( $( this ).val());
|
||||
});
|
||||
|
||||
//calls the plate calculator function
|
||||
platecalculator(plateWeights, platesAvailable, finalPlateWeights);
|
||||
|
||||
}
|
||||
|
||||
function platecalculator ( plateWeights, platesAvailable, target) {
|
||||
console.log("Plate Weights", plateWeights);
|
||||
console.log("Plate Available", platesAvailable);
|
||||
console.log("Weight To Add", target);
|
||||
for (var i = 0; i < platesAvailable.length; i++) {
|
||||
if (plateWeights[i]*2 <= target) {
|
||||
var weightToAdd = Math.floor(target / (plateWeights[i]*2));
|
||||
target = target - weightToAdd*(plateWeights[i]*2);
|
||||
console.log("plateWeights " + plateWeights[i]);
|
||||
console.log("weightToAdd " + weightToAdd);
|
||||
console.log("target " + target);
|
||||
if (weightToAdd > 0) {
|
||||
jQuery(".input-weightsneeded").eq(i).val(weightToAdd);
|
||||
}
|
||||
jQuery(".input-difference").val(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
70
js/-Old/Weight Calculation Script-Edited-Jquery-V3.js
Normal file
70
js/-Old/Weight Calculation Script-Edited-Jquery-V3.js
Normal file
@@ -0,0 +1,70 @@
|
||||
// calculation function starts here
|
||||
|
||||
function startcalc() {
|
||||
|
||||
//calls inputs to start calculation
|
||||
var weighttolift = jQuery(".input-weight").val();
|
||||
var percentage = jQuery(".input-percentage").val();
|
||||
var bar = jQuery(".input-bar").val();
|
||||
|
||||
|
||||
// calculates and logs final values
|
||||
var final = Math.floor(weighttolift * percentage);
|
||||
|
||||
|
||||
|
||||
// calculates weight of the plates needed
|
||||
var finalPlateWeights = final - bar;
|
||||
|
||||
|
||||
//This creates an arrary for the weights available
|
||||
var plateWeights = [];
|
||||
|
||||
$( ".input-weightsavailable" ).each( function(){
|
||||
plateWeights.push( $( this ).data( "weight" ));
|
||||
});
|
||||
|
||||
|
||||
|
||||
//This creates an arrary for the number of plates available
|
||||
var platesAvailable = [];
|
||||
|
||||
$( ".input-weightsavailable" ).each( function(){
|
||||
platesAvailable.push( $( this ).val());
|
||||
});
|
||||
|
||||
//calls the plate calculator function
|
||||
platecalculator(plateWeights, platesAvailable, finalPlateWeights, final);
|
||||
|
||||
}
|
||||
|
||||
//plate calulation function
|
||||
function platecalculator ( plateWeights, platesAvailable, target, finalWeight) {
|
||||
//iterates though the plates availble.
|
||||
for (var i = 0; i < platesAvailable.length; i++) {
|
||||
//checks if the plate is less than or equal to the weight of plates needed
|
||||
if (plateWeights[i]*2 <= target) {
|
||||
var weightToAdd = Math.floor(target / (plateWeights[i]*2));
|
||||
|
||||
//check if there are enough weights
|
||||
var plateCheck = Math.floor(platesAvailable[i]/2);
|
||||
if (weightToAdd > plateCheck) {
|
||||
weightToAdd = plateCheck;
|
||||
}
|
||||
//subtracts added weights
|
||||
target = target - weightToAdd*(plateWeights[i]*2);
|
||||
|
||||
//Adds plates required
|
||||
if (weightToAdd > 0) {
|
||||
jQuery(".input-weightsneeded").eq(i).val(weightToAdd);
|
||||
}
|
||||
|
||||
//sets the offset
|
||||
jQuery(".input-difference").val(target);
|
||||
|
||||
//sets the final weight
|
||||
jQuery(".input-final").val(finalWeight - target);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
196
js/-Old/Weight Calculation Script-Edited-Jquery.txt
Normal file
196
js/-Old/Weight Calculation Script-Edited-Jquery.txt
Normal file
@@ -0,0 +1,196 @@
|
||||
<script>
|
||||
var weighttolift = 0;
|
||||
var percentage = 0;
|
||||
|
||||
var target = 0;
|
||||
// calculation function starts here
|
||||
|
||||
function startcalc() {
|
||||
// making variables to use the values later.
|
||||
|
||||
// make the weight that have to be lifted after minus the bar weight etc.
|
||||
|
||||
var weighttolift = jQuery(".input-weight").val();
|
||||
var weighttolift = jQuery("input[name=Weight]").val();
|
||||
var percentage = jQuery("input[name=Percentage]").val();
|
||||
var bar = jQuery(".input-bar").val();
|
||||
|
||||
var bar = jQuery("input[name=Bar]").val();
|
||||
|
||||
// targeted values
|
||||
var target = ("input[name=Target]").val();
|
||||
|
||||
// this funciton calculates the weight percentage , final , difference etc
|
||||
|
||||
targets = Math.floor(weighttolift * percentage);
|
||||
|
||||
// final wieght calculater
|
||||
target.value = targets;
|
||||
|
||||
var finals = Math.floor(parseInt(target.value) - parseInt(bar));
|
||||
|
||||
|
||||
//this function assign the required plate pairs value
|
||||
|
||||
var weightcalculate = 0;
|
||||
|
||||
var avail45 = document.getElementById('avail45').value;
|
||||
|
||||
if (avail45 == 0) {
|
||||
document.getElementById('req45').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var c = 0;
|
||||
for (var a = 1; a <= avail45; a++) {
|
||||
if (finals >= 90) {
|
||||
c++;
|
||||
finals -= 90;
|
||||
weightcalculate += 90;
|
||||
}
|
||||
|
||||
}
|
||||
if (c == 0) {
|
||||
document.getElementById('req45').value = null;
|
||||
} else {
|
||||
document.getElementById('req45').value = c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail35 = document.getElementById('avail35').value;
|
||||
|
||||
if (avail35 == 0) {
|
||||
document.getElementById('req35').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var d = 0;
|
||||
for (var a = 1; a <= avail35; a++) {
|
||||
if (finals >= 70) {
|
||||
d++;
|
||||
finals -= 70;
|
||||
weightcalculate += 70;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (d == 0) {
|
||||
document.getElementById('req35').value = null;
|
||||
} else {
|
||||
document.getElementById('req35').value = d;
|
||||
}
|
||||
}
|
||||
|
||||
var avail25 = document.getElementById('avail25').value;
|
||||
|
||||
if (avail25 == 0) {
|
||||
document.getElementById('req25').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var e = 0;
|
||||
for (var a = 1; a <= avail25; a++) {
|
||||
if (finals >= 50) {
|
||||
e++;
|
||||
finals -= 50;
|
||||
weightcalculate += 50;
|
||||
}
|
||||
|
||||
}
|
||||
if (e == 0) {
|
||||
document.getElementById('req25').value = null;
|
||||
} else {
|
||||
document.getElementById('req25').value = e;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail10 = document.getElementById('avail10').value;
|
||||
|
||||
if (avail10 == 0) {
|
||||
document.getElementById('req10').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var f = 0;
|
||||
for (var a = 1; a <= avail10; a++) {
|
||||
if (finals >= 20) {
|
||||
f++;
|
||||
finals -= 20;
|
||||
weightcalculate += 20;
|
||||
}
|
||||
|
||||
}
|
||||
if (f == 0)
|
||||
{
|
||||
document.getElementById('req10').value = null;
|
||||
} else {
|
||||
|
||||
document.getElementById('req10').value = f;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail5 = document.getElementById('avail5').value;
|
||||
|
||||
if (avail5 == 0) {
|
||||
document.getElementById('req5').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var g = 0;
|
||||
for (var a = 1; a <= avail5; a++) {
|
||||
if (finals >= 10) {
|
||||
g++;
|
||||
finals -= 10;
|
||||
weightcalculate += 10;
|
||||
}
|
||||
|
||||
}
|
||||
if (g == 0) {
|
||||
document.getElementById('req5').value = null;
|
||||
} else {
|
||||
document.getElementById('req5').value = g;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail2 = document.getElementById('avail2').value;
|
||||
|
||||
if (avail2 == 0) {
|
||||
document.getElementById('req2').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var h = 0;
|
||||
for (var a = 1; a <= avail2; a++) {
|
||||
if (finals >= 5) {
|
||||
h++;
|
||||
finals -= 5;
|
||||
weightcalculate += 5;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (h == 0) {
|
||||
document.getElementById('req2').value = null;
|
||||
}
|
||||
else {
|
||||
document.getElementById('req2').value = h;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var bar2 = document.getElementById('Bar').value;
|
||||
document.getElementById('finalw').value = Math.floor(parseInt(weightcalculate) + parseInt(bar2));
|
||||
var targ = document.getElementById('Target').value;
|
||||
var finalssweight = document.getElementById('finalw').value;
|
||||
|
||||
document.getElementById('diff').value = Math.floor(parseInt(targ) - parseInt(finalssweight));
|
||||
|
||||
}
|
||||
</script>
|
||||
193
js/-Old/Weight Calculation Script-Edited.txt
Normal file
193
js/-Old/Weight Calculation Script-Edited.txt
Normal file
@@ -0,0 +1,193 @@
|
||||
<script>
|
||||
var weighttolift = 0;
|
||||
var percentage = 0;
|
||||
|
||||
var target = 0;
|
||||
// calculation function starts here
|
||||
|
||||
function startcalc() {
|
||||
// making variables to use the values later.
|
||||
|
||||
// make the weight that have to be lifted after minus the bar weight etc.
|
||||
|
||||
var weighttolift = document.getElementById('Weight').value;
|
||||
var percentage = document.getElementById('Percentage').value;
|
||||
var bar = document.getElementById('Bar').value;
|
||||
|
||||
// targeted values
|
||||
var target = document.getElementById('Target');
|
||||
|
||||
// this funciton calculates the weight percentage , final , difference etc
|
||||
|
||||
targets = Math.floor(weighttolift * percentage);
|
||||
|
||||
// final wieght calculater
|
||||
target.value = targets;
|
||||
|
||||
var finals = Math.floor(parseInt(target.value) - parseInt(bar));
|
||||
|
||||
|
||||
//this function assign the required plate pairs value
|
||||
|
||||
var weightcalculate = 0;
|
||||
|
||||
var avail45 = document.getElementById('avail45').value;
|
||||
|
||||
if (avail45 == 0) {
|
||||
document.getElementById('req45').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var c = 0;
|
||||
for (var a = 1; a <= avail45; a++) {
|
||||
if (finals >= 90) {
|
||||
c++;
|
||||
finals -= 90;
|
||||
weightcalculate += 90;
|
||||
}
|
||||
|
||||
}
|
||||
if (c == 0) {
|
||||
document.getElementById('req45').value = null;
|
||||
} else {
|
||||
document.getElementById('req45').value = c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail35 = document.getElementById('avail35').value;
|
||||
|
||||
if (avail35 == 0) {
|
||||
document.getElementById('req35').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var d = 0;
|
||||
for (var a = 1; a <= avail35; a++) {
|
||||
if (finals >= 70) {
|
||||
d++;
|
||||
finals -= 70;
|
||||
weightcalculate += 70;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (d == 0) {
|
||||
document.getElementById('req35').value = null;
|
||||
} else {
|
||||
document.getElementById('req35').value = d;
|
||||
}
|
||||
}
|
||||
|
||||
var avail25 = document.getElementById('avail25').value;
|
||||
|
||||
if (avail25 == 0) {
|
||||
document.getElementById('req25').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var e = 0;
|
||||
for (var a = 1; a <= avail25; a++) {
|
||||
if (finals >= 50) {
|
||||
e++;
|
||||
finals -= 50;
|
||||
weightcalculate += 50;
|
||||
}
|
||||
|
||||
}
|
||||
if (e == 0) {
|
||||
document.getElementById('req25').value = null;
|
||||
} else {
|
||||
document.getElementById('req25').value = e;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail10 = document.getElementById('avail10').value;
|
||||
|
||||
if (avail10 == 0) {
|
||||
document.getElementById('req10').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var f = 0;
|
||||
for (var a = 1; a <= avail10; a++) {
|
||||
if (finals >= 20) {
|
||||
f++;
|
||||
finals -= 20;
|
||||
weightcalculate += 20;
|
||||
}
|
||||
|
||||
}
|
||||
if (f == 0)
|
||||
{
|
||||
document.getElementById('req10').value = null;
|
||||
} else {
|
||||
|
||||
document.getElementById('req10').value = f;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail5 = document.getElementById('avail5').value;
|
||||
|
||||
if (avail5 == 0) {
|
||||
document.getElementById('req5').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var g = 0;
|
||||
for (var a = 1; a <= avail5; a++) {
|
||||
if (finals >= 10) {
|
||||
g++;
|
||||
finals -= 10;
|
||||
weightcalculate += 10;
|
||||
}
|
||||
|
||||
}
|
||||
if (g == 0) {
|
||||
document.getElementById('req5').value = null;
|
||||
} else {
|
||||
document.getElementById('req5').value = g;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail2 = document.getElementById('avail2').value;
|
||||
|
||||
if (avail2 == 0) {
|
||||
document.getElementById('req2').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var h = 0;
|
||||
for (var a = 1; a <= avail2; a++) {
|
||||
if (finals >= 5) {
|
||||
h++;
|
||||
finals -= 5;
|
||||
weightcalculate += 5;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (h == 0) {
|
||||
document.getElementById('req2').value = null;
|
||||
}
|
||||
else {
|
||||
document.getElementById('req2').value = h;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var bar2 = document.getElementById('Bar').value;
|
||||
document.getElementById('finalw').value = Math.floor(parseInt(weightcalculate) + parseInt(bar2));
|
||||
var targ = document.getElementById('Target').value;
|
||||
var finalssweight = document.getElementById('finalw').value;
|
||||
|
||||
document.getElementById('diff').value = Math.floor(parseInt(targ) - parseInt(finalssweight));
|
||||
|
||||
}
|
||||
</script>
|
||||
226
js/-Old/Weight Calculation Script.txt
Normal file
226
js/-Old/Weight Calculation Script.txt
Normal file
@@ -0,0 +1,226 @@
|
||||
<script>
|
||||
// Do not copy any part of this script without permission; ExRx.net;http://www.exrx.net
|
||||
|
||||
var weighttolift = 0;
|
||||
var percentage = 0;
|
||||
|
||||
var target = 0;
|
||||
// calculation function starts here
|
||||
|
||||
function startcalc() {
|
||||
// making variables to use the values later.
|
||||
|
||||
// make the weight that have to be lifted after minus the bar weight etc.
|
||||
|
||||
var weighttolift = document.getElementById('Weight').value;
|
||||
var percentage = document.getElementById('Percentage').value;
|
||||
var bar = document.getElementById('Bar').value;
|
||||
|
||||
// targeted values
|
||||
var target = document.getElementById('Target');
|
||||
|
||||
// this funciton calculates the weight percentage , final , difference etc
|
||||
|
||||
targets = Math.floor(weighttolift * percentage);
|
||||
|
||||
// final wieght calculater
|
||||
target.value = targets;
|
||||
|
||||
var finals = Math.floor(parseInt(target.value) - parseInt(bar));
|
||||
|
||||
// calculating total weight and the difference
|
||||
if (collar == 0) {} else {
|
||||
var collar = document.getElementById('collars').value;
|
||||
finals = finals - Math.floor(parseInt(collar));
|
||||
}
|
||||
|
||||
//this function assign the required plate pairs value
|
||||
|
||||
var weightcalculate = 0;
|
||||
|
||||
var avail100 = document.getElementById('avail100').value;
|
||||
|
||||
if (avail100 == 0) {
|
||||
document.getElementById('req100').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var b = 0;
|
||||
for (var a = 1; a <= avail100; a++) {
|
||||
if (finals >= 200) {
|
||||
b++;
|
||||
finals -= 200;
|
||||
weightcalculate += 200;
|
||||
}
|
||||
|
||||
}
|
||||
if (b == 0) {
|
||||
document.getElementById('req100').value = null;
|
||||
} else {
|
||||
|
||||
document.getElementById('req100').value = b;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var avail45 = document.getElementById('avail45').value;
|
||||
|
||||
if (avail45 == 0) {
|
||||
document.getElementById('req45').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var c = 0;
|
||||
for (var a = 1; a <= avail45; a++) {
|
||||
if (finals >= 90) {
|
||||
c++;
|
||||
finals -= 90;
|
||||
weightcalculate += 90;
|
||||
}
|
||||
|
||||
}
|
||||
if (c == 0) {
|
||||
document.getElementById('req45').value = null;
|
||||
} else {
|
||||
document.getElementById('req45').value = c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail35 = document.getElementById('avail35').value;
|
||||
|
||||
if (avail35 == 0) {
|
||||
document.getElementById('req35').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var d = 0;
|
||||
for (var a = 1; a <= avail35; a++) {
|
||||
if (finals >= 70) {
|
||||
d++;
|
||||
finals -= 70;
|
||||
weightcalculate += 70;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (d == 0) {
|
||||
document.getElementById('req35').value = null;
|
||||
} else {
|
||||
document.getElementById('req35').value = d;
|
||||
}
|
||||
}
|
||||
|
||||
var avail25 = document.getElementById('avail25').value;
|
||||
|
||||
if (avail25 == 0) {
|
||||
document.getElementById('req25').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var e = 0;
|
||||
for (var a = 1; a <= avail25; a++) {
|
||||
if (finals >= 50) {
|
||||
e++;
|
||||
finals -= 50;
|
||||
weightcalculate += 50;
|
||||
}
|
||||
|
||||
}
|
||||
if (e == 0) {
|
||||
document.getElementById('req25').value = null;
|
||||
} else {
|
||||
document.getElementById('req25').value = e;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail10 = document.getElementById('avail10').value;
|
||||
|
||||
if (avail10 == 0) {
|
||||
document.getElementById('req10').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var f = 0;
|
||||
for (var a = 1; a <= avail10; a++) {
|
||||
if (finals >= 20) {
|
||||
f++;
|
||||
finals -= 20;
|
||||
weightcalculate += 20;
|
||||
}
|
||||
|
||||
}
|
||||
if (f == 0)
|
||||
{
|
||||
document.getElementById('req10').value = null;
|
||||
} else {
|
||||
|
||||
document.getElementById('req10').value = f;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail5 = document.getElementById('avail5').value;
|
||||
|
||||
if (avail5 == 0) {
|
||||
document.getElementById('req5').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var g = 0;
|
||||
for (var a = 1; a <= avail5; a++) {
|
||||
if (finals >= 10) {
|
||||
g++;
|
||||
finals -= 10;
|
||||
weightcalculate += 10;
|
||||
}
|
||||
|
||||
}
|
||||
if (g == 0) {
|
||||
document.getElementById('req5').value = null;
|
||||
} else {
|
||||
document.getElementById('req5').value = g;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var avail2 = document.getElementById('avail2').value;
|
||||
|
||||
if (avail2 == 0) {
|
||||
document.getElementById('req2').value = null;
|
||||
|
||||
} else {
|
||||
//counts the required plates
|
||||
var h = 0;
|
||||
for (var a = 1; a <= avail2; a++) {
|
||||
if (finals >= 5) {
|
||||
h++;
|
||||
finals -= 5;
|
||||
weightcalculate += 5;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (h == 0) {
|
||||
document.getElementById('req2').value = null;
|
||||
}
|
||||
else {
|
||||
document.getElementById('req2').value = h;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var collar2 = document.getElementById('collars').value;
|
||||
var bar2 = document.getElementById('Bar').value;
|
||||
document.getElementById('finalw').value = Math.floor(parseInt(weightcalculate) + parseInt(bar2) + parseInt(collar2));
|
||||
var targ = document.getElementById('Target').value;
|
||||
var finalssweight = document.getElementById('finalw').value;
|
||||
|
||||
document.getElementById('diff').value = Math.floor(parseInt(targ) - parseInt(finalssweight));
|
||||
|
||||
}
|
||||
</script>
|
||||
BIN
js/.DS_Store
vendored
Normal file
BIN
js/.DS_Store
vendored
Normal file
Binary file not shown.
70
js/Weight Calculation Script-Edited-Jquery-V4.js
Normal file
70
js/Weight Calculation Script-Edited-Jquery-V4.js
Normal file
@@ -0,0 +1,70 @@
|
||||
// calculation function starts here
|
||||
|
||||
function startcalc() {
|
||||
|
||||
//calls inputs to start calculation
|
||||
var weighttolift = jQuery(".input-weight").val();
|
||||
var percentage = jQuery(".input-percentage").val();
|
||||
var bar = jQuery(".input-bar").val();
|
||||
|
||||
|
||||
// calculates and logs final values
|
||||
var final = Math.floor(weighttolift * percentage);
|
||||
|
||||
|
||||
|
||||
// calculates weight of the plates needed
|
||||
var finalPlateWeights = final - bar;
|
||||
|
||||
|
||||
//This creates an arrary for the weights available
|
||||
var plateWeights = [];
|
||||
|
||||
$( ".input-weightsavailable" ).each( function(){
|
||||
plateWeights.push( $( this ).data( "weight" ));
|
||||
});
|
||||
|
||||
|
||||
|
||||
//This creates an arrary for the number of plates available
|
||||
var platesAvailable = [];
|
||||
|
||||
$( ".input-weightsavailable" ).each( function(){
|
||||
platesAvailable.push( $( this ).val());
|
||||
});
|
||||
|
||||
//calls the plate calculator function
|
||||
platecalculator(plateWeights, platesAvailable, finalPlateWeights, final);
|
||||
|
||||
}
|
||||
|
||||
//plate calulation function
|
||||
function platecalculator ( plateWeights, platesAvailable, target, finalWeight) {
|
||||
//iterates though the plates availble.
|
||||
for (var i = 0; i < platesAvailable.length; i++) {
|
||||
//checks if the plate is less than or equal to the weight of plates needed
|
||||
if (plateWeights[i]*2 <= target) {
|
||||
var weightToAdd = Math.floor(target / (plateWeights[i]*2));
|
||||
|
||||
//check if there are enough weights
|
||||
var plateCheck = Math.floor(platesAvailable[i]/2);
|
||||
if (weightToAdd > plateCheck) {
|
||||
weightToAdd = plateCheck;
|
||||
}
|
||||
//subtracts added weights
|
||||
target = target - weightToAdd*(plateWeights[i]*2);
|
||||
|
||||
//Adds plates required
|
||||
if (weightToAdd > 0) {
|
||||
jQuery(".input-weightsneeded").eq(i).val(weightToAdd);
|
||||
}
|
||||
|
||||
//sets the offset
|
||||
jQuery(".input-difference").text(target);
|
||||
|
||||
//sets the final weight
|
||||
jQuery(".input-final").text(finalWeight - target);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user