fix sort
This commit is contained in:
parent
4dcf7d63c3
commit
cfb7258d24
12 changed files with 5212 additions and 125 deletions
2337
wotstats/static/css/font-awesome.css
vendored
Normal file
2337
wotstats/static/css/font-awesome.css
vendored
Normal file
File diff suppressed because it is too large
Load diff
4
wotstats/static/css/font-awesome.min.css
vendored
Normal file
4
wotstats/static/css/font-awesome.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
wotstats/static/fonts/FontAwesome.otf
Normal file
BIN
wotstats/static/fonts/FontAwesome.otf
Normal file
Binary file not shown.
BIN
wotstats/static/fonts/fontawesome-webfont.eot
Normal file
BIN
wotstats/static/fonts/fontawesome-webfont.eot
Normal file
Binary file not shown.
2671
wotstats/static/fonts/fontawesome-webfont.svg
Normal file
2671
wotstats/static/fonts/fontawesome-webfont.svg
Normal file
File diff suppressed because it is too large
Load diff
After Width: | Height: | Size: 434 KiB |
BIN
wotstats/static/fonts/fontawesome-webfont.ttf
Normal file
BIN
wotstats/static/fonts/fontawesome-webfont.ttf
Normal file
Binary file not shown.
BIN
wotstats/static/fonts/fontawesome-webfont.woff
Normal file
BIN
wotstats/static/fonts/fontawesome-webfont.woff
Normal file
Binary file not shown.
BIN
wotstats/static/fonts/fontawesome-webfont.woff2
Normal file
BIN
wotstats/static/fonts/fontawesome-webfont.woff2
Normal file
Binary file not shown.
4
wotstats/static/js/jquery-latest.min.js
vendored
Normal file
4
wotstats/static/js/jquery-latest.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -7,6 +7,7 @@
|
||||||
<!-- load MUI -->
|
<!-- load MUI -->
|
||||||
<link href="//cdn.muicss.com/mui-0.9.22/css/mui.min.css" rel="stylesheet" type="text/css" />
|
<link href="//cdn.muicss.com/mui-0.9.22/css/mui.min.css" rel="stylesheet" type="text/css" />
|
||||||
<script src="//cdn.muicss.com/mui-0.9.22/js/mui.min.js"></script>
|
<script src="//cdn.muicss.com/mui-0.9.22/js/mui.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="/static/css/font-awesome.min.css">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
background-color: #f0f0f0;
|
background-color: #f0f0f0;
|
||||||
|
|
|
@ -1,36 +1,79 @@
|
||||||
{% extends 'layouts/main.html' %}
|
{% extends 'layouts/main.html' %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<style>
|
||||||
|
.not_sorted {
|
||||||
|
color: #f0f0f0;
|
||||||
|
}
|
||||||
|
.sorted {
|
||||||
|
color: #000000;
|
||||||
|
};
|
||||||
|
</style>
|
||||||
<h2>Техника</h2>
|
<h2>Техника</h2>
|
||||||
Категории
|
Категории
|
||||||
<input type="checkbox" name="checkall" id="checkall" value="1"> Все
|
<!-- <input type="checkbox" name="checkall" id="checkall" value="1"> Все -->
|
||||||
<input type="checkbox" name="cat[1]" value="1"> I
|
<input type="checkbox" name="level" class="level" value="1" {% if 1 in args.level %}checked{% endif %}> I
|
||||||
<input type="checkbox" name="cat[2]" value="2"> II
|
<input type="checkbox" name="level" class="level" value="2" {% if 2 in args.level %}checked{% endif %}> II
|
||||||
<input type="checkbox" name="cat[3]" value="3"> III
|
<input type="checkbox" name="level" class="level" value="3" {% if 3 in args.level %}checked{% endif %}> III
|
||||||
<input type="checkbox" name="cat[4]" value="4"> IV
|
<input type="checkbox" name="level" class="level" value="4" {% if 4 in args.level %}checked{% endif %}> IV
|
||||||
<input type="checkbox" name="cat[5]" value="5"> V
|
<input type="checkbox" name="level" class="level" value="5" {% if 5 in args.level %}checked{% endif %}> V
|
||||||
<input type="checkbox" name="cat[6]" value="6"> VI
|
<input type="checkbox" name="level" class="level" value="6" {% if 6 in args.level %}checked{% endif %}> VI
|
||||||
<input type="checkbox" name="cat[7]" value="7"> VII
|
<input type="checkbox" name="level" class="level" value="7" {% if 7 in args.level %}checked{% endif %}> VII
|
||||||
<input type="checkbox" name="cat[8]" value="8"> VIII
|
<input type="checkbox" name="level" class="level" value="8" {% if 8 in args.level %}checked{% endif %}> VIII
|
||||||
<input type="checkbox" name="cat[9]" value="9"> IX
|
<input type="checkbox" name="level" class="level" value="9" {% if 9 in args.level %}checked{% endif %}> IX
|
||||||
<input type="checkbox" name="cat[10]" value="10"> X
|
<input type="checkbox" name="level" class="level" value="10" {% if 10 in args.level %}checked{% endif %}> X
|
||||||
|
|
||||||
<table id="myTable" class="mui-table mui-table--bordered tablesorter">
|
<table id="myTable" class="mui-table mui-table--bordered tablesorter">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th>Нация</th>
|
<th>Нация</th>
|
||||||
<th>Уровень</th>
|
<th onclick="$(this).order_sort('level', '{% if not args.sort %}desc{% else %}asc{% endif %}')">
|
||||||
<th>Тип</th>
|
Уровень
|
||||||
<th>Название</th>
|
{% if args.order == 'level' %}
|
||||||
<th>Кол-во боёв</th>
|
<i class="fa fa-sort-alpha-{% if args.sort %}desc{% else %}asc{% endif %} sorted" aria-hidden="true"></i>
|
||||||
<th>Кол-во побед</th>
|
{% else %}
|
||||||
|
<i class="fa fa-sort-alpha-{% if args.sort %}desc{% else %}asc{% endif %} not_sorted" aria-hidden="true"></i>
|
||||||
|
{% endif %}
|
||||||
|
</th>
|
||||||
|
<th onclick="$(this).order_sort('type', '{% if not args.sort %}desc{% else %}asc{% endif %}')">
|
||||||
|
Тип
|
||||||
|
{% if args.order == 'type' %}
|
||||||
|
<i class="fa fa-sort-alpha-{% if args.sort %}desc{% else %}asc{% endif %} sorted" aria-hidden="true"></i>
|
||||||
|
{% else %}
|
||||||
|
<i class="fa fa-sort-alpha-{% if args.sort %}desc{% else %}asc{% endif %} not_sorted" aria-hidden="true"></i>
|
||||||
|
{% endif %}
|
||||||
|
</th>
|
||||||
|
<th onclick="$(this).order_sort('name', '{% if not args.sort %}desc{% else %}asc{% endif %}')">
|
||||||
|
Название
|
||||||
|
{% if args.order == 'name' %}
|
||||||
|
<i class="fa fa-sort-alpha-{% if args.sort %}desc{% else %}asc{% endif %} sorted" aria-hidden="true"></i>
|
||||||
|
{% else %}
|
||||||
|
<i class="fa fa-sort-alpha-{% if args.sort %}desc{% else %}asc{% endif %} not_sorted" aria-hidden="true"></i>
|
||||||
|
{% endif %}
|
||||||
|
</th>
|
||||||
|
<th onclick="$(this).order_sort('battles', '{% if not args.sort %}desc{% else %}asc{% endif %}')">
|
||||||
|
Кол-во боёв
|
||||||
|
{% if args.order == 'battles' %}
|
||||||
|
<i class="fa fa-sort-alpha-{% if args.sort %}desc{% else %}asc{% endif %} sorted" aria-hidden="true"></i>
|
||||||
|
{% else %}
|
||||||
|
<i class="fa fa-sort-alpha-{% if args.sort %}desc{% else %}asc{% endif %} not_sorted" aria-hidden="true"></i>
|
||||||
|
{% endif %}
|
||||||
|
</th>
|
||||||
|
<th onclick="$(this).order_sort('wins', '{% if not args.sort %}desc{% else %}asc{% endif %}')">
|
||||||
|
Кол-во побед
|
||||||
|
{% if args.order == 'wins' %}
|
||||||
|
<i class="fa fa-sort-alpha-{% if args.sort %}desc{% else %}asc{% endif %} sorted" aria-hidden="true"></i>
|
||||||
|
{% else %}
|
||||||
|
<i class="fa fa-sort-alpha-{% if args.sort %}desc{% else %}asc{% endif %} not_sorted" aria-hidden="true"></i>
|
||||||
|
{% endif %}
|
||||||
|
</th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
{#% for x in account_technic %}
|
{% for x in account_technic %}
|
||||||
<tr>
|
<tr>
|
||||||
<!-- <td>{{ x['tank_id'] }}</td> -->
|
<!-- <td>{{ x['tank_id'] }}</td> -->
|
||||||
<td><img src="{{ x.details.image }}" ></td>
|
<td><img src="{{ x.details.image }}" ></td>
|
||||||
|
@ -41,112 +84,85 @@
|
||||||
<td>{{ x['statistics']['battles'] }}</td>
|
<td>{{ x['statistics']['battles'] }}</td>
|
||||||
<td>{{ x['statistics']['wins'] }}</td>
|
<td>{{ x['statistics']['wins'] }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %#}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
|
<script src="/static/js/jquery-latest.min.js"></script>
|
||||||
<script src="/static/js/jquery.tablesorter.min.js"></script>
|
<script src="/static/js/jquery.tablesorter.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function sorter() {
|
|
||||||
setTimeout(function(){
|
|
||||||
|
|
||||||
$("#myTable").tablesorter({
|
|
||||||
sortRestart : true,
|
|
||||||
headers: {
|
|
||||||
// set "sorter : false" (no quotes) to disable the column
|
|
||||||
0: {sorter: false},
|
|
||||||
1: {sorter: false},
|
|
||||||
2: {sorter: "text"},
|
|
||||||
3: {sorter: "text"},
|
|
||||||
4: {sorter: "text"},
|
|
||||||
5: {sorter: "text"},
|
|
||||||
6: {sorter: "text"},
|
|
||||||
7: {sorter: false}
|
|
||||||
},
|
|
||||||
|
|
||||||
// ignore case while sorting
|
|
||||||
ignoreCase: true,
|
|
||||||
|
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
};
|
|
||||||
|
|
||||||
function checkall(selected) {
|
|
||||||
if (selected == 0 || selected == 10) {
|
|
||||||
$('#checkall').prop('checked', true);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
function request_seleted(selected) {
|
|
||||||
|
|
||||||
$.getJSON( "/technic/list.json", {level: selected.concat()}, function( data ) {
|
|
||||||
$('#myTable tbody').empty();
|
|
||||||
$.each( data.technic, function(key, val) {
|
|
||||||
d = val.details;
|
|
||||||
s = val.statistics;
|
|
||||||
$('#myTable tbody').append('<tr><td><img src="'+d.image+'"></td><td><img src="https://ru-wotp.wgcdn.co/static/5.7.0_023df2/wotp_static/img/core/frontend/scss/common/components/icons/img/filter-'+d.nation+'.png"> '+d.nation_i18n+'</td><td>'+d.level+'</td><td>'+d.type_i18n+'</td><td>'+d.name_i18n+'</td><td>'+s.battles+'</td><td>'+s.wins+'</td><td><a href="/technic/{{ g.wg_user_id }}/'+d.tank_id+'">Статистика</a></td></tr>');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
sorter();
|
|
||||||
};
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var inputs = $('input[name*=cat]');
|
var params = {
|
||||||
|
order: {% if args.order %}'{{ request.args.order }}'{% else%}'id'{% endif %},
|
||||||
var selected = [];
|
sort: {% if args.sort %}'{{ request.args.sort }}'{% else%}'asc'{% endif %},
|
||||||
for(var i=0; i < inputs.length; i++) {
|
level: [
|
||||||
if (inputs[i].checked == true) {
|
{% for level in args.level %}
|
||||||
selected.push(inputs[i].value);
|
{{ level|int }},
|
||||||
}
|
{% endfor %}
|
||||||
}
|
],
|
||||||
request_seleted(selected);
|
|
||||||
|
|
||||||
|
|
||||||
$('#checkall').click(function(){
|
|
||||||
var checked_count = 0;
|
|
||||||
|
|
||||||
for(var i=0; i < inputs.length; i++) {
|
|
||||||
if (inputs[i].checked == false) {
|
|
||||||
checked_count += 1;
|
|
||||||
};
|
};
|
||||||
inputs[i].checked = $('#checkall').prop('checked');
|
|
||||||
}
|
|
||||||
checkall(checked_count);
|
|
||||||
|
|
||||||
var selected = [];
|
console.log($.param(params));
|
||||||
for(var i=0; i < inputs.length; i++) {
|
|
||||||
if (inputs[i].checked == true) {
|
$(".level").change(function() {
|
||||||
selected.push(inputs[i].value);
|
console.log($(this).is(':checked'));
|
||||||
}
|
console.log("index: " + params.level.indexOf(parseInt($(this).val())));
|
||||||
}
|
|
||||||
request_seleted(selected);
|
if ($(this).is(':checked')) {
|
||||||
});
|
var int_level = parseInt($(this).val());
|
||||||
|
|
||||||
|
console.log('data: + ' + int_level);
|
||||||
|
|
||||||
|
if (params.level.indexOf(int_level) < 0) {
|
||||||
|
params.level.push(int_level);
|
||||||
|
console.log('data index: ' + params.level.indexOf(int_level));
|
||||||
|
|
||||||
|
//params.level.pop(params.level.indexOf(parseInt($(this).val())));
|
||||||
|
}
|
||||||
|
|
||||||
inputs.click(function() {
|
|
||||||
var checked_count = 0;
|
|
||||||
var selected = [];
|
|
||||||
for(var i=0; i < inputs.length; i++) {
|
|
||||||
if (inputs[i].checked == false) {
|
|
||||||
checked_count += 1;
|
|
||||||
$('#checkall').prop('checked', false);
|
|
||||||
} else {
|
} else {
|
||||||
|
var int_level = parseInt($(this).val());
|
||||||
|
|
||||||
selected.push(inputs[i].value);
|
console.log($(this).is(':checked'));
|
||||||
console.log(selected);
|
console.log("index: " + params.level.indexOf(int_level));
|
||||||
|
console.log('data: - ' + int_level);
|
||||||
|
|
||||||
|
// if (!params.level.includes(parseInt($(this).val()))) {
|
||||||
|
params.level.splice(params.level.indexOf(int_level), 1);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
console.log(params.level);
|
||||||
checkall(checked_count);
|
|
||||||
request_seleted(selected);
|
//console.log(params);
|
||||||
|
//console.log($.param(params));
|
||||||
|
window.location.replace(window.location.pathname + '?' + $.param(params));
|
||||||
|
|
||||||
|
//if (params.level.includes($(this).is(':checked'))
|
||||||
|
// var action = $(this).is(':checked');
|
||||||
|
// $.post(
|
||||||
|
// "is_checked", {id: $(this).attr('id'), action: action}
|
||||||
|
// ).done(function(data, statusText, xhr) {
|
||||||
|
// switch(xhr.status) {
|
||||||
|
// case 200:
|
||||||
|
// console.log('');
|
||||||
|
// //window.location.replace(window.location.pathname + '?' + $.param(params));
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// .fail(function(data, statusText, xhr){
|
||||||
|
// alert(xhr);
|
||||||
|
// });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
(function($) {
|
||||||
|
$.fn.order_sort = function(order, sort) {
|
||||||
|
params.order = order;
|
||||||
|
params.sort = sort;
|
||||||
|
console.log(params);
|
||||||
|
window.location.replace(window.location.pathname + '?' + $.param(params));
|
||||||
|
}
|
||||||
|
})(jQuery);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -28,7 +28,8 @@ def __get_technic():
|
||||||
}
|
}
|
||||||
|
|
||||||
__ = requests.get(url, params=payload).json()
|
__ = requests.get(url, params=payload).json()
|
||||||
return __.get('data', {}).get(user_id)
|
xx = __.get('data', {}).get(user_id)
|
||||||
|
return xx
|
||||||
|
|
||||||
def __get_technic_user_tank(tank_id):
|
def __get_technic_user_tank(tank_id):
|
||||||
# ?application_id=502910c1c785c3c7ca2e83c9e89bde02&account_id=69552613&tank_id=5121&r_realm=ru&run=1
|
# ?application_id=502910c1c785c3c7ca2e83c9e89bde02&account_id=69552613&tank_id=5121&r_realm=ru&run=1
|
||||||
|
@ -53,25 +54,8 @@ def index():
|
||||||
if not g.user:
|
if not g.user:
|
||||||
return redirect(url_for('pages_home.index'))
|
return redirect(url_for('pages_home.index'))
|
||||||
|
|
||||||
# TODO: total accounts
|
|
||||||
#
|
|
||||||
account_technic = list()
|
|
||||||
for x in __get_technic():
|
|
||||||
x['details'] = t.get(str(x['tank_id']))
|
|
||||||
account_technic.append(x)
|
|
||||||
|
|
||||||
return render_template(
|
|
||||||
'pages/account/technic.html',
|
|
||||||
account_technic=account_technic
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pages_technic.route('/list.json')
|
|
||||||
def list_json():
|
|
||||||
if not g.user:
|
|
||||||
return redirect(url_for('pages_home.index'))
|
|
||||||
|
|
||||||
list_levels = []
|
list_levels = []
|
||||||
|
print(request.args.getlist('level[]'))
|
||||||
if len(request.args.getlist('level[]')) > 0:
|
if len(request.args.getlist('level[]')) > 0:
|
||||||
list_levels = []
|
list_levels = []
|
||||||
for i in request.args.getlist('level[]'):
|
for i in request.args.getlist('level[]'):
|
||||||
|
@ -90,7 +74,77 @@ def list_json():
|
||||||
x['details'] = t.get(str(x['tank_id']))
|
x['details'] = t.get(str(x['tank_id']))
|
||||||
account_technic.append(x)
|
account_technic.append(x)
|
||||||
|
|
||||||
return jsonify(technic=account_technic)
|
order_keys = {
|
||||||
|
'level': lambda data: data['details']['level'],
|
||||||
|
'nation': lambda data: data['details']['nation'],
|
||||||
|
'type': lambda data: data['details']['type'],
|
||||||
|
'name': lambda data: data['details']['name_i18n'],
|
||||||
|
'battles': lambda data: data['statistics']['battles'],
|
||||||
|
'wins': lambda data: data['statistics']['wins'],
|
||||||
|
}
|
||||||
|
if request.args.get('order', 'level') in order_keys:
|
||||||
|
order = order_keys[request.args.get('order', 'level')]
|
||||||
|
else:
|
||||||
|
order = order_keys['level']
|
||||||
|
|
||||||
|
reverse = False if request.args.get('sort') == 'asc' else True
|
||||||
|
|
||||||
|
technic = sorted(account_technic, key=order, reverse=reverse)
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
'pages/account/technic.html',
|
||||||
|
account_technic=technic,
|
||||||
|
args={
|
||||||
|
'level': list_levels,
|
||||||
|
'sort': reverse,
|
||||||
|
'order': request.args.get('order', 'level'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pages_technic.route('/list.json')
|
||||||
|
def list_json():
|
||||||
|
if not g.user:
|
||||||
|
return redirect(url_for('pages_home.index'))
|
||||||
|
|
||||||
|
list_levels = []
|
||||||
|
print(request.args.getlist('level'))
|
||||||
|
if len(request.args.getlist('level')) > 0:
|
||||||
|
list_levels = []
|
||||||
|
for i in request.args.getlist('levelss'):
|
||||||
|
list_levels.append(int(i))
|
||||||
|
|
||||||
|
# TODO: total accounts
|
||||||
|
#
|
||||||
|
account_technic = list()
|
||||||
|
|
||||||
|
for x in __get_technic():
|
||||||
|
if len(list_levels) == 0:
|
||||||
|
x['details'] = t.get(str(x['tank_id']))
|
||||||
|
account_technic.append(x)
|
||||||
|
else:
|
||||||
|
if t.get(str(x['tank_id'])).get('level') in list_levels:
|
||||||
|
x['details'] = t.get(str(x['tank_id']))
|
||||||
|
account_technic.append(x)
|
||||||
|
|
||||||
|
order_keys = {
|
||||||
|
'level': lambda data: data['details']['level'],
|
||||||
|
'nation': lambda data: data['details']['nation'],
|
||||||
|
'type': lambda data: data['details']['type'],
|
||||||
|
'name': lambda data: data['details']['name_i18n'],
|
||||||
|
'battles': lambda data: data['statistics']['battles'],
|
||||||
|
'wins': lambda data: data['statistics']['wins'],
|
||||||
|
}
|
||||||
|
if request.args.get('order', 'level') in order_keys:
|
||||||
|
order = order_keys[request.args.get('order', 'level')]
|
||||||
|
else:
|
||||||
|
order = order_keys['level']
|
||||||
|
|
||||||
|
reverse = False if request.args.get('sort') == 'asc' else True
|
||||||
|
|
||||||
|
technic = sorted(account_technic, key=order, reverse=reverse)
|
||||||
|
#technic = account_technic
|
||||||
|
return jsonify(technic=technic, levels=list_levels)
|
||||||
|
|
||||||
|
|
||||||
@pages_technic.route('/<int:user_id>/<int:tank_id>/')
|
@pages_technic.route('/<int:user_id>/<int:tank_id>/')
|
||||||
|
|
Reference in a new issue