Pagination is now functional and loads the requested sites
This commit is contained in:
parent
b644d5ed66
commit
788f9eafcd
|
@ -28,7 +28,12 @@ if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($input->action) && $input->action == "getDomains") {
|
if(isset($input->action) && $input->action == "getDomains") {
|
||||||
|
// Check if the requested page is a number
|
||||||
|
if(!(is_int($input->page) && $input->page > 0)) {
|
||||||
|
echo "Requested page must be a positive number!";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
// Here we get the number of matching records
|
// Here we get the number of matching records
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT COUNT(*) AS anzahl
|
SELECT COUNT(*) AS anzahl
|
||||||
|
@ -75,7 +80,7 @@ if(isset($input->action) && $input->action == "getDomains") {
|
||||||
// Initialize the return value
|
// Initialize the return value
|
||||||
$retval = Array();
|
$retval = Array();
|
||||||
|
|
||||||
$retval['pages']['current'] = 4000;
|
$retval['pages']['current'] = $input->page;
|
||||||
$retval['pages']['total'] = ceil($obj->anzahl / $config['domain_rows']);
|
$retval['pages']['total'] = ceil($obj->anzahl / $config['domain_rows']);
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,10 +118,15 @@ if(isset($input->action) && $input->action == "getDomains") {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now the number of entries gets limited to the domainRows config value
|
* Now the number of entries gets limited to the domainRows config value.
|
||||||
|
* SQL LIMIT is used for that:
|
||||||
|
* LIMIT lower, upper
|
||||||
|
* Note that LIMIT 0,4 returns the first five rows!
|
||||||
*/
|
*/
|
||||||
$sql .= " LIMIT " . $config['domain_rows'];
|
$lower_limit = ($config['domain_rows'] * ($input->page - 1));
|
||||||
|
|
||||||
|
$sql .= " LIMIT " . $lower_limit . ", " . $config['domain_rows'];
|
||||||
|
|
||||||
$stmt = $db->prepare($sql);
|
$stmt = $db->prepare($sql);
|
||||||
|
|
||||||
if(isset($input->name)) {
|
if(isset($input->name)) {
|
||||||
|
|
|
@ -20,7 +20,8 @@ var sort = {
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
requestData();
|
// When the site is loaded, always show the first page
|
||||||
|
requestData(1);
|
||||||
|
|
||||||
$('#table-domains>thead>tr>td span').click(function() {
|
$('#table-domains>thead>tr>td span').click(function() {
|
||||||
var field = $(this).siblings('strong').text().toLowerCase();
|
var field = $(this).siblings('strong').text().toLowerCase();
|
||||||
|
@ -53,7 +54,7 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function requestData() {
|
function requestData(page) {
|
||||||
var restrictions = {
|
var restrictions = {
|
||||||
csrfToken: $('#csrfToken').text(),
|
csrfToken: $('#csrfToken').text(),
|
||||||
};
|
};
|
||||||
|
@ -71,6 +72,7 @@ function requestData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
restrictions.action = "getDomains";
|
restrictions.action = "getDomains";
|
||||||
|
restrictions.page = page;
|
||||||
|
|
||||||
$.post(
|
$.post(
|
||||||
"api/domains.php",
|
"api/domains.php",
|
||||||
|
@ -189,5 +191,5 @@ function deleteDomainWithId(id, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function paginationClicked() {
|
function paginationClicked() {
|
||||||
alert($(this).data("page"));
|
requestData($(this).data("page"));
|
||||||
}
|
}
|
Loading…
Reference in a new issue