Math.round(1234.1); //1234
Math.round(1234.1/10) * 10; //1230
Math.round(1234.1/100) * 100; //1200
$('#filter-aply').on('click', () => {
const jsMetr = $("#js-range__metr");
const jsRange = $("#js-range__price");
const etage = parseFloat($('.filter-item__buttons').children('.button.active').data('etg'));
// Square
const squareMin = parseFloat(jsMetr.data('from'));
const squareMax = parseFloat(jsMetr.data('to'));
// Price
const priceMin = parseFloat(jsRange.data('from'));
const priceMax = parseFloat(jsRange.data('to'));
let dataCount = 0;
$('.sale-item').each(function() {
const etageLocal = parseFloat($(this).data('etage'));
const price = parseFloat($(this).data('price'));
const square = parseFloat($(this).data('square'));
let eqPrice = false;
let eqEtage = false;
let eqSquare = false;
if (price <= priceMax && price >= priceMin) eqPrice = true;
if (etageLocal == etage) eqEtage = true;
if (square <= squareMax && square >= squareMin) eqSquare = true
if (!eqEtage || !eqPrice || !eqSquare) {
$(this).removeClass('showed')
$(this).removeAttr('data-count')
}
if(eqPrice && eqEtage && eqSquare){
$(this).addClass('showed')
dataCount++;
$(this).attr('data-count', dataCount)
$('.sale-item__eye').attr('data-position', dataCount)
$('.sale-item[data-count="1"]').click()
}
});
});