Display of pagination now works for total page number greater than 8. Note that the actual pagination is not yet implemented
This commit is contained in:
parent
d61caad090
commit
8d18e15d53
|
@ -75,8 +75,8 @@ if(isset($input->action) && $input->action == "getDomains") {
|
|||
// Initialize the return value
|
||||
$retval = Array();
|
||||
|
||||
$retval['pages']['current'] = 1;
|
||||
$retval['pages']['total'] = $obj->anzahl / $config['domain_rows'];
|
||||
$retval['pages']['current'] = 4000;
|
||||
$retval['pages']['total'] = ceil($obj->anzahl / $config['domain_rows']);
|
||||
|
||||
|
||||
// Now the real search is done on the database
|
||||
|
|
25
domains.php
25
domains.php
|
@ -83,26 +83,11 @@ limitations under the License.
|
|||
<tbody class="cursor-pointer">
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="pagination" class="text-center">
|
||||
<ul class="pagination">
|
||||
<li>
|
||||
<a href="#" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
<li><a href="#">1</a></li>
|
||||
<li><a href="#">2</a></li>
|
||||
<li><a href="#">3</a></li>
|
||||
<li><a href="#">4</a></li>
|
||||
<li><a href="#">5</a></li>
|
||||
<li>
|
||||
<a href="#" aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<nav id="pagination-wrapper" class="text-center defaulthidden">
|
||||
<ul id="pagination" class="pagination">
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<?php
|
||||
if($_SESSION['type'] == "admin") {
|
||||
|
|
|
@ -76,15 +76,56 @@ function requestData() {
|
|||
"api/domains.php",
|
||||
JSON.stringify(restrictions),
|
||||
function(data) {
|
||||
recreateTable(data);
|
||||
recreateTable(data.data);
|
||||
recreatePagination(data.pages)
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function recreatePagination(data) {
|
||||
$('#pagination').empty();
|
||||
|
||||
if(data.total === 1) {
|
||||
$('#pagination-wrapper').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if(data.current > 1) {
|
||||
$('<li><a href="#"><span class="glyphicon glyphicon-chevron-left"></span></a></li>').appendTo('#pagination').data("page", data.current - 1).click(paginationClicked);
|
||||
}
|
||||
|
||||
$('<li><span>1</span></li>').appendTo('#pagination').data("page", 1).click(paginationClicked);
|
||||
|
||||
if(data.current > 4) {
|
||||
$('<li class="disabled"><span>…</span></li>').appendTo('#pagination');
|
||||
}
|
||||
|
||||
for(var i = data.current - 2; i <= data.current + 2; i++) {
|
||||
if(i > 1 && i < data.total) {
|
||||
if(data.current === i) {
|
||||
$('<li class="active"><span>' + i + '</span></li>').appendTo('#pagination');
|
||||
} else {
|
||||
$('<li><span>' + i + '</span></li>').appendTo('#pagination').data("page", i).click(paginationClicked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(data.current < data.total - 3) {
|
||||
$('<li class="disabled"><span>…</span></li>').appendTo('#pagination');
|
||||
}
|
||||
|
||||
$('<li><span>' + data.total + '</span></li>').appendTo('#pagination').data("page", data.total).click(paginationClicked);
|
||||
|
||||
if(data.current < data.total) {
|
||||
$('<li><a href="#"><span class="glyphicon glyphicon-chevron-right"></span></a></li>').appendTo('#pagination').data("page", data.current + 1).click(paginationClicked);
|
||||
}
|
||||
|
||||
$('#pagination-wrapper').show();
|
||||
}
|
||||
|
||||
function recreateTable(data) {
|
||||
$('#table-domains>tbody').empty();
|
||||
$('#pagination').empty();
|
||||
|
||||
$.each(data, function(index,item) {
|
||||
$('<tr></tr>').appendTo('#table-domains>tbody')
|
||||
|
@ -146,3 +187,7 @@ function deleteDomainWithId(id, callback) {
|
|||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function paginationClicked() {
|
||||
alert($(this).data("page"));
|
||||
}
|
Loading…
Reference in a new issue