-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
77 lines (66 loc) · 2.3 KB
/
script.js
File metadata and controls
77 lines (66 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
let form = document.getElementById('calculadora');
form.style.background = 'white';
const CALCULAR = document.getElementById('calcular');
const ERROR = document.getElementById('error');
const FLU = document.getElementById('flu');
const MAN = document.getElementById('man');
CALCULAR.addEventListener('click', () => {
const DATO = document.getElementById('peso').value;
//validar la carga de datos
if(DATO >= 31){
ERROR.style.display = 'none';
let flujo1 = calcFlujo(DATO) * 1500;
let opc1 = flujo1 /24;
opc1 = Math.round(opc1);
let flujo2 = calcFlujo(DATO);
let opc2 = flujo2 * 2000;
opc2 = opc2 / 24;
opc2 = Math.round(opc2);
let mantenimiento1 = opc1 * 1.5;
let mantenimiento2 = opc2 * 1.5;
FLU.innerHTML = "Puede utilizar: Opcion 1: " + opc1 + " cc/hr o <br>" + "Puede utilizar: Opcion 2: " + opc2 + " cc/hr" ;
MAN.innerHTML = "Opcion 1: M+M/2 = " + mantenimiento1 + " cc/hr" + "<br> Opcion 2: M+M/2 = " + mantenimiento2 + " cc/hr";
FLU.style.display = 'block';
MAN.style.display = 'block';
//console.log("funciona");
}
else if (DATO >=0 && DATO <= 30){
ERROR.style.display = 'none';
let flujo = calcFlujo(DATO);
let mantenimiento = flujo*1.5;
FLU.innerHTML = flujo + ' cc/hr';
MAN.innerHTML = 'M+M/2 = ' + mantenimiento + ' cc/hr';
FLU.style.display = 'block';
MAN.style.display = 'block';
//console.log("funciona2");
}
else {
ERROR.style.display = 'block';
FLU.style.display = 'none';
MAN.style.display = 'none';
//console.log("funciona3");
}
});
function calcFlujo(peso){
let resto = Number(peso);
let flujo = 0;
let cc = 0;
if (resto > 30){
//Superficie corporal = ( (peso * 4) + 7) / (peso + 90)
let superCorpo = ((resto * 4) + 7) / (resto + 90);
return superCorpo;
} else if (resto>20) {
let aux = resto-20;
cc = aux * 20;
resto -= aux;
}
if (resto>10){
let aux = resto-10;
cc += aux * 50
resto -= aux;
}
resto = resto * 100;
cc += resto;
flujo = Math.round(cc / 24);
return flujo;
}