Changeset 7888b17 for src/main/resources/static/js/pagination.js
- Timestamp:
- 10/07/21 20:37:55 (3 years ago)
- Branches:
- master
- Children:
- b8a8d06
- Parents:
- ee0e297
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/resources/static/js/pagination.js
ree0e297 r7888b17 5 5 let sort = findGetParameter("sort"); 6 6 let order = findGetParameter("order"); 7 let group = findGetParameter("groupBy") 7 8 8 9 let sortByInput = document.getElementById("sortBy"); … … 12 13 orderInput.value = order; 13 14 15 let groupByInput = document.getElementById("groupBy") === null ? document.createElement("input") : document.getElementById("groupBy"); 16 groupByInput.value = group; 17 14 18 sortByInput.addEventListener("change", function () { 15 window.location.href = url + "?page=" + currentPage + "&sort=" + sortByInput.value + "&order=" + orderInput.value ;19 window.location.href = url + "?page=" + currentPage + "&sort=" + sortByInput.value + "&order=" + orderInput.value + "&groupBy=" + groupByInput.value; 16 20 }) 17 21 18 22 orderInput.addEventListener("change", function() { 19 window.location.href = url + "?page=" + currentPage + "&sort=" + sortByInput.value + "&order=" + orderInput.value; 23 window.location.href = url + "?page=" + currentPage + "&sort=" + sortByInput.value + "&order=" + orderInput.value + "&groupBy=" + groupByInput.value; 24 }) 25 26 groupByInput.addEventListener("change", function () { 27 window.location.href = url + "?page=" + 1 + "&sort=" + sortByInput.value + "&order=" + orderInput.value + "&groupBy=" + groupByInput.value; 20 28 }) 21 29 … … 29 37 30 38 if (page > 1) { 31 str += '<li class="page-item"><a class="page-link" href="'+url+'?page='+(page-1)+'&sort='+sort+'&order='+order+' ">Previous</a></li>';39 str += '<li class="page-item"><a class="page-link" href="'+url+'?page='+(page-1)+'&sort='+sort+'&order='+order+'&groupBy='+group+'">Previous</a></li>'; 32 40 } 33 41 … … 35 43 for (let p = 1; p <= pages; p++) { 36 44 active = page == p ? "active" : ""; 37 str += '<li class="page-item '+active+'"><a class="page-link" href="'+url+'?page='+p+'&sort='+sort+'&order='+order+' ">'+ p +'</a></li>';45 str += '<li class="page-item '+active+'"><a class="page-link" href="'+url+'?page='+p+'&sort='+sort+'&order='+order+'&groupBy='+group+'">'+ p +'</a></li>'; 38 46 } 39 47 } … … 41 49 else { 42 50 if (page > 2) { 43 str += '<li class="page-item"><a class="page-link" href="'+url+'?page=1&sort='+sort+'&order='+order+' ">1</a></li>';51 str += '<li class="page-item"><a class="page-link" href="'+url+'?page=1&sort='+sort+'&order='+order+'&groupBy='+group+'">1</a></li>'; 44 52 if (page > 3) { 45 str += '<li class="page-item"><a class="page-link" href="'+url+'?page='+(page-2)+'&sort='+sort+'&order='+order+' ">...</a></li>';53 str += '<li class="page-item"><a class="page-link" href="'+url+'?page='+(page-2)+'&sort='+sort+'&order='+order+'&groupBy='+group+'">...</a></li>'; 46 54 } 47 55 } … … 67 75 } 68 76 active = page == p ? "active" : ""; 69 str += '<li class="page-item '+active+'"><a class="page-link" href="'+url+'?page='+p+'&sort='+sort+'&order='+order+' ">'+ p +'</a></li>';77 str += '<li class="page-item '+active+'"><a class="page-link" href="'+url+'?page='+p+'&sort='+sort+'&order='+order+'&groupBy='+group+'">'+ p +'</a></li>'; 70 78 } 71 79 72 80 if (page < pages-1) { 73 81 if (page < pages-2) { 74 str += '<li class="page-item"><a class="page-link" href="'+url+'?page='+(page+2)+'&sort='+sort+'&order='+order+' ">...</a></li>';82 str += '<li class="page-item"><a class="page-link" href="'+url+'?page='+(page+2)+'&sort='+sort+'&order='+order+'&groupBy='+group+'">...</a></li>'; 75 83 } 76 str += '<li class="page-item"><a class="page-link" href="'+url+'?page='+pages+'&sort='+sort+'&order='+order+' ">'+pages+'</a></li>';84 str += '<li class="page-item"><a class="page-link" href="'+url+'?page='+pages+'&sort='+sort+'&order='+order+'&groupBy='+group+'">'+pages+'</a></li>'; 77 85 } 78 86 } 79 87 80 88 if (page < pages) { 81 str += '<li class="page-item"><a class="page-link" href="'+url+'?page='+(page+1)+'&sort='+sort+'&order='+order+' ">Next</a></li>';89 str += '<li class="page-item"><a class="page-link" href="'+url+'?page='+(page+1)+'&sort='+sort+'&order='+order+'&groupBy='+group+'">Next</a></li>'; 82 90 } 83 91 str += '</ul>';
Note:
See TracChangeset
for help on using the changeset viewer.