-
Notifications
You must be signed in to change notification settings - Fork 0
/
companies.html
177 lines (164 loc) · 9.84 KB
/
companies.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<html lang="pt-br">
<head>
<link rel="stylesheet" href="style.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ANAC 2015-2020</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/locale/pt-br.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script>
fetch("data/icao_companies.json").then(res => res.json()).then(function(json) {
let str = ""
for(let j in json) {
if(!json.hasOwnProperty(j)) continue;
str += "<option value='"+j+"' label='"+json[j]["Airline"]+"' />\n"
}
document.getElementById("companies").innerHTML = str
})
</script>
</head>
<body>
<div class="page">
<div class="topnav" id="topnav">
<a href="index.html">Geral</a>
<a href="dates.html">Datas</a>
<a href="airports.html">Aeroportos</a>
<a href="companies.html" class="selected">Empresas</a>
<a href="about.html">Sobre</a>
<div class="space"></div>
<a class="collapse" onclick="collapseTopNav()">...</a>
</div>
<div class="content">
<div class="box" id="date_box">
<p>Por favor selecione a empresa que deseja consultar:</p>
<datalist id="companies"></datalist>
<form action="companies.html" method="get" class="group">
<label for="company">Empresa: </label>
<input list="companies" name="company" id="company" >
<input type="submit" value="Consultar">
</form>
</div>
<div id="content_box" style="display: none;">
<div class="group">
<div class="box">
<h2>Ficha técnica da Empresa</h2>
<p>ICAO <span class="counter" id="icao">N/A</span></p>
<p>Nome <span class="counter" id="name">N/A</span></p>
<p>País <span class="counter" id="country">N/A</span></p>
</div>
<div class="box">
<h2>Informações importantes</h2>
<p>Quantidade de voos registrados <span class="counter" id="flights">N/A</span></p>
<p>Quantidade de voos atrasados <span class="counter" id="delayedFlights">N/A</span> <span style="font-weight: bold" id="delayedFlightsPercentage"></span></p>
<p>Quantidade de voos cancelados <span class="counter" id="cancelledFlights">N/A</span> <span style="font-weight: bold" id="cancelledFlightsPercentage"></span></p>
</div>
<div class="box">
<h2>Informações importantes</h2>
<p>Partida mais comum <span class="counter" id="departure">N/A</span> <span style="font-weight: bold" id="departureFlights"></span></p>
<p>Destino mais comum <span class="counter" id="arrival">N/A</span> <span style="font-weight: bold" id="arrivalFlights"></span></p>
<p>Rota mais comum <span class="counter" id="route">N/A</span> <span style="font-weight: bold" id="routeFlights"></span></p>
</div>
</div>
<div class="box">
<p>Gráfico de Voos por Dia</p>
<canvas id="flightGraph"></canvas>
</div>
</div>
</div>
<div class="space"></div>
<footer>
<div>
<p>Feito por: Carolaine, Elian Luz, Euma Santos e Luca Argolo<br/>Dúvidas? Mande um email para <a style="color:cornflowerblue" href="mailto:[email protected]">[email protected]</a></p>
</div>
<div class="space"></div>
<p>Trabalho de MATA62 (Engenharia de Software)<br/>2020.3 - UFBA</p>
<p> </p>
<p><a href="https://github.com/lucaargolo/historico-de-voos">
<svg width="40px" height="38px" role="img" viewBox="0 0 24 24">
<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" fill="#FFFFFF"/>
</svg>
</a></p>
</footer>
</div>
</body>
<script src="common.js"></script>
<!--suppress JSFileReferences -->
<script type="module">
import { CountUp } from "https://cdn.jsdelivr.net/npm/[email protected]/dist/countUp.min.js"
const url = new URL(window.location.href);
const company = url.searchParams.get("company");
if(company != null && company.length === 3) {
document.getElementById("date_box").style = "display: none;"
document.getElementById("content_box").style = "display: flex; flex-direction: column;"
fetch("data/icao_companies.json").then(res => res.json()).then(function(json) {
document.getElementById("icao").innerText = company
document.getElementById("name").innerText = json[company]["Airline"]
document.getElementById("country").innerText = json[company]["Country/Region"]
})
fetch("data/generated/voosPorEmpresaDia.json").then(res => res.json()).then(function(json) {
let flights = json[company]
let flightsKeys = Object.keys(flights)
flightsKeys.sort()
let flightsSorted = {}
for(let k in flightsKeys) {
let key = flightsKeys[k]
flightsSorted[key] = flights[key]
}
let xs = []
let day_ys = []
let mean_ys = []
let sum_array = []
let sum = 0
for(let d in flightsSorted) {
if(!flightsSorted.hasOwnProperty(d)) continue;
sum += flightsSorted[d]
let num = parseInt(d)
if(num > 1417392000) { //Check if the date is after 01-12-2014
xs.push(num)
day_ys.push(flightsSorted[num])
sum_array.unshift(flightsSorted[num])
if(sum_array.length > 7) {
sum_array.pop()
}
let sum = 0
for(let s in sum_array) {
if(!sum_array.hasOwnProperty(s)) continue;
sum += sum_array[s]
}
mean_ys.push(Math.floor(sum/sum_array.length))
}
}
new CountUp('flights', sum).start();
createFlightGraph("flightGraph", xs, mean_ys, day_ys)
fetch("data/generated/voosAtrasadosPorEmpresa.json").then(res => res.json()).then(function(subJson) {
new CountUp('delayedFlights', subJson[company]).start();
document.getElementById("delayedFlightsPercentage").innerText = "(" + ((subJson[company]/sum)*100).toFixed(2) + "%)"
})
fetch("data/generated/voosCanceladosPorEmpresa.json").then(res => res.json()).then(function(subJson) {
new CountUp('cancelledFlights', subJson[company]).start();
document.getElementById("cancelledFlightsPercentage").innerText = "(" + ((subJson[company]/sum)*100).toFixed(2) + "%)"
})
fetch("data/generated/voosPorEmpresaOrigem.json").then(res => res.json()).then(function(subJson) {
let departures = subJson[company]
let mostCommon = getMostCommon(departures)
document.getElementById("departure").innerText = mostCommon[0]
document.getElementById("departureFlights").innerText = mostCommon[1] + " Voos"
})
fetch("data/generated/voosPorEmpresaDestino.json").then(res => res.json()).then(function(subJson) {
let arrivals = subJson[company]
let mostCommon = getMostCommon(arrivals)
document.getElementById("arrival").innerText = mostCommon[0]
document.getElementById("arrivalFlights").innerText = mostCommon[1] + " Voos"
})
fetch("data/generated/voosPorEmpresaRota.json").then(res => res.json()).then(function(subJson) {
let routes = subJson[company]
let mostCommon = getMostCommon(routes)
document.getElementById("route").innerText = mostCommon[0]
document.getElementById("routeFlights").innerText = mostCommon[1] + " Voos"
})
})
}
</script>
</html>