1 | <?php |
||
2 | namespace Anax\View; |
||
3 | |||
4 | ?> |
||
5 | <a href="Ip3">TILLBAKA</a> |
||
6 | <h1><?= htmlentities($ipadress) ?></h1> |
||
7 | |||
8 | <?php if ($validerbar) : ?> |
||
9 | <h4>Väderrapport kommande 5 dagar</h4> |
||
10 | <?php if ($weatherForecast) : |
||
11 | echo "<table class='table'> |
||
12 | <tr> |
||
13 | <th>Dag & Tid</th> |
||
14 | <th>Väderslag</th> |
||
15 | <th>Temp</th> |
||
16 | <th>Väderbild</th> |
||
17 | </tr>"; |
||
18 | |||
19 | ?> |
||
20 | |||
21 | <?php foreach ($weatherForecast["list"] as $key => $row) : |
||
22 | ?> |
||
23 | <?php |
||
24 | echo "<tr>"; |
||
25 | echo "<td>" . trim(json_encode($row["dt_txt"]), '"') . "</td>"; |
||
26 | echo "<td>" . trim(json_encode($row["weather"][0]["main"]), '"') . "</td>"; |
||
27 | echo "<td>" . round(json_encode($row["main"]["temp"]-273.15), 1). " C°" . "</td>"; |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
28 | echo "<td><img src=\"http://openweathermap.org/img/wn/" . trim(json_encode($row["weather"][0]["icon"]), '"') . "@2x.png\"></td>"; |
||
29 | endforeach; |
||
30 | echo "</tr>"; |
||
31 | echo "</table>"; |
||
32 | ?> |
||
33 | <h4>Väderrapport för de dagar som har varit (Olika många dagar beroende på stad)</h4> |
||
34 | <?php if ($weatherHistory) : |
||
35 | echo "<table class='table'> |
||
36 | <tr> |
||
37 | <th>För hur många dagar sen</th> |
||
38 | <th>Väderslag</th> |
||
39 | <th>Temp</th> |
||
40 | <th>Väderbild</th> |
||
41 | </tr>"; |
||
42 | |||
43 | ?> |
||
44 | |||
45 | <?php foreach ($weatherHistory["list"] as $key => $row) : |
||
46 | ?> |
||
47 | <?php |
||
48 | echo "<tr>"; |
||
49 | echo "<td>" .json_encode($key + 1). "</td>"; |
||
50 | echo "<td>" . trim(json_encode($row["weather"][0]["main"]), '"') . "</td>"; |
||
51 | echo "<td>" . round(json_encode($row["main"]["temp"]-273.15), 1). " C°" . "</td>"; |
||
52 | echo "<td><img src=\"http://openweathermap.org/img/wn/" . trim(json_encode($row["weather"][0]["icon"]), '"') . "@2x.png\"></td>"; |
||
53 | endforeach; |
||
54 | echo "</tr>"; |
||
55 | echo "</table>"; |
||
56 | ?> |
||
57 | <h1>Karta</h1> |
||
58 | <?php |
||
59 | $city = trim(json_encode($weatherForecast["city"]["name"]), '"'); |
||
60 | $country = trim(json_encode($weatherForecast["city"]["country"]), '"'); |
||
61 | $long = trim(json_encode($weatherForecast["city"]["coord"]["lon"]), '"'); |
||
62 | $lat = trim(json_encode($weatherForecast["city"]["coord"]["lat"]), '"'); |
||
63 | ?> |
||
64 | <p>Stad: <?= $city ?></p> |
||
65 | <p>Land: <?= $country ?></p> |
||
66 | <p>Longitude: <?= $long ?></p> |
||
67 | <p>Latitude: <?= $lat ?></p> |
||
68 | <p style="display: none;" id="longitude"><?= $long ?></p> |
||
69 | <p style="display: none;" id="latitude"><?= $lat ?></p> |
||
70 | <div style="height: 500px;" id="map"></div> |
||
71 | <link rel="stylesheet" type="text/css" href="https://unpkg.com/[email protected]/dist/leaflet.css"> |
||
72 | <script src='https://unpkg.com/[email protected]/dist/leaflet.js'></script> |
||
73 | <script type="text/javascript"> |
||
74 | var longitude = document.getElementById('longitude').innerText; |
||
75 | var latitude = document.getElementById('latitude').innerText; |
||
76 | var map = L.map('map').setView([latitude, longitude], 11); |
||
77 | |||
78 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
||
79 | attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' |
||
80 | }).addTo(map); |
||
81 | |||
82 | L.marker([latitude, longitude]).addTo(map) |
||
83 | .openPopup(); |
||
84 | </script> |
||
85 | <?php endif; ?> |
||
86 | <?php endif; ?> |
||
87 | <?php else : ?> |
||
88 | <p>Staden <?= htmlentities($ipadress) ?> hittades inte, var vänligen och försök igen. <a href="Ip3">TILLBAKA</a></p> |
||
89 | <?php endif; ?> |
||
90 |