-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
101 lines (81 loc) · 2.56 KB
/
script.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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var temp;
var hum;
var dp;
var comfo;
timeout();
function get_temp(){
temp = parseFloat(0.8*document.getElementById("temp_range").value-20);
}
function get_hum(){
hum = document.getElementById("hum_range").value;
}
function get_dp(T,RH){
dp = (243.12*(Math.log(RH/100)+((17.62*T)/(243.12+T))))/(17.62-((Math.log(RH/100))+((17.62*T)/(243.12+T))));
}
function prg_bar(prg){
var value = parseFloat(25/6*prg-25)
if(value<=0){
document.getElementById("bar-temp").style.width = String(0) + "%";
}
else {
document.getElementById("bar-temp").style.width = String(value) + "%";
}
}
function copas() {
/* Get the text field */
copyText = document.getElementById("output");
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /* For mobile devices */
/* Copy the text inside the text field */
navigator.clipboard.writeText(copyText.value);
}
function getVal_output() {
valueof_output = String(document.getElementById('output').value);
}
function Comf(Dew){
if(Dew >= 25.14){
document.getElementById("bar-temp").style.backgroundColor = "darkred"
return "Very uncomfortable";
}
else if(Dew < 25.14 && Dew >= 22.01){
document.getElementById("bar-temp").style.backgroundColor = "red"
return "Uncomfortable";
}
else if(Dew < 22.01 && Dew >= 19.04){
document.getElementById("bar-temp").style.backgroundColor = "yellow"
return "Alright";
}
else if(Dew < 19.04 && Dew >= 16.06){
document.getElementById("bar-temp").style.backgroundColor = "green"
return "Comfortable";
}
else if(Dew < 16.06 && Dew >= 7.08){
document.getElementById("bar-temp").style.backgroundColor = "skyblue"
return "Dry";
}
else if(Dew < 7.08){
document.getElementById("bar-temp").style.backgroundColor = "lightblue"
return "Too dry";
}
else{
return "Error";
}
}
function timeout() {
setTimeout(function () {
if(typeof temp == "undefined" || typeof hum == "undefined"){
temp = 20;
hum = 50;
dp = 9;
}
get_dp(temp, hum);
comfo = Comf(dp);
prg_bar(dp);
document.getElementById("temp_tag").innerHTML = parseInt(temp);
document.getElementById("hum_tag").innerHTML = parseInt(hum);
document.getElementById("dp_tag").innerHTML = parseInt(dp);
document.getElementById("explain_tag").innerHTML = comfo;
timeout();
}, 50);
}