-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathpressure.js
191 lines (175 loc) · 4.31 KB
/
pressure.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
var pressfrom,pressto,pressfromval,pressvalto,constr="";
function presscalc()
{
pressfromval=document.getElementById("pressurefromval").value;
pressfrom=document.getElementById("pressfrom").value;
pressto=document.getElementById("pressto").value;
calculate();
}
function resultdisplay()
{
if(pressto==="bar")
presstofull="Bar";
else if(pressto==="pascal")
presstofull="Pascal";
else if(pressto==="torr")
presstofull="Torr";
else if(pressto==="sa")
presstofull="Standard atmosphere";
else if(pressto==="pfi")
presstofull="Pound-force per sq inch";
if(!(Number.isInteger(pressvalto)))
pressvalto=pressvalto.toFixed(5);
document.getElementById("presstoval").value=pressvalto;
document.getElementById("resulttext").innerHTML=pressvalto+" "+presstofull;
document.getElementById("formulatext").innerHTML=constr;
}
function calculate()
{
if(pressfrom==="bar")//if conversion is from bar to other
{
constr="1 bar = ";
if(pressto==="bar")
{
pressvalto = pressfromval *1;
constr+="1 bar";
}
else if(pressto==="pascal")
{
pressvalto = pressfromval * 100000;
constr+="100000 pascal";
}
else if(pressto==="torr")
{
pressvalto = pressfromval * 750.0616827;
constr+="750.0616827 torr";
}
else if(pressto==="sa")
{
pressvalto = pressfromval * 0.9869232;
constr+="0.9869232 Standard atmosphere";
}
else if(pressto==="pfi")
{
pressvalto = pressfromval * 14.5037737;
constr+="14.503773773 Pound-force per sq inch";
}
}
else if(pressfrom==="pascal")//if conversion is from pascal to other
{
constr="1 pascal = ";
if(pressto==="bar")
{
pressvalto = pressfromval * 0.00001;
constr+="0.00001 bar";
}
else if(pressto==="pascal")
{
pressvalto = pressfromval * 1;
constr+="1 pascal";
}
else if(pressto==="torr")
{
pressvalto = pressfromval * 0.0075006;
constr+="0.0075006 torr";
}
else if(pressto==="sa")
{
pressvalto = pressfromval * 0.0000098;
constr+="0.0000098 Standard atmosphere";
}
else if(pressto==="pfi")
{
pressvalto = pressfromval * 0.0001450;
constr+="0.0001450 Pound-force per sq inch";
}
}
else if(pressfrom==="torr")//if conversion is from torr to other
{
constr="1 torr = ";
if(pressto==="bar")
{
pressvalto = pressfromval * 0.0013332;
constr+="0.0013332 bar";
}
else if(pressto==="pascal")
{
pressvalto = pressfromval * 133.3223684;
constr+="133.3223684 pascal";
}
else if(pressto==="torr")
{
pressvalto = pressfromval * 1;
constr+="1 torr";
}
else if(pressto==="sa")
{
pressvalto = pressfromval * 0.0013157;
constr+="0.0013157 Standard atmosphere";
}
else if(pressto==="pfi")
{
pressvalto = pressfromval * 0.0193367;
constr+="0.0193367 Pound-force per sq inch";
}
}
else if(pressfrom==="sa")//if conversion is from standard atmosphere to other
{
constr="1 standard atmosphere = ";
if(pressto==="bar")
{
pressvalto = pressfromval * 1.01325;
constr+="1.01325 bar";
}
else if(pressto==="pascal")
{
pressvalto = pressfromval * 101325;
constr+="101325 pascal";
}
else if(pressto==="torr")
{
pressvalto = pressfromval * 760;
constr+="760 torr";
}
else if(pressto==="sa")
{
pressvalto = pressfromval * 1;
constr+="1 standard atmosphere";
}
else if(pressto==="pfi")
{
pressvalto = pressfromval * 14.6959487;
constr+="14.6959487 Pound-force per sq inch";
}
}
else if(pressfrom==="pfi")//if conversion is from pound force per sq inch to other
{
constr="1 Pound-force per sq inch = ";
if(pressto==="bar")
{
pressvalto = pressfromval * 0.068947572;
constr+="0.068947572 bar";
}
else if(pressto==="pascal")
{
pressvalto = pressfromval * 6894.7572932;
constr+="6894.7572932 pascal";
}
else if(pressto==="torr")
{
pressvalto = pressfromval * 51.7149325;
constr+="51.7149325 torr";
}
else if(pressto==="sa")
{
pressvalto = pressfromval * 0.0680459;
constr+="0.0680459 Standard atmosphere";
}
else if(pressto==="pfi")
{
pressvalto = pressfromval * 1;
constr+="1 Pound-force per sq unit";
}
}
resultdisplay();//calling display
}