-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeco.js
52 lines (44 loc) · 1.21 KB
/
deco.js
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
const input = document.getElementById('input');
const input2 = document.getElementById('input2');
const log0 = document.getElementById('values0');
const log = document.getElementById('values');
const log2 = document.getElementById('values2');
var button = document.getElementById('clear');
let gas = "";
let time = "";
let hypoxic = false;
let nonStandard = false;
input.addEventListener('input', updateValue);
function updateValue(e) {
gas = e.target.value;
if(gas > "29" && gas < "33"){
gas = `Nitrox ${gas}`;
nonStandard = false;
hypoxic = false;
}
else if((gas >"21" && gas < "30")||(gas>"32")){
gas = "Standard gases and air only";
nonStandard = true;
}
else if(gas == "21"){
gas = `You dive Air`;
}
else if(gas < "21"){
gas = `Your mix is hypoxic!`;
hypoxic = true;
}
}
input2.addEventListener('input', updateValue2);
function updateValue2(f) {
time = `Dive time ${f.target.value}`;
}
button.addEventListener('click', () => {
if(hypoxic || nonStandard){
log0.textContent = gas;
}
else{
log0.textContent = `Diving calculated for ${gas} and ${time} min`;
//log.textContent = gas;
//log2.textContent = time;
}
});