This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
188 lines (177 loc) · 7.6 KB
/
index.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
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
178
179
180
181
182
183
184
185
186
187
188
<?php
require_once(dirname(__FILE__).'/config.php');
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Agendas do Governo Federal</title>
<link rel="apple-touch-icon" sizes="180x180" href="/assets/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon-16x16.png">
<link rel="manifest" href="/assets/site.webmanifest">
<link rel="mask-icon" href="/assets/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="/assets/favicon.ico">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-config" content="/assets/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<meta name="description" content="Agendas do Governo Federal">
<meta name="image" content="https://adgf.altendorfme.com/assets/ogimage.png">
<meta itemprop="name" content="Agendas do Governo Federal">
<meta itemprop="description" content="Agendas do Governo Federal">
<meta itemprop="image" content="https://adgf.altendorfme.com/assets/ogimage.png">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Agendas do Governo Federal">
<meta name="twitter:description" content="Agendas do Governo Federal">
<meta name="twitter:site" content="@altendorfme">
<meta name="twitter:image:src" content="https://adgf.altendorfme.com/assets/ogimage.png">
<meta name="og:title" content="Agendas do Governo Federal">
<meta name="og:description" content="Agendas do Governo Federal">
<meta name="og:image" content="https://adgf.altendorfme.com/assets/ogimage.png">
<meta name="og:url" content="https://adgf.altendorfme.com">
<meta name="og:site_name" content="Agendas do Governo Federal">
<meta name="og:locale" content="pt_BR">
<meta name="og:type" content="website">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="//fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;700&display=swap" rel="stylesheet">
<style>
body {
background: #FBFBFB;
font-family: 'Source Code Pro', monospace;
color: #989fb1;
padding: 1rem;
font-size: 16px;
}
a {
color: #989fb1;
}
a:hover {
text-decoration: none;
}
h1 {
margin: 0;
padding-bottom: .4rem;
color: #4876d6;
}
select {
font-family: 'Source Code Pro', monospace;
font-size: 16px;
padding: .2rem;
}
.endpoint {
display: none;
margin-top: 1rem;
}
.active {
color: #aa0982;
margin-bottom: .5rem !important;
}
.endpoint p {
margin: 0;
}
.endpoint a {
color: #0c969b;
}
iframe {
width: 100%;
}
#dashboard {
box-sizing: border-box;
}
#dashboard p {
margin-top: 1rem;
margin-bottom: .2rem;
}
iframe {
background: #fff;
padding: .8rem;
width: 100%;
height: 56.25vh;
box-sizing: border-box;
}
</style>
</head>
<body>
<h1>Agendas do Governo Federal</h1>
<select name="schedule" id="schedule">
<option value="" selected disabled>Agendas</option>
<?php
$mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);
$mysqli->set_charset("utf8");
$schedules = "SELECT * FROM `schedule`";
$schedules_query = mysqli_query($mysqli, $schedules);
while($data = mysqli_fetch_array($schedules_query)) {
$id = $data['id'];
$name = $data['name'];
$url = $data['url'];
$political_party = $data['political_party'];
$department = $data['department'];
$initials = $data['initials'];
$dashboard = $data['dashboard'];
$start_date = $data['start_date'];
$active = $data['active'];
?>
<option title="teste" value="<?php echo $id; ?>" data-url="<?php echo $url; ?>" data-dashboard="<?php echo $dashboard; ?>" data-active="<?php echo $active; ?>" data-start_date="<?php echo $start_date; ?>">
<?php echo $name; ?>
<?php echo ($political_party == NULL) ? '' : ' ('.$political_party.')'; ?> -
<?php echo $department; ?><?php echo ($initials == NULL) ? '' : ' ('.$initials.')'; ?>
</option>
<?php
}
?>
</select>
<div class="endpoint" id="endpoint">
<p class="active" id="active">
A captura de dados dessa agenda está desativado pela mudança de ministro, mudança na URL da fonte de dados ou agenda indisponivel.
</p>
<p class="start_date" id="start_date">Início do mandato: <span></span></p>
<p>CSV: <a href="#" target="_blank" id="csv"></a></p>
<p>JSON: <a href="#" target="_blank" id="json"></a></p>
<p>Fonte: <a href="#" target="_blank" id="source">gov.br</a></p>
<div id="dashboard">
<p><a href="#" id="dashboard_link" target="_blank">Dashboard</a> (via <a href="https://twitter.com/BrunoHMioto" target="_blank" id="dashboard">@BrunoHMioto</a>)</p>
</div>
</div>
<p><a href="https://github.com/altendorfme/agendas-do-governo-federal" target="_blank"><strong>Github</strong></a> / <a href="https://twitter.com/altendorfme" target="_blank"><strong>Twitter</strong></a></p>
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
$(function() {
$('#schedule').on('change',function(e){
e.preventDefault();
var id = $('#schedule').val();
var url = $('#schedule').find(':selected').attr('data-url');
var active = $('#schedule').find(':selected').attr('data-active');
var start_date = $('#schedule').find(':selected').attr('data-start_date');
var dashboard = $('#schedule').find(':selected').attr('data-dashboard');
$('#dashboard iframe').remove('');
if(dashboard.length) {
$('#dashboard_link').attr('href', dashboard);
$('<iframe>', {
src: dashboard,
id: 'iframe',
frameborder: 1,
scrolling: 'yes'
}).appendTo('#dashboard');
$('#dashboard').show('');
} else {
$('#dashboard').hide('');
}
$('#endpoint').show();
$('#source').attr('href', url);
$('#start_date span').html(start_date);
if(active == 1) {
$('#active').hide();
} else {
$('#active').show();
}
var csv = '/api/'+id+'.csv';
var json = '/api/'+id+'.json';
$('#csv').attr('href', csv).html(csv);
$('#json').attr('href', json).html(json);
})
});
</script>
</body>
</html>