-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlength.html
262 lines (248 loc) · 9.46 KB
/
length.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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Length Converter - Convert Meters, Kilometers, Miles & More</title>
<meta name="description"
content="Convert length units like meters, kilometers, miles, and more with our simple and fast online converter." />
<meta name="keywords"
content="length converter, meters to kilometers, convert miles, length unit conversion, distance calculator,real time length converter" />
<link rel="shortcut icon" href="./images/length.webp" type="image/x-icon">
<link rel="stylesheet" href="./styles.css">
<link rel="stylesheet" href="./footer.css">
</head>
<body>
<nav>
<div class="menu-toggle" onclick="toggleMenu()">
<span></span>
<span></span>
<span></span>
</div>
<div class="nav-links">
<a href="./index.html">Home</a>
<a href="./data.html">Data <span id="converterText">Converter</span></a>
<a href="./length.html" class="bb">Length <span id="converterText">Converter</span></a>
<a href="./time.html">Time <span id="converterText">Converter</span></a>
<a href="./mass.html">Mass <span id="converterText">Converter</span></a>
<a href="./temperature.html">Temperature <span id="converterText">Converter</span></a>
<a href="./numbersystem.html">Number System <span id="converterText">Converter</span></a>
<a href="./discount.html">Discount <span id="converterText">Calculator</span></a>
<a href="./power.html">Power mod <span id="converterText">Calculator</span></a>
<a href="./text.html">Text Styler</a>
</div>
</nav>
<div class="container">
<img src="./images/length.webp" alt="Data" class="description-image">
<h1>Length Converter</h1>
<input type="number" title="Enter length" name="input-value" id="input-value" placeholder="Enter length">
<select name="input-type" id="input-type" title="Click to select">
<option value="nm">Nanometer</option>
<option value="mmm">Micrometer</option>
<option value="mm">Millimeter (mm)</option>
<option value="cm">Centimeter (cm)</option>
<option value="m">Meter (m)</option>
<option value="km">Kilometer (km)</option>
<option value="in">Inch (in)</option>
<option value="ft">Foot (ft)</option>
<option value="yd">Yard (yd)</option>
<option value="mi">Mile (mi)</option>
<option value="nmi">Nautical Mile</option>
<option value="fr">Furlong</option>
<option value="au">Astronomical Unit (AU)</option>
<option value="ly">Light Year (ly)</option>
<option value="pc">Parsec (pc)</option>
<option value="fa">Fathom</option>
<option value="A">Angstrom</option>
</select>
<br>
<div class="convert-logo-div">
<img src="./images/animated/convert.gif" alt="Convert" class="description-image">
</div>
<input type="number" name="output-value" id="output-value" title="Output" placeholder="Converted Length">
<Select name="output-type" id="output-type" title="Click to select">
<option value="nm">Nanometer</option>
<option value="mmm">Micrometer</option>
<option value="mm">Millimeter (mm)</option>
<option value="cm">Centimeter (cm)</option>
<option value="m">Meter (m)</option>
<option value="km">Kilometer (km)</option>
<option value="in">Inch (in)</option>
<option value="ft">Foot (ft)</option>
<option value="yd">Yard (yd)</option>
<option value="mi">Mile (mi)</option>
<option value="nmi">Nautical Mile</option>
<option value="fr">Furlong</option>
<option value="au">Astronomical Unit (AU)</option>
<option value="ly">Light Year (ly)</option>
<option value="pc">Parsec (pc)</option>
<option value="fa">Fathom</option>
<option value="A">Angstrom</option>
</select>
</div>
<footer>
<div class="footer-container">
<div class="footer-info">
<p>© 2024 Arun Neupane. All rights reserved.</p>
<p>Made with ❤️ by Arun Neupane</p>
</div>
<div class="footer-links">
<a href="./about.html">About</a>
<a href="./privacy.html">Privacy Policy</a>
<a href="./contact.html">Contact</a>
</div>
</div>
</footer>
<script src="nav.js"></script>
<script>
const inputType = document.getElementById("input-type");
const outputType = document.getElementById("output-type");
const inputValue = document.getElementById("input-value");
const outputValue = document.getElementById("output-value");
inputType.selectedIndex = 4;
outputType.selectedIndex = 3;
inputType.addEventListener("change", () => {
if (inputValue.value !== "") {
change(parseFloat(inputValue.value), 0, inputType, outputType);
}
});
outputType.addEventListener("change", () => {
if (inputValue.value !== "") {
change(0, parseFloat(outputValue.value), outputType, inputType);
}
});
inputValue.addEventListener("keyup", () => {
if (inputValue.value !== "")
change(parseFloat(inputValue.value), 0, inputType, outputType);
else
outputValue.value = "";
});
outputValue.addEventListener("keyup", () => {
if (outputValue.value !== "")
change(0, parseFloat(outputValue.value), outputType, inputType);
else
inputValue.value = "";
});
function change(m, result, inputType, outputType) {
let input = true;
if (result != 0) {
m = result;
input = false;
}
m = parseFloat(m);
switch (inputType.value) {
case "mm":
m = m / 1000;
break;
case "m":
m = m;
break;
case "cm":
m = m / 100;;
break;
case "km":
m = m * 1000;
break;
case "mmm":
m = m / 1000000;
break;
case "nm":
m /= 1000000000;
break;
case "in":
m *= 0.0254;
break;
case "ft":
m = m * 0.3048;
break;
case "yd":
m *= 0.9144;
break;
case "mi":
m = m * 1609.34;
break;
case "nmi":
m = m * 1852;
break;
case "fr":
m = m * 201.168;
break;
case "amu":
m = m * 149600000000;
break;
case "ly":
m = m * 9461000000000000;
break;
case "pc":
m = m * 30860000000000000;
break;
case "fa":
m = m * 1.8288;
break;
case "A":
m = m / 10000000000;
break;
}
switch (outputType.value) {
case "mm":
m = m * 1000;
break;
case "m":
m = m;
break;
case "cm":
m = m * 100;;
break;
case "km":
m = m / 1000;
break;
case "mmm":
m = m / 1000000;
break;
case "nm":
m *= 1000000000;
break;
case "in":
m /= 0.0254;
break;
case "ft":
m = m / 0.3048;
break;
case "yd":
m *= 0.9144;
break;
case "mi":
m = m / 1609.34;
break;
case "nmi":
m = m / 1852;
break;
case "fr":
m = m / 201.168;
break;
case "amu":
m = m / 149600000000;
break;
case "ly":
m = m / 9461000000000000;
break;
case "pc":
m = m / 30860000000000000;
break;
case "fa":
m = m / 1.8288;
break;
case "A":
m = m * 10000000000;
break;
}
if (input) {
outputValue.value = m;
}
else {
inputValue.value = m;
}
}
</script>
</body>
</html>