let url = window.location.href.toString().split(window.location.host)[1].split("?")[0]; let pages = parseInt(document.getElementById("helper").getAttribute("data-pages")); let currentPage = parseInt(findGetParameter("page")); let sort = findGetParameter("sort"); let order = findGetParameter("order"); let group = findGetParameter("groupBy") let sortByInput = document.getElementById("sortBy"); sortByInput.value = sort; let orderInput = document.getElementById("order"); orderInput.value = order; let groupByInput = document.getElementById("groupBy") === null ? document.createElement("input") : document.getElementById("groupBy"); groupByInput.value = group; sortByInput.addEventListener("change", function () { window.location.href = url + "?page=" + currentPage + "&sort=" + sortByInput.value + "&order=" + orderInput.value + "&groupBy=" + groupByInput.value; }) orderInput.addEventListener("change", function() { window.location.href = url + "?page=" + currentPage + "&sort=" + sortByInput.value + "&order=" + orderInput.value + "&groupBy=" + groupByInput.value; }) groupByInput.addEventListener("change", function () { window.location.href = url + "?page=" + 1 + "&sort=" + sortByInput.value + "&order=" + orderInput.value + "&groupBy=" + groupByInput.value; }) document.getElementById('pagination').innerHTML = createPagination(pages, currentPage); function createPagination(pages, page) { let str = ''; return str; } function findGetParameter(parameterName) { let result = null, tmp = []; location.search .substr(1) .split("&") .forEach(function (item) { tmp = item.split("="); if (tmp[0] === parameterName) result = tmp[1]; }); return result; }