-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmob.php
70 lines (61 loc) · 2.17 KB
/
mob.php
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
<?php
/*
* Mobile version of the site
*
* Simplified layout and no javascript
*
*/
$file = file_get_contents('data.json');
$data = json_decode($file, true);
?>
<html>
<head>
<title>Wellington real-time weather data</title>
</head>
<body>
<h2>Wellington real-time weather data</h2>
<table border="1" cellspacing="0" cellpadding="5">
<thead>
<tr>
<th rowspan="2">Location</th>
<th colspan="4">Wind</th>
<th rowspan="2">Temp.</th>
<th rowspan="2">Pressure</th>
<th rowspan="2">Observation Time</th>
<th rowspan="2">Source</th>
</tr>
<tr>
<th>Speed</th>
<th colspan="2">Direction</th>
<th>Gust</th>
</thead>
<tbody id="tablebody">
<?php
foreach ($data as $row) {
$site = ($row['name']) ? $row['name'] : 'Unknown';
$comment = ($row['comment']) ? '<small>'.$row['comment'].'</small>' : '';
$link = ($row['link']) ? '<a href="'.$row['link'].'">Source</a>' : '—';
$temp = ($row['reading']['temp'] !== false) ? $row['reading']['temp'].'°C' : '—';
$pressure = ($row['reading']['pressure'] !== false) ? $row['reading']['pressure'].' mb' : '—';
$windSpeed = ($row['reading']['windSpeed'] !== false) ? (round(10.0*$row['reading']['windSpeed'])/10.0).' kts' : '—';
$windGust = ($row['reading']['windGust'] !== false) ? (round(10.0*$row['reading']['windGust'])/10.0).' kts' : '—';
if ($row['reading']['windDir'] !== false) {
$windDir = $row['reading']['windDir'].'°';
$windCardinal = ($row['reading']['windCardinal']) ? $row['reading']['windCardinal'] : '—';
} else {
$windDir = '—';
$windCardinal = '—';
}
$obsTime = $row['reading']['obsTime'];
$obsTimeFormatted = ($row['reading']['obsTimeFormatted']) ? $row['reading']['obsTimeFormatted'] : 'Obs time unknown';
print '<tr><td>'.$site.'</td>';
print '<td>'.$windSpeed.'</td><td>'.$windDir.'</td><td>'.$windCardinal.'</td>';
print '<td>'.$windGust.'</td><td>'.$temp.'</td><td>'.$pressure.'</td><td>'.$obsTimeFormatted.'</td>';
print '<td>'.$link.'</td></tr>';
}
?>
</tbody>
</table>
<p>This page is for mobile phones. The full version of this page is <a href="kiting.html">here</a>.</p>
</body>
</html>