-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
77 lines (54 loc) · 2.12 KB
/
Copy pathscripts.js
File metadata and controls
77 lines (54 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
'use strict';
var numberOfItems = $('#page .list-group').length;
var limitPerPage = 4;
$('#page .list-group:gt(' + (limitPerPage - 1) + ')').hide();
var totalPages = Math.ceil(numberOfItems / limitPerPage);
$(".pagination").append("<li class='current-page active'><a href='javascript:void(0)'>" + 1 + "</a></li>");
for (var i = 2; i <= totalPages; i++) {
$(".pagination").append("<li class='current-page'><a href='javascript:void(0)'>" + i + "</a></li>");
}
$(".pagination").append("<li id='next-page'><a href='javascript:void(0)' aria-label=Next><span aria-hidden=true>»</span></a></li>");
$(".pagination li.current-page").on("click", function() {
if ($(this).hasClass('active')) {
return false;
} else {
var currentPage = $(this).index();
$(".pagination li").removeClass('active');
$(this).addClass('active');
$("#page .list-group").hide();
var grandTotal = limitPerPage * currentPage;
for (var i = grandTotal - limitPerPage; i < grandTotal; i++) {
$("#page .list-group:eq(" + i + ")").show();
}
}
});
$("#next-page").on("click", function() {
var currentPage = $(".pagination li.active").index();
if (currentPage === totalPages) {
return false;
} else {
currentPage++;
$(".pagination li").removeClass('active');
$("#page .list-group").hide();
var grandTotal = limitPerPage * currentPage;
for (var i = grandTotal - limitPerPage; i < grandTotal; i++) {
$("#page .list-group:eq(" + i + ")").show();
}
$(".pagination li.current-page:eq(" + (currentPage - 1) + ")").addClass('active');
}
});
$("#previous-page").on("click", function() {
var currentPage = $(".pagination li.active").index();
if (currentPage === 1) {
return false;
} else {
currentPage--;
$(".pagination li").removeClass('active');
$("#page .list-group").hide();
var grandTotal = limitPerPage * currentPage;
for (var i = grandTotal - limitPerPage; i < grandTotal; i++) {
$("#page .list-group:eq(" + i + ")").show();
}
$(".pagination li.current-page:eq(" + (currentPage - 1) + ")").addClass('active');
}
});