-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
71 lines (67 loc) · 2.07 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>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>
<tbody id="tides">
</tbody>
</thead>
</table>
</div>
<script>
const harmonicsOptions = {};
</script>
<script src="./tide-predictor.js"></script>
<script>
(()=> {
fetch(
'https://raw.githubusercontent.com/indridieinarsson/sun_and_tides/master/rvk.json'
)
.then(response => {
return response.json()
}).then(harmonics => {
// console.log('"blefl')
// console.log(harmonics)
// console.log("---")
const startDate = new Date()
const endDate = new Date(startDate.getTime() + (10 * 24 * 60 * 60 * 1000))
let pred = tidePredictor(harmonics, {phaseKey: 'phase',})
const highLow = pred.getExtremesPrediction({
start: startDate,
end: endDate,
labels: {
//optional human-readable labels
high: 'High tide',
low: 'Low tide',
},
})
console.log("tides : ")
console.log(highLow)
console.log("---------")
//const highLow = tidePredictor(harmonics, {phaseKey: 'phase',
// } ).getExtremesPrediction(new Date('2019-01-01'), new Date('2019-01-10'))
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>