-
Notifications
You must be signed in to change notification settings - Fork 1
/
scouts.html
165 lines (146 loc) · 5.56 KB
/
scouts.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
<html>
<head>
<meta charset="utf-8"/>
<script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdnjs.cloudflare.com/ajax/libs/Dynatable/0.3.1/jquery.dynatable.js"></script>
<script type="text/javascript" charset="utf8" src="./mercado.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/Dynatable/0.3.1/jquery.dynatable.css">
<script type="text/javascript">
var STATUS = {
DUVIDA : 2,
SUSPENSO : 3,
CONTUDIDO : 5,
NULO : 6,
PROVAVEL : 7
};
var SCOUTS = ["RB","FC","GC","CA","CV","SG","DD","DP","GS","FS","PE","A","FT","FD","FF","G","I","PP"];
function normalizeAtletas(atleta) {
//Se atleta não possui Scout faz scout = 0
SCOUTS.forEach(function(scout){
if(!atleta.scout[scout]) atleta.scout[scout] = 0;
atleta[scout] = atleta.scout[scout];
});
//Traduz o status id do atleta para o nome do status
atleta.status = mercado.status[atleta.status_id].nome;
//Traduz o clube id do atleta para a sigla do clube
atleta.clube = mercado.clubes[atleta.clube_id].nome;
//Traduz o posicao id do atleta para o nome da posição
atleta.posicao = mercado.posicoes[atleta.posicao_id].nome;
return atleta;
}
$(document).ready( function () {
mercado.atletas.map(normalizeAtletas);
var dynatable = $('#table_id').dynatable({
dataset: { records: mercado.atletas },
features: {
pushState: document.location.protocol === 'http'
}
});
var dynatable_data = dynatable.data('dynatable');
$.each(mercado.status,function(index, value){
$('#search-status').append($('<option>', {
value: value.id,
text : value.nome
}));
});
//Criando select para filtro de status dos atletas
var searchStatus = $('#search-status');
searchStatus.change( function() {
var value = $(this).val();
if (value === "0") {
dynatable_data.queries.remove("status_id");
} else {
dynatable_data.queries.add("status_id",value);
}
dynatable_data.process();
});
searchStatus.val(STATUS.PROVAVEL);
searchStatus.trigger("change");
//Criando select para filtro de clube dos atletas
$('#search-clube-id').change( function() {
var value = $(this).val();
if (value === "0") {
dynatable_data.queries.remove("clube_id");
} else {
dynatable_data.queries.add("clube_id",value);
}
dynatable_data.process();
});
$.each(mercado.clubes,function(index, value){
$('#search-clube-id').append($('<option>', {
value: value.id,
text : value.nome
}));
});
dynatable_data.queries.functions['preco_minimo'] = function(record, queryValue) {
return parseFloat(record.preco_num) >= parseFloat(queryValue);
};
$('#search-preco-minimo').change( function() {
var value = $(this).val();
if(value) dynatable_data.queries.add("preco_minimo",value);
else dynatable_data.queries.remove("preco_minimo");
dynatable_data.process();
});
dynatable_data.queries.functions['preco_maximo'] = function(record, queryValue) {
return parseFloat(record.preco_num) <= parseFloat(queryValue);
};
$('#search-preco-maximo').change( function() {
var value = $(this).val();
if(value) dynatable_data.queries.add("preco_maximo",value);
else dynatable_data.queries.remove("preco_maximo");
dynatable_data.process();
});
});
</script>
</head>
<body>
<label for="search-status">Status</label>
<select id="search-status" name="status">
<option value="0">Todos</option>
</select>
<label for="search-clube-id">Clube</label>
<select id="search-clube-id" name="clube_id">
<option value="0">Todos</option>
</select>
<label for="search-preco-minimo">Preço Mínimo</label>
<input id='search-preco-minimo' type='text' size='3' maxlength='3'/>
<label for="search-preco-maximo">Preço Máximo</label>
<input id='search-preco-maximo' type='text' size='3' maxlength='3'/>
<table id="table_id">
<thead>
<tr>
<th data-dynatable-column="clube">Clube</th>
<th data-dynatable-column="apelido">Nome</th>
<th data-dynatable-column="jogos_num">Jogos</th>
<th data-dynatable-column="posicao">Posição</th>
<th data-dynatable-column="preco_num">Preço</th>
<th data-dynatable-column="variacao_num">Variação</th>
<th data-dynatable-column="media_num">Media</th>
<th data-dynatable-column="RB">RB</th>
<th data-dynatable-column="FC">FC</th>
<th data-dynatable-column="GC">GC</th>
<th data-dynatable-column="CA">CA</th>
<th data-dynatable-column="CV">CV</th>
<th data-dynatable-column="SG">SG</th>
<th data-dynatable-column="DD">DD</th>
<th data-dynatable-column="DP">DP</th>
<th data-dynatable-column="GS">GS</th>
<th data-dynatable-column="FS">FS</th>
<th data-dynatable-column="PE">PE</th>
<th data-dynatable-column="A">A</th>
<th data-dynatable-column="FT">FT</th>
<th data-dynatable-column="FD">FD</th>
<th data-dynatable-column="FF">FF</th>
<th data-dynatable-column="G">G</th>
<th data-dynatable-column="I">I</th>
<th data-dynatable-column="PP">PP</th>
<th data-dynatable-column="status">Status</th>
<th style="display: none" data-dynatable-column="status_id">Status ID</th>
<th style="display: none" data-dynatable-column="clube_id">Clube ID</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>