Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / tv.php
blobab4a3658c9d9a3efe725af7e218497e0cf2ebea5
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Language.php');
5 $Spotter = new Spotter();
6 ?>
7 <!DOCTYPE HTML>
8 <html>
9 <head>
10 <meta charset="UTF-8">
11 <title>Spotter TV</title>
12 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
13 <link rel="shortcut icon" type="image/x-icon" href="<?php print $globalURL; ?>/favicon.ico">
14 <link rel="apple-touch-icon" href="<?php print $globalURL; ?>/images/touch-icon.png">
15 <link href='http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
16 <!--[if lt IE 9]>
17 <script type="text/javascript" src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
18 <script type="text/javascript" src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
19 <![endif]-->
20 <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
21 <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
22 <script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
23 <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
24 <link type="text/css" rel="stylesheet" href="<?php print $globalURL; ?>/css/style-tv.css?<?php print time(); ?>" />
25 </head>
26 <body>
29 <?php
30 if (isset($_GET['q']))
32 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
33 $spotter_array = $Spotter->searchSpotterData($q, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "0,10", "", "");
34 } else {
35 $spotter_array = $Spotter->getLatestSpotterData("0,10", "");
38 print '<div class="table-responsive">';
39 print '<table id="table-tv">';
40 print '<tbody>';
41 foreach ($spotter_array as $spotter_item)
43 if (isset($globalTimezone)) {
44 date_default_timezone_set($globalTimezone);
45 } else {
46 date_default_timezone_set('UTC');
48 print '<tr>';
49 if (isset($_GET['image']) && $_GET['image'] == "true")
51 if ($spotter_item['image'] != "")
53 print '<td class="aircraft_image">';
54 print '<img src="'.$spotter_item['image'].'" alt="'._("Click to see more information about this flight").'" title="'._("Click to see more information about this flight").'" />';
55 print '</td>';
56 } else {
57 print '<td class="aircraft_image">';
58 print '<img src="'.$globalURL.'/images/placeholder.png" alt="'._("Click to see more information about this flight").'" title="'._("Click to see more information about this flight").'" />';
59 print '</td>';
62 if ($globalIVAO && (@getimagesize('images/airlines/'.$spotter_item['airline_icao'].'.gif') || @getimagesize($globalURL.'/images/airlines/'.$spotter_item['airline_icao'].'.gif')))
64 print '<td class="logo">';
65 print '<img src="'.$globalURL.'/images/airlines/'.$spotter_item['airline_icao'].'.gif" />';
66 print '</td>';
67 } elseif (@getimagesize('images/airlines/'.$spotter_item['airline_icao'].'.png') || @getimagesize($globalURL.'/images/airlines/'.$spotter_item['airline_icao'].'.png'))
69 print '<td class="logo">';
70 print '<img src="'.$globalURL.'/images/airlines/'.$spotter_item['airline_icao'].'.png" />';
71 print '</td>';
72 } else {
73 print '<td class="logo-no-image">';
74 if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != "")
76 print $spotter_item['airline_name'];
77 } else {
78 print 'N/A';
80 print '</td>';
82 print '<td class="info">';
83 print '<div class="flight">';
84 print $spotter_item['departure_airport_city'].' ('.$spotter_item['departure_airport'].') <i class="fa fa-arrow-right"></i> '.$spotter_item['arrival_airport_city'].' ('.$spotter_item['arrival_airport'].')';
85 print '</div>';
86 print '<div class="other1">';
87 if ($spotter_item['registration'] != "")
89 print '<span><i class="fa fa-align-justify"></i> '.$spotter_item['registration'].'</span>';
91 if ($spotter_item['aircraft_name'] != "")
93 print '<span><i class="fa fa-plane"></i> '.$spotter_item['aircraft_name'].'</span>';
94 } else {
95 if ($spotter_item['aircraft_type'] != "")
97 print '<span><i class="fa fa-plane"></i> '.$spotter_item['aircraft_type'].'</span>';
100 print '<span><i class="fa fa-calendar"></i> '.date("r", strtotime($spotter_item['date_iso_8601'])).'</span>';
101 print '</div>';
102 print '<div class="other2">';
103 print '<span><i class="fa fa-arrow-up"></i> '.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_name'].', '.$spotter_item['departure_airport_country'];
104 if (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != '') {
105 print ' ('.$spotter_item['departure_airport_time'].')';
107 print '</span>';
108 print '<span><i class="fa fa-arrow-down"></i> '.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_name'].', '.$spotter_item['arrival_airport_country'];
109 if (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != '') {
110 print ' ('.$spotter_item['arrival_airport_time'].')';
112 print '</span>';
113 print '</div>';
114 print '<div class="other3">';
115 if ($spotter_item['ident'] != "")
117 print '<span><i class="fa fa-th-list"></i> '.$spotter_item['ident'].'</span>';
119 if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != "")
121 print '<span><i class="fa fa-align-justify"></i> '.$spotter_item['airline_name'].'</span>';
123 if ($spotter_item['airline_country'] != "")
125 print '<span><i class="fa fa-globe"></i> '.$spotter_item['airline_country'].'</span>';
127 print '</div>';
128 print '</td>';
129 print '</tr>';
131 print '<tbody>';
132 print '</table>';
133 print '</div>';
136 <script>
137 $( document ).ready(function() {
139 //loads the notification system every 16 seconds
140 setInterval( getNewDataTV, 16000 );
142 //changes the information every 10 seconds
143 setInterval( changeInformation, 10000 );
146 function getNewDataTV()
149 <?php
150 if (isset($_GET['image']) && isset($_GET['q'])) {
151 $image = filter_input(INPUT_GET,'image',FILTER_SANITIZE_STRING);
152 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
154 $.getJSON( "<?php print $globalURL; ?>/getLatestData-tv.php?other_i="+other_i+"&image=<?php print $image; ?>&q=<?php print $q; ?>", function( data ) {
155 <?php
156 } elseif (isset($_GET['image'])) {
157 $image = filter_input(INPUT_GET,'image',FILTER_SANITIZE_STRING);
159 $.getJSON( "<?php print $globalURL; ?>/getLatestData-tv.php?other_i="+other_i+"&image=<?php print $image; ?>", function( data ) {
160 <?php
161 } elseif (isset($_GET['q'])) {
162 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
164 $.getJSON( "<?php print $globalURL; ?>/getLatestData-tv.php?other_i="+other_i+"&q=<?php print $q; ?>", function( data ) {
165 <?php
166 } else {
168 $.getJSON( "<?php print $globalURL; ?>/getLatestData-tv.php?other_i="+other_i+"", function( data ) {
169 <?php
172 $.each(data.flights, function(i, item) {
173 if (item.html != "")
175 $('#table-tv').prepend(item.html);
176 $('#table-tr-'+item.flight_id).fadeIn();
177 $('#table-tv tr:last').remove();
182 var other_i = 1;
183 $('.other2').hide();
184 $('.other3').hide();
185 function changeInformation()
187 if (other_i == 1)
189 $('.other3').hide();
190 $('.other1').fadeOut( "slow", function() {
191 $('.other2').fadeIn();
193 other_i = 2;
194 } else if (other_i == 2)
196 $('.other1').hide();
197 $('.other2').fadeOut( "slow", function() {
198 $('.other3').fadeIn();
200 other_i = 3;
201 } else if (other_i == 3)
203 $('.other2').hide();
204 $('.other3').fadeOut( "slow", function() {
205 $('.other1').fadeIn();
207 other_i = 1;
210 </script>
212 </body>
213 </html>