Avoid NearbyTownShops

by mtenschert

HTML

<input ng-model="option.value" class="filter__slider ng-valid ng-dirty ng-valid-parse ng-touched" type="range" min="1" max="16" value="16" step="1">

<div class="product">Shop 1</div>
<div class="product">Shop 1</div>
<div class="product">Shop 1</div>
<div class="product">Shop 1</div>
<div class="product not-in-town">Not 1</div>
<div class="product not-in-town">Not 1</div>
<div class="product not-in-town">Not 1</div>
<div class="product not-in-town">Not 1</div>

JavaScript

// timeout for optimize360 asynchronous loading
setTimeout(function() {
  var allShops = $(".product").length;
  var NbTS = $(".not-in-town").length;
  if (allShops - NbTS < 5) {
    $('.product').hide();
  }
  alert(allShops - NbTS);
}, 1500);