-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.html
More file actions
55 lines (51 loc) · 1.47 KB
/
Copy pathindex.html
File metadata and controls
55 lines (51 loc) · 1.47 KB
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
<!doctype html>
<html>
<head>
<title>Tide Predictor in the browser</title>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
/>
</head>
<body>
<div class="container">
<h1>High/low tides for Monterey, CA</h1>
<table class="table">
<thead>
<tr>
<th>Time</th>
<th>High/Low</th>
<th>Level (meters)</th>
</tr>
</thead>
<tbody id="tides"></tbody>
</table>
</div>
<script type="module">
import tidePredictor from "./src/index.js";
fetch(
"https://api.tidesandcurrents.noaa.gov/mdapi/prod/webapi/stations/9413450/harcon.json?units=metric",
)
.then((response) => {
return response.json();
})
.then((harmonics) => {
const start = new Date();
const end = new Date(start.getTime() + 10 * 24 * 60 * 60 * 1000);
const highLow = tidePredictor(harmonics.HarmonicConstituents).getExtremesPrediction({
start,
end,
});
highLow.forEach((level) => {
const tableRow = document.createElement("tr");
tableRow.innerHTML = `
<td>${level.time}</td>
<td>${level.label}</td>
<td>${level.level}</td>
`;
document.getElementById("tides").appendChild(tableRow);
});
});
</script>
</body>
</html>