1
|
function checkValidItemsPerPage(){
|
2
|
var visibleItemCount = document.getElementById("itemsPerPage");
|
3
|
if(!isNaN(visibleItemCount.value) && visibleItemCount.value % 1 === 0 && parseInt(visibleItemCount.value) >= 1 && parseInt(visibleItemCount.value) <= 500){
|
4
|
return true;
|
5
|
}else{
|
6
|
alert("Zadaný počet není validní, zkuste to znovu.\nPlatný rozsah: 1 - 500 položek na stránku.");
|
7
|
visibleItemCount.value = itemPerPage;
|
8
|
return false;
|
9
|
}
|
10
|
}
|
11
|
|
12
|
function changeItemsPerPage(){
|
13
|
//if there is no valid input, return and dont save
|
14
|
if(checkValidItemsPerPage() === false){
|
15
|
return;
|
16
|
}
|
17
|
|
18
|
pageIndex = 0;
|
19
|
var visibleItemCount = document.getElementById("itemsPerPage").value;
|
20
|
itemPerPage = visibleItemCount;
|
21
|
fetchData(true);
|
22
|
}
|
23
|
|
24
|
function moveToFirst(){
|
25
|
pageIndex = 0;
|
26
|
fetchData(true);
|
27
|
}
|
28
|
|
29
|
function moveToPrevious(){
|
30
|
pageIndex = (pageIndex - 1 > 0) ? (pageIndex - 1) : (0);
|
31
|
fetchData(true);
|
32
|
}
|
33
|
|
34
|
function moveToNext(){
|
35
|
pageIndex = (pageIndex + 1 < pageCount) ? (pageIndex + 1) : (pageCount - 1);
|
36
|
fetchData(true);
|
37
|
}
|
38
|
|
39
|
function moveToLast(){
|
40
|
pageIndex = pageCount - 1;
|
41
|
fetchData(true);
|
42
|
}
|
43
|
|
44
|
function onManualPageStart(element){
|
45
|
element.value = '';
|
46
|
}
|
47
|
|
48
|
function onManualPageEnd(element) {
|
49
|
const value = Number(element.value) - 1;
|
50
|
if(Number.isInteger(value) && value >= 0 && value < pageCount){
|
51
|
pageIndex = value;
|
52
|
fetchData(true);
|
53
|
} else {
|
54
|
element.value = (pageIndex + 1) + " / " + pageCount;
|
55
|
}
|
56
|
|
57
|
}
|