const baseUrl = 'https://www.gamadex.com.pl/', uploadPath = 'https://www.gamadex.com.pl/upload/thumbnails/', resourcesPath = 'https://www.gamadex.com.pl/resources/site/'; let main = null, products = null, options = null; function getProducts(){ $.ajax({ method: 'post', url: '', data: {getProductsList: true} }).fail(function(){ $('.product-list').html('
Wystąpił błąd podczas pobierania listy produktów.
'); }).done(function(data){ main = JSON.parse(data); products = main.products; options = { page: 0, filters: {}, autocomplete: null }; if(localStorage.getItem('OptionsPage')) { options.page = parseInt(localStorage.getItem('OptionsPage')); localStorage.removeItem('OptionsPage'); } createProductsList(products, options); }); } function createProductsList(list, options){ let html = '', nav = '', title = '', count = 0, limit = 9, ac = []; for(const x in list){ let display = true; ac.push(list[x]['title']); if(typeof options.filters == 'object'){ for(const y in options.filters){ if(typeof options.filters[y] == 'object'){ switch(options.filters[y].type){ case 'equal': if(options.filters[y].value.indexOf(list[x][y]) == -1) display = false; break; case 'contain': if(list[x][y].toLowerCase().indexOf(options.filters[y].value[0].toLowerCase()) == -1) display = false; break; case 'between': if(Number(options.filters[y].value[0]) !== NaN && list[x][y] < Number(options.filters[y].value[0])) display = false; if(Number(options.filters[y].value[1]) !== NaN && list[x][y] > Number(options.filters[y].value[1])) display = false; break; } } } } //console.log('Options.page = ' + options.page); //console.log('Count = ' + count); //console.log('Limit: ' + limit); //console.log(count >= (options.page * limit) && count < ((options.page + 1) * limit)); //console.log(options.page * limit); //console.log(options.page + 1); //console.log((options.page + 1) * limit); if(display){ if(count >= (options.page * limit) && count < ((options.page + 1) * limit)){ html += `
' :
''
}