-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.html
71 lines (60 loc) · 2.35 KB
/
index.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
<!doctype html>
<html>
<head>
<title>metar.js</title>
<style type="text/css">
textarea.metar-input {
width: 100%;
max-width: 600px;
}
button.parse-metar {
display: block;
}
</style>
</head>
<body>
<a href="https://github.com/skydivejkl/metar.js"><img style="position: fixed; top: 0; right: 0; border: 0; z-index: 1000; margin: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<h1>metar.js</h1>
<p>
<a href="http://en.wikipedia.org/wiki/METAR">METAR</a> (Meteorological Aviation Report) parser for Javascript.
</p>
<h2>Demo</h2>
<p>
Get reports for example from
<a href="http://weather.noaa.gov/pub/data/observations/metar/stations/">weather.noaa.gov</a>
or
<a href="http://www.yle.fi/tekstitv/txt/P428_02.html">YLE Teksti-TV</a>.
</p>
<textarea autofocus class="metar-input" placeholder="EFJY 201050Z AUTO 16007KT 9999 -SHRA OVC060CB 15/09 Q1017"></textarea>
<button class="parse-metar">Parse</button>
<script src="metar.js"></script>
<pre class="metar-result">
</pre>
<script>
(function() {
var input = document.querySelector("textarea.metar-input");
var output = document.querySelector("pre.metar-result");
function parse(e) {
if (e) e.preventDefault();
if (!input.value.trim()) input.value = input.placeholder;
try {
var result = parseMETAR(input.value);
} catch(err) {
output.innerText = "Parse error: " + err.message;
}
if (result) {
output.innerText = JSON.stringify(parseMETAR(input.value), null, " ");
location.hash = escape(input.value);
}
}
if (location.hash) {
input.value = unescape(location.hash.substring(1));
parse();
}
document
.querySelector("button.parse-metar")
.addEventListener("click", parse , false);
}());
</script>
</body>
</html>