-
Notifications
You must be signed in to change notification settings - Fork 0
/
science.html
54 lines (47 loc) · 2.19 KB
/
science.html
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
<h1 id="page-title">CO2 Calculation</h1>
<p>Select the ppm in the first box, and the lux in the second</p>
<select id="ppm" onchange="calculatePpm()">
<option value="0">0</option>
<option value="300">300</option>
<option value="600">600</option>
<option value="1200">1200</option>
</select>
<select id="lux" onchange="calculateLux()">
<option value="5000">5000</option>
<option value="15000">15000</option>
<option value="25000">25000</option>
</select>
<button onclick="calculate()">Re-run</button>
<p id="result"></p>
<script>
var freqArr = [[[0,0],[4,3],[9,4],[13,6]],[[0,0],[9,4],[13,6],[17,6]],[[0,0],[10,5],[17,6],[19,6]]];
var Ppm = 0;
var Lux = 5000;
var lLev = 1;//hanges with light level
var cLev = 0;//changes with ppm
function calculatePpm(){
Ppm = document.getElementById("ppm").value;
if(Ppm=='0') cLev=0;
else if(Ppm=='300') cLev=1;
else if(Ppm=='600') cLev=2;
else if(Ppm=='1200') cLev=3;
calculate();
}
function calculateLux(){
Lux = document.getElementById("lux").value;
if(Lux=='5000') lLev=0;
else if(Lux=='15000') lLev=1;
else if(Lux=='25000') lLev=2;
calculate();
}
function calculate(){
var b1 = freqArr[lLev][cLev][0];
var b2 = freqArr[lLev][cLev][1];
var numBubs = b1 + Math.floor(b2 * Math.random());
var timeBub = Math.ceil(60000 / (numBubs+1));
console.log(numBubs);
console.log(timeBub);
document.getElementById("result").innerHTML = numBubs;
}
calculate();
</script>