Если не работает, то поправить, думаю, сможете.
$(function() {
var get_param = location.href.split('#').shift().split('?').pop().trim(),
$nodes = $("#start-date-sort, #end-date-sort, #start-sum-sort, #end-sum-sort");
if (!get_param) {
$nodes.each(function() {
this.href = this.id + '=DESC';
});
return;
};
var Url = new URL(location.href),
str = get_param.replace(/[a-z-]*-sort=(desc|asc)/gi, '');
$nodes.each(function() {
this.href = '?' + str + '&' + this.id + '=' + (
Url.searchParams.get(this.id) == 'DESC' ? 'ASC' : 'DESC'
);
});
});
|