-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
75 lines (53 loc) · 3.37 KB
/
Copy pathscript.js
File metadata and controls
75 lines (53 loc) · 3.37 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
mySubmit.onclick = function(){
const ammountToMake = Number(document.getElementById("ammountToMake").value);
const aromaPercentage = Number(document.getElementById("aromaPercentage").value);
const desiredNicotineStrength = Number(document.getElementById("desiredNicotineStrength").value);
const baseNicotineStrength = Number(document.getElementById("baseNicotineStrength").value);
const mySubmit = document.getElementById("mySubmit");
const result = document.getElementById("myResult");
let aroma;
let nicBase;
let zeroBase;
if(ammountToMake === 0 || ammountToMake === null){
result.textContent = "Ammount of Liquid must be greater than 0!"
} else {
if(aromaPercentage === 0 || aromaPercentage === null){ // without aroma
if(baseNicotineStrength === 0 || baseNicotineStrength === null){
result.textContent = "you must type in nicotine strength from nicotine shot that is grater than 0!"
} else{
nicBase = (desiredNicotineStrength * ammountToMake) / baseNicotineStrength;
zeroBase = ammountToMake - nicBase;
if(isNaN(nicBase) || isNaN(zeroBase)){
result.textContent = `Only use numbers for calculation!`;
} else {
result.textContent = `${nicBase}ml Nikotin Shot + ${zeroBase}ml Base`;
}
}
} else if(desiredNicotineStrength === 0 || desiredNicotineStrength === null){ // without nicotine
if(aromaPercentage === 0 || aromaPercentage === null){
result.textContent = "you must type in aroma percentage that is greater than 0!"
} else{
aroma = (ammountToMake * aromaPercentage) / 100;
zeroBase = ammountToMake - aroma;
if(isNaN(aroma) || isNaN(zeroBase)){
result.textContent = `Only use numbers for calculation!`;
} else{
result.textContent = `${aroma}ml Aroma + ${zeroBase}ml Base`;
}
}
} else{ // do all calculations
if(baseNicotineStrength === 0 || baseNicotineStrength === null){
result.textContent = "You must type in nicotine strength from nicotine shot that is grater than 0!"
} else{
aroma = (ammountToMake * aromaPercentage) / 100;
nicBase = (desiredNicotineStrength * ammountToMake) / baseNicotineStrength;
zeroBase = ammountToMake - nicBase - aroma;
if(isNaN(aroma) || isNaN(nicBase) || isNaN(zeroBase)){
result.textContent = `Only use numbers for calculation!`;
} else{
result.textContent = `${aroma}ml Aroma + ${nicBase}ml Nikotin Shot + ${zeroBase}ml Base`;
}
}
}
}
}