From 09c0124556967d34291ad90bcf268fad6234f731 Mon Sep 17 00:00:00 2001 From: Lars Olesen Date: Sun, 20 Oct 2019 07:48:46 +0000 Subject: [PATCH] Fixes --- assets/js/1rm.js | 154 +++++++++++++--------- assets/js/cooper.js | 282 +++++++++++++++++++--------------------- assets/js/fat-pct.js | 39 +++--- assets/js/fitness-hr.js | 23 ++-- assets/js/max-hr.js | 13 +- test/1rm.js | 5 +- 6 files changed, 265 insertions(+), 251 deletions(-) diff --git a/assets/js/1rm.js b/assets/js/1rm.js index 13db6291cc9a..a65dd6573704 100644 --- a/assets/js/1rm.js +++ b/assets/js/1rm.js @@ -1,96 +1,122 @@ let motionsplan = {}; -motionsplan.Estimate1RM = function(weight, repetitions) -{ +motionsplan.Estimate1RM = function(weight, repetitions) { var weight, repetitions; - + weight = weight; repetitions = repetitions; function getBrzycki() { - return Math.round(weight*(36/(37-repetitions))); - } - function getEpley() { - return Math.round((1 + (0.0333*repetitions))*weight); - } - function getLander() { - return Math.round((100*weight)/(101.3 - 2.67123*repetitions)); - } - - function getLombardi() { - return Math.round(weight*(Math.pow(repetitions,0.1))); - } - - function getMayhewetal() { - return Math.round((100*weight)/(52.2 + (41.9*Math.exp(-0.055*repetitions)))); - } - function getOconneretal() { - return Math.round(weight*(1 + 0.025*repetitions)); - } - function getWathan() { - return Math.round((100*weight)/(48.8 + (53.8*Math.exp(-0.075*repetitions)))); - } - - /** - * Advanced - originally from motion-online.dk. - */ - function getMOL(trained, sex) - { - var trained, koen; - trained = trained; - koen = sex; + return Math.round(weight * (36 / (37 - repetitions))); + } + + function getEpley() { + return Math.round((1 + (0.0333 * repetitions)) * weight); + } + + function getLander() { + return Math.round((100 * weight) / (101.3 - 2.67123 * repetitions)); + } + + function getLombardi() { + return Math.round(weight * (Math.pow(repetitions, 0.1))); + } + + function getMayhew() { + return Math.round((100 * weight) / (52.2 + (41.9 * Math.exp(-0.055 * repetitions)))); + } + + function getOconnor() { + return Math.round(weight * (1 + 0.025 * repetitions)); + } + + function getWathan() { + return Math.round((100 * weight) / (48.8 + (53.8 * Math.exp(-0.075 * repetitions)))); + } + + /** + * Advanced - originally from motion-online.dk. + * https://www.motion-online.dk/rm-beregner/ + * https://www.motion-online.dk/rm-beregner-teoretisk-baggrund/ + */ + function getMOL(trained, sex) { + var trained, koen; + trained = trained; + koen = sex; if (koen == 1 && trained == 1) { - var a = -2.1021, b = 102.52; + var a = -2.1021, + b = 102.52; } else if (koen == 1 && trained == 0) { - var a = -2.6578, b = 102.65; + var a = -2.6578, + b = 102.65; } else if (koen == 0 && trained == 1) { - var a = -2.1275, b = 101.59; + var a = -2.1275, + b = 101.59; } else if (koen == 0 && trained == 0) { - var a = -2.6914, b = 102.14; + var a = -2.6914, + b = 102.14; } if (repetitions == 1) { - var repmax = weight; + var repmax = weight; } else { - var repmax=weight/(a*repetitions+b)*100; + var repmax = weight / (a * repetitions + b) * 100; } - + return repmax; } - /* - $scope.percentOfRm = function(rm, percent) { - return rm * percent / 100; - }; - $scope.calcRM = function(rm, number) { - var a = -2.78; - var b = 102.78; - return Math.round(((a*number+b)*rm/100) * Math.pow(10,1))/Math.pow(10,1); - };*/ + + /** + * From motion-online RM calculator + */ + function getMOLBryzki() + { + var a = -2.78, b = 102.78; + if (repetitions == 1) { + var repmax = weight; + } + else { + var repmax = weight / (a * repetitions + b) * 100; + } + + return repmax; + } + + /* + $scope.percentOfRm = function(rm, percent) { + return rm * percent / 100; + }; + + $scope.calcRM = function(rm, number) { + var a = -2.78; + var b = 102.78; + return Math.round(((a*number+b)*rm/100) * Math.pow(10,1))/Math.pow(10,1); + };*/ var publicAPI = { - getBrzycki : getBrzycki, - getEpley : getEpley, - getLander : getLander, - getLombardi : getLombardi, - getMayhewetal : getMayhewetal, - getOconneretal : getOconneretal, - getWathan : getWathan, - getMOL : getMOL - - }; - - return publicAPI; + getBrzycki: getBrzycki, + getEpley: getEpley, + getLander: getLander, + getLombardi: getLombardi, + getMayhew: getMayhew, + getOconnor: getOconnor, + getWathan: getWathan, + getMOL: getMOL, + getMOLBryzki : getMOLBryzki + + }; + + return publicAPI; } module.exports = motionsplan; /* Bryzki og avanceret fra motion-online -https://www.motion-online.dk/rm-beregner/ -https://www.motion-online.dk/rm-beregner-teoretisk-baggrund/ + function Calculate1(thisform) { reps = thisform.reps.value; diff --git a/assets/js/cooper.js b/assets/js/cooper.js index de5a72843bec..3117ac424e13 100644 --- a/assets/js/cooper.js +++ b/assets/js/cooper.js @@ -1,9 +1,8 @@ let motionsplan = {}; -motionsplan.CooperClinicMortalityRiskIndex = function(age, hr, bloodpressure, diabetes, smoker, bmi, fitness) -{ +motionsplan.CooperClinicMortalityRiskIndex = function(age, hr, bloodpressure, diabetes, smoker, bmi, fitness) { var age, hr, bloodpressure, diabetes, smoker, bmi, fitness; - + age = age; hr = hr; bloodpressure = bloodpressure; @@ -11,163 +10,156 @@ motionsplan.CooperClinicMortalityRiskIndex = function(age, hr, bloodpressure, di smoker = smoker; bmi = bmi; fitness = fitness; - - function getAgePoint() - { - var point; - if (age < 44) { - point = 0 - } - else if (age < 49) { - point = 3; - } - else if (age < 54) { - point = 6; - } - else if (age < 59) { - point = 8; - } - else if (age < 64) { - point = 9; - } - else if (age < 69) { - point = 10; - } - - return point; + + function getAgePoint() { + var point; + if (age < 44) { + point = 0 + } + else if (age < 49) { + point = 3; + } + else if (age < 54) { + point = 6; + } + else if (age < 59) { + point = 8; + } + else if (age < 64) { + point = 9; + } + else if (age < 69) { + point = 10; + } + + return point; } - - function getHrPoint() - { - if (hr >= 80) { - return 2; - } - return 0; + + function getHrPoint() { + if (hr >= 80) { + return 2; + } + return 0; } - function getBMIPoint() - { - if (bmi > 35) { - return 3; - } - - return 0; + function getBMIPoint() { + if (bmi > 35) { + return 3; + } + + return 0; } - - function getFitnessPoint() - { - if (fitness < 35) { - return 2; - } - - return 0; + + function getFitnessPoint() { + if (fitness < 35) { + return 2; + } + + return 0; } - - function getRiskPoint() - { - var point = getAgePoint() + getHrPoint() + bloodpressure + diabetes + smoker + getBMIPoint() + getFitnessPoint(); - return point; + + function getRiskPoint() { + var point = getAgePoint() + getHrPoint() + bloodpressure + diabetes + smoker + getBMIPoint() + getFitnessPoint(); + return point; } - function getAbsoluteRisk() - { - var risk; - var point = getRiskPoint(); - if (point == 0) { - risk = 1.8; - } - else if (point == 1) { - risk = 2.2; - } - else if (point == 2) { - risk = 2.6; - } - else if (point == 3) { - risk = 3.1; - } - else if (point == 4) { - risk = 3.7; - } - else if (point == 5) { - risk = 4.4; - } - else if (point == 6) { - risk = 5.4; - } - else if (point == 7) { - risk = 6.5; - } - else if (point == 8) { - risk = 7.9; - } - else if (point == 9) { - risk = 9.7; - } - else if (point == 10) { - risk = 11.8; - } - else if (point == 11) { - risk = 14; - } - else if (point == 12) { - risk = 16.5; - } - else if (point == 13) { - risk = 20.4; - } - else if (point == 14) { - risk = 23.2; - } - else if (point == 15) { - risk = 28.1; - } - else if (point == 16) { - risk = 32.1; - } - else { - risk = 46.7; - } + function getAbsoluteRisk() { + var risk; + var point = getRiskPoint(); + if (point == 0) { + risk = 1.8; + } + else if (point == 1) { + risk = 2.2; + } + else if (point == 2) { + risk = 2.6; + } + else if (point == 3) { + risk = 3.1; + } + else if (point == 4) { + risk = 3.7; + } + else if (point == 5) { + risk = 4.4; + } + else if (point == 6) { + risk = 5.4; + } + else if (point == 7) { + risk = 6.5; + } + else if (point == 8) { + risk = 7.9; + } + else if (point == 9) { + risk = 9.7; + } + else if (point == 10) { + risk = 11.8; + } + else if (point == 11) { + risk = 14; + } + else if (point == 12) { + risk = 16.5; + } + else if (point == 13) { + risk = 20.4; + } + else if (point == 14) { + risk = 23.2; + } + else if (point == 15) { + risk = 28.1; + } + else if (point == 16) { + risk = 32.1; + } + else { + risk = 46.7; + } return risk; } - function getRelativeRisk() - { - var risk2, risk3; - var risk = getAbsoluteRisk(); - if (age < 34) { - risk2 = risk / 2.4; - } - else if (age < 44) { - risk2 = risk / 2.6; - } - else if (age < 49) { - risk2 = risk / 4.6; - } - else if (age < 54) { - risk2 = risk / 8.2; - } - else if (age < 59) { - risk2 = risk / 12.6; - } - else if (age < 64) { - risk2 = risk / 16.1; - } - else { - risk2 = risk / 18.1; - } - risk3 = Math.round((risk2) * Math.pow(10, 1)) / Math.pow(10, 1); - return risk3; + function getRelativeRisk() { + var risk2, risk3; + var risk = getAbsoluteRisk(); + if (age < 34) { + risk2 = risk / 2.4; + } + else if (age < 44) { + risk2 = risk / 2.6; + } + else if (age < 49) { + risk2 = risk / 4.6; + } + else if (age < 54) { + risk2 = risk / 8.2; + } + else if (age < 59) { + risk2 = risk / 12.6; + } + else if (age < 64) { + risk2 = risk / 16.1; + } + else { + risk2 = risk / 18.1; + } + risk3 = Math.round((risk2) * Math.pow(10, 1)) / Math.pow(10, 1); + return risk3; } var publicAPI = { - getRiskPoint : getRiskPoint, - getAbsoluteRisk : getAbsoluteRisk, - getRelativeRisk : getRelativeRisk - - }; + getRiskPoint: getRiskPoint, + getAbsoluteRisk: getAbsoluteRisk, + getRelativeRisk: getRelativeRisk + + }; - return publicAPI; + return publicAPI; } module.exports = motionsplan; diff --git a/assets/js/fat-pct.js b/assets/js/fat-pct.js index 690688d5fc55..644fb2b71c9e 100644 --- a/assets/js/fat-pct.js +++ b/assets/js/fat-pct.js @@ -2,39 +2,36 @@ let motionsplan = {} motionsplan.CalculateFatPercent = function(h, w, a, sex) { var h, w, sex; - + h = h = h / 100; w = w; a = a; sex = sex; - - function getBMI() - { + + function getBMI() { return w / (h * h); } - - function getFatMass() - { - var fm; - if (sex == 'man') - fm = 0.988 * getBMI() + 0.242 * w + 0.094 * a - 30.18; - else - fm = 0.988 * getBMI() + 0.344 * w + 0.094 * a - 30.18; - return fm; + + function getFatMass() { + var fm; + if (sex == 'man') + fm = 0.988 * getBMI() + 0.242 * w + 0.094 * a - 30.18; + else + fm = 0.988 * getBMI() + 0.344 * w + 0.094 * a - 30.18; + return fm; } - - function getFatPercent() - { + + function getFatPercent() { return getFatMass() / w * 100; } var publicAPI = { - getFatMass : getFatMass, - getFatPercent : getFatPercent - - }; + getFatMass: getFatMass, + getFatPercent: getFatPercent + + }; - return publicAPI; + return publicAPI; } module.exports = motionsplan; diff --git a/assets/js/fitness-hr.js b/assets/js/fitness-hr.js index b7ff8357a118..bc1fc654259d 100644 --- a/assets/js/fitness-hr.js +++ b/assets/js/fitness-hr.js @@ -2,31 +2,30 @@ let motionsplan = {} motionsplan.CalculateFitnessFromHr = function(mxpul, hvpul, wgt) { var mxpul, hvpul, wgt; - + mxpul = mxpul; hvpul = hvpul; wgt = wgt; - + function getMaximalOxygen() { var konditalM = mxpul / hvpul * 15.3; var maxiltop = Math.round(konditalM * wgt / 1000 * Math.pow(10, 2)) / Math.pow(10, 2); return maxiltop; } - - function getFitnessLevel() - { + + function getFitnessLevel() { var konditalM = mxpul / hvpul * 15.3; var kondi = Math.round((konditalM) * Math.pow(10, 1)) / Math.pow(10, 1); - return kondi; + return kondi; } - + var publicAPI = { - getMaximalOxygen : getMaximalOxygen, - getFitnessLevel : getFitnessLevel - - }; + getMaximalOxygen: getMaximalOxygen, + getFitnessLevel: getFitnessLevel + + }; - return publicAPI; + return publicAPI; } module.exports = motionsplan; diff --git a/assets/js/max-hr.js b/assets/js/max-hr.js index e85ffd3e7059..2ff5763acc2f 100644 --- a/assets/js/max-hr.js +++ b/assets/js/max-hr.js @@ -2,19 +2,18 @@ let motionsplan = {} motionsplan.EstimateMaxHr = function(ald) { var ald; - + ald = ald; - function getMaxHr() - { + function getMaxHr() { return Math.round((208 - 0.7 * ald) * Math.pow(10, 0)) / Math.pow(10, 0); } - + var publicAPI = { - getMaxHr : getMaxHr - }; + getMaxHr: getMaxHr + }; - return publicAPI; + return publicAPI; } module.exports = motionsplan; diff --git a/test/1rm.js b/test/1rm.js index 013f54b2c155..63f603579d00 100644 --- a/test/1rm.js +++ b/test/1rm.js @@ -9,13 +9,14 @@ describe('Estimate1RM', function() { assert.equal(rm.getBrzycki(), 113); assert.equal(rm.getLander(), 114); assert.equal(rm.getLombardi(), 117); - assert.equal(rm.getMayhewetal(), 119); - assert.equal(rm.getOconneretal(), 113); + assert.equal(rm.getMayhew(), 119); + assert.equal(rm.getOconnor(), 113); assert.equal(rm.getWathan(), 117); assert.equal(rm.getMOL(1, 1), 108.68442932523273); assert.equal(rm.getMOL(1, 0), 109.94750006871719); assert.equal(rm.getMOL(0, 1), 111.90564116337104); assert.equal(rm.getMOL(0, 0), 112.76118309033298); + assert.equal(rm.getMOLBryzki(), 112.51125112511251) }); }); });