109 lines
5.0 KiB
HTML
Executable File
109 lines
5.0 KiB
HTML
Executable File
{% put scripts %}
|
|
|
|
<script>
|
|
getCat('{{query}}', '{{catId}}');
|
|
getCatProducts('{{query}}', '{{limit}}', '{{catId}}', '1');
|
|
$('#pagination').hide();
|
|
// console.log("qqq");
|
|
function getCatProducts(query, limit, catId, page) {
|
|
$(document).ready(function () {
|
|
$.ajax({
|
|
url: `https://nurgul.com.tm/app/api/products?` + query + `{{activeLocale}}&category=` + catId + `&limit=` + limit + `&page=` + page,
|
|
type: 'GET',
|
|
dataType: 'json',
|
|
beforeSend: function () {
|
|
$('#products_{{id}}').html("");
|
|
$('#products_list_{{id}}').html("");
|
|
$('#pagination_numbers').html("");
|
|
$('#detail_screen').hide();
|
|
$('#products_{{id}}').hide();
|
|
$('#loader_{{id}}').show();
|
|
},
|
|
success: function (data, textStatus, xhr) {
|
|
$('#detail_screen').show();
|
|
$('#loader_{{id}}').hide();
|
|
$('#products_{{id}}').show();
|
|
$('#show_title').html(`<span>{{'all'|_}}` + data.meta.total + `, {{'per.page'|_}} ` + data.meta.to + `</span>`);
|
|
|
|
if (data.meta.total > 8) {
|
|
$('#pagination').show();
|
|
}
|
|
// console.log(data.data);
|
|
|
|
var products = data.data;
|
|
for (var product of products) {
|
|
// console.log(product.name);
|
|
$('#products_{{id}}').append(productCard(product));
|
|
$('#products_list_{{id}}').append(productList(product));
|
|
}
|
|
|
|
var pagination = data.meta;
|
|
|
|
|
|
$('#pagination_numbers').append(
|
|
(pagination.current_page != 1 ?
|
|
`<li><a href="javascript:;" onClick="getCatProducts(` + `'{{query}}'` + `,` + `'{{limit}}'` + `,` + `'{{catId}}'` + `,` + pagination.links[1].label + `)"><i class="icon-arrow-left"></i></a></li>`
|
|
:
|
|
`<li><a href="javascript:;"><i class="icon-arrow-left"></i></a></li>`
|
|
)
|
|
);
|
|
// for (var paginate of pagination.links) {
|
|
for (var i = 0; i < pagination.links.length; i++) {
|
|
if (i != 0 && i != pagination.links.length-1) {
|
|
$('#pagination_numbers').append(
|
|
`<li` + (pagination.links[i].active ? ` class="active" ` : ``) + `><a href="javascript:;" onClick="getCatProducts(` + `'{{query}}'` + `,` + `'{{limit}}'` + `,` + `'{{catId}}'` + `,` + pagination.links[i].label + `)">` + pagination.links[i].label + `</a></li>`
|
|
);
|
|
}
|
|
}
|
|
|
|
$('#pagination_numbers').append(
|
|
(pagination.current_page != pagination.last_page ?
|
|
`<li><a href="javascript:;" onClick="getCatProducts(` + `'{{query}}'` + `,` + `'{{limit}}'` + `,` + `'{{catId}}'` + `,` + (pagination.current_page + 1) + `)"><i class="icon-arrow-right"></i></a></li>`
|
|
:
|
|
`<li><a href="javascript:;"><i class="icon-arrow-right"></i></a></li>`
|
|
)
|
|
);
|
|
|
|
// $('#pagination_numbers').append(
|
|
// `<li` + (pagination.current_page == (pagination.from - pagination.per_page) ? ` class="active" ` : ``) + `><a href="javascript:;" onClick="getCatProducts(` + `'{{query}}'` + `,` + `'{{limit}}'` + `,` + `'{{catId}}'` + `, '2')">` + (pagination.from - pagination.per_page) + `</a></li>`
|
|
// // <li><a href="javascript:;" id="pagination_prev"><i class="icon-arrow-right"></i></a></li>
|
|
// );
|
|
|
|
|
|
},
|
|
error: function (xhr, textStatus, errorThrown) {
|
|
console.log('Error in Operation');
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function getCat(query, catId) {
|
|
$(document).ready(function () {
|
|
$.ajax({
|
|
url: `https://nurgul.com.tm/app/api/categories/` + catId + `?` + query,
|
|
type: 'GET',
|
|
dataType: 'json',
|
|
beforeSend: function () {
|
|
$('#products_{{id}}').hide();
|
|
$('#loader_{{id}}').show();
|
|
},
|
|
success: function (data, textStatus, xhr) {
|
|
$('#loader_{{id}}').hide(500);
|
|
$('#products_{{id}}').show(500);
|
|
|
|
$('#category_name').html(data.data.name);
|
|
$('#category_name_main').html(data.data.name);
|
|
|
|
},
|
|
error: function (xhr, textStatus, errorThrown) {
|
|
console.log('Error in Operation');
|
|
}
|
|
});
|
|
});
|
|
}
|
|
</script>
|
|
{% endput %}
|
|
|
|
{%partial 'scripts/setModal' %}
|
|
{%partial 'scripts/prodCard' %} |