Φίλτρα

arrowdown
grid-view-active list-view map-view
fromto-icon
' + '' var adCounter = 0; for (var i in response.products) { var prod = response.products[i]; var image = response.products[i].image.id + '.' + response.products[i].image.extension; var description = response.products[i].desc_gr; var adDate = new Date(response.products[i].updated_at).getTime(); var timestamp = new Date().getTime() - (2* 24 * 60 * 60 * 1000); var new_tag = ''; if(adDate>=timestamp) { new_tag = 'new-tag' } if (description.length > 50) { description = description.substring(0, 50) + '...'; } var product_link = '/product/' +prod.parentCategory.id + '/' + prod.id + '/' + prod.title_gr.replace(/ /g, "-").replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, ''); var item = '
' + '
' + '' + '' + response.products[i].image.title + ' ' + '
' + '
€ ' + prod.price + '
' + '
' + '
' + '' + '
' + '
'; $('#grid-view-container').append(item); if (adCounter == 5) { adCounter = 0; $('#grid-view-container').append(adBanner); } else { adCounter++; } // var a = $('
').addClass('col-16 mb-3 mb-md-4'); // var b = $('
').addClass('card'); // var c = $('
').addClass('row').attr('id','list-view'); var specs2 = ''; for (var a in prod.specs) { var colClass = (a % 2 == 0) ? 'col-md-5 col-xxl-5' : 'col-md-3 col-xxl-3'; specs2 += '
' + prod.specs[a].technical_spec_definition + '
' + '
' + prod.specs[a].value + '
'; } var listeItem = '
' + '
' + '
' + '
' + '' + response.products[i].image.title + '' + '
' + '
€ ' + prod.price + '
' + '
' + '
' + '
' + '
' + '
' + prod.title_gr + '
' + '

' + prod.coarse_address + '

' + '

' + description + '

' + '
' + specs2 + '
' + '
' + '
' + '
' + '
' + '
'; $('#list-view-container').append(listeItem) } /* $('.preSelected').attr('disabled', true); $('.preSelected').addClass("cursorDisabled"); $('.sName').addClass('inputDisabled');*/ // $('.radioSelected').attr('disabled', true); // $('.radioSelected').addClass("cursorDisabled"); // $('.rName').addClass('inputDisabled'); var responseFilters = response.filters; var uniqueSpecs = responseFilters.filter(function (itm, i, responseFilters) { return i === responseFilters.indexOf(itm); }); var filtersArray = {}; var uniqueParents = []; for (var i in uniqueSpecs) { var numOccurences = $.grep(responseFilters, function (elem) { return elem === uniqueSpecs[i]; }).length; // console.log(uniqueSpecs[i]+' '+numOccurences); filtersArray[uniqueSpecs[i]] = numOccurences; var uniqueParent = false; if ($('.radioSelected[id="' + uniqueSpecs[i] + '"]').length) { uniqueParent = $('.radioSelected[id="' + uniqueSpecs[i] + '"]').closest('.checkBox-group .collapse').attr('id'); } if (uniqueParent) { if ($.inArray(uniqueParent, uniqueParents) < 0) { uniqueParents.push(uniqueParent); } } } /*console.log('filtersArray', filtersArray); console.log('uniqueParents', uniqueParents);*/ $('.radioSelected').parent().find('.rCount').text('(' + 0 + ')'); $('.radioSelected').attr('disabled', true); $('.radioSelected').addClass("cursorDisabled"); $('.rName, .rCount').addClass('inputDisabled'); if (disableCheckboxes) { $('.preSelected').attr('disabled', true); $('.preSelected').addClass("cursorDisabled"); $('.sName, .sCount, .noCount').addClass('inputDisabled'); $('.sCount').addClass('d-none'); $('.noCount').removeClass('d-none'); } for (var x in filtersArray) { $('.radioSelected[id="' + x + '"]').parent().find('.rCount').text('(' + filtersArray[x] + ')'); $('.radioSelected[id="' + x + '"]').attr('disabled', false); $('.radioSelected[id="' + x + '"]').removeClass("cursorDisabled"); $('.radioSelected[id="' + x + '"]').parent().find('.rName, .rCount').removeClass('inputDisabled'); $('.preSelected[name="' + x + '"]').parent().find('.sCount').text('(' + filtersArray[x] + ')'); if (disableCheckboxes) { // $('.preSelected[name="' + x + '"]').parent().find('.sCount').text('(' + filtersArray[x] + ')'); $('.preSelected[name="' + x + '"]').attr('disabled', false); $('.preSelected[name="' + x + '"]').removeClass("cursorDisabled"); $('.preSelected[name="' + x + '"]').parent().find('.sName, .sCount, noCount').removeClass('inputDisabled'); $('.preSelected[name="' + x + '"]').parent().find('.sName, .sCount').removeClass('inputDisabled'); $('.preSelected[name="' + x + '"]').parent().find('.noCount').addClass('d-none'); $('.preSelected[name="' + x + '"]').parent().find('.sCount').removeClass('d-none'); } else { if (!$('#filter-sidebar').find("input[type=radio]:checked").length) { $('.preSelected.cursorDisabled').each(function () { let _this = $(this); _this.attr('disabled', false); _this.removeClass("cursorDisabled"); _this.parent().find('.sName, .sCount').removeClass('inputDisabled'); _this.parent().find('.sCount').removeClass('d-none'); _this.parent().find('.noCount').addClass('d-none'); }); } } } /* for (var i in response.filters) { /!*$('.preSelected').each(function () { var self = $(this).attr('name'); if (response.filters[i] === self){ $(this).attr('disabled', false); $(this).removeClass("cursorDisabled"); $(this).removeClass('inputDisabled'); $(this).next().removeClass('inputDisabled') } });*!/ $('.radioSelected').each(function () { var selfRadio = $(this).attr('id'); if (response.filters[i] === selfRadio){ $(this).attr('disabled', false); $(this).removeClass("cursorDisabled"); $(this).removeClass('inputDisabled'); $(this).next().removeClass('inputDisabled') } }); }*/ } function postNextData(data) { $.post('/request.php', data, function (response) { if (response && !response.error) { setData(response); } if (response.products.length > 0) { // console.log({length: response.products.length}); var cur = parseInt($('#grid-view-container').attr('data-current-count')); var value = (cur + parseInt(response.products.length)); // console.log({value: value}); $('#grid-view-container').attr('data-get-more', 'yes'); // console.log({currentCountBefore: $('#grid-view-container').attr('data-current-count')}); $('#grid-view-container').attr('data-current-count', value); // console.log({currentCountAfter: $('#grid-view-container').attr('data-current-count')}); // alert(response.products.length); // var lastItem = response.products; // var x = lastItem[lastItem.length - 1]; // if (localStorage.getItem("lastProd") !== null) { // var lastProd = localStorage.getItem("lastProd"); // alert(lastProd); // alert(x.id); // if (lastProd !== x.id) { // localStorage.setItem("lastProd", x.id); // } else { // localStorage.removeItem("lastProd"); // } // } // console.log('*** last item***',x.id); } }, 'json') } function postData(data) { $.post('/request.php', data, function (response) { $('.total').html(''); $('#grid-view-container').html(''); $('#list-view-container').html(''); if (response && !response.error) { $('#grid-view-container').attr('data-count', response.count).attr('data-current-count', 51); $('#grid-view-container').attr('data-get-more', 'yes'); setData(response, data.disableCheckboxes); $('.total').append('

' + response.count + ' Results

'); } else { $('#grid-view-container').html('

Δεν υπάρχουν αποτελέσματα για την αναζήτηση σας!

'); } // if(response.products.length === 51) { //// alert(response.products.length); // var lastItem = response.products; // var x = lastItem[lastItem.length - 1]; // if (localStorage.getItem("lastProd") !== null) { // var lastProd = localStorage.getItem("lastProd"); // if (lastProd !== x.id) { // localStorage.setItem("lastProd", x.id); // } else { // localStorage.removeItem("lastProd"); // } // } else { // localStorage.setItem("lastProd", x.id); // } //// console.log('*** last item***',x.id); // } }, 'json') } function setFilters() { getSelectedFilters(); var url = '/search'; var operator = '?'; // console.log(filters); for (var type in filters.preSelected) { if (type == 'specs') { for (var SpecType in filters.preSelected[type]) { if (filters.preSelected[type][SpecType].length > 0) { url += operator + SpecType + '=' + filters.preSelected[type][SpecType].map(function (v) { return encodeURIComponent(v) }).join('+'); operator = '&'; } } } else if (type == 'price') { for (var SpecPrice in filters.preSelected[type]) { if (typeof filters.preSelected[type][SpecPrice] != 'undefined') { url += operator + SpecPrice + '=' + filters.preSelected[type][SpecPrice].map(function (v) { return encodeURIComponent(v) }).join('+'); } operator = '&'; } } else { url += operator + type + '=' + filters.preSelected[type].map(function (v) { return encodeURIComponent(v) }).join('+'); operator = '&'; } } for (var page in filters.topFilters) { if (page == 'page' || page == 'perPage' || page == 'order') { url += operator + page + '=' + filters.topFilters[page]; } operator = '&'; } window.history.replaceState(null, null, url); } function getSelectedFilters() { filters.preSelected.cat = [window.location.search.substring(1).split("&")[0].split('=')[1]]; filters.preSelected.q = [$('#search-form').find('input[name="getAllProds"]').val()]; filters.topFilters.order = [$('#ordering option:selected').val()]; filters.preSelected.specs = {}; $('.desktop').each(function () { filters.preSelected.specs[$(this).attr('data-parent')] = []; }); $('.preSelected').each(function () { if ($(this).is(':checked')) { var preSel = $(this).closest('.desktop').attr('data-parent'); if (preSel) { filters.preSelected.specs[preSel].push($(this).val()); } } }); $('.radioSelected').each(function () { if ($(this).is(':checked')) { $(this).addClass('rChecked'); var preSel = $(this).closest('.desktop').attr('data-parent'); if (preSel) { filters.preSelected.specs[preSel].push($(this).val()); } } }); } $('.preSelected').click(function () { setFilters(); postData({ getAllProds: '1', filters: filters, disableCheckboxes: false }); }); $('.radioSelected').click(function () { if ($(this).hasClass('rChecked')) { $(this).prop('checked', false) $(this).removeClass('rChecked') } setFilters(); postData({ getAllProds: '1', filters: filters, disableCheckboxes: $(this).prop('checked') }); }); $('#deleteSearchKey').click(function () { filters.preSelected.q = ''; $('#search-form').find('input[name="getAllProds"]').val(''); setFilters(); postData({ getAllProds: '1', filters: filters }); // console.log('delete button', filters); }); function getUrlFilters() { var pairs = window.location.search.substring(1).split("&"), pair, i; for (i in pairs) { pair = pairs[i].split("="); var val = pair[1] && decodeURIComponent(pair[1]).split('+') || []; if (val.length) { urlSelected[decodeURIComponent(pair[0])] = val; } } }