Add dirname and basename to AJAX returns. Improve path display for current path navigation.
This commit is contained in:
parent
529a229e20
commit
1d10e37747
|
@ -96,6 +96,9 @@ if ( $_SESSION["sortorder"] == SORTBYNAME ) {
|
|||
usort($issues, "compareNames");
|
||||
|
||||
$data["compath"] = $compath;
|
||||
$pathparts = pathinfo($compath);
|
||||
$data["parentpath"] = $pathparts['dirname'];
|
||||
$data["foldername"] = $pathparts['basename'];
|
||||
$data["contents"] = array_merge($folders, $issues);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
|
|
@ -10,13 +10,18 @@ $data = array();
|
|||
$data["error"] = false;
|
||||
$data["message"] = "";
|
||||
|
||||
$comicfull = realpath(COMICSDIR . urldecode($_REQUEST['path']));
|
||||
if ( ($comicfull === false) || (substr($comicfull, 0, strlen(COMICSDIR)) != COMICSDIR) ) {
|
||||
$newpath = urldecode($_REQUEST['path']);
|
||||
|
||||
$comicfull = realpath(COMICSDIR . $newpath);
|
||||
if ( ($newpath == "/") || ($comicfull === false) || (substr($comicfull, 0, strlen(COMICSDIR)) != COMICSDIR) ) {
|
||||
$_SESSION['compath'] = "/";
|
||||
} else {
|
||||
$_SESSION['compath'] = substr($comicfull, strlen(COMICSDIR));
|
||||
}
|
||||
$data["message"] = "New comic path: {$_SESSION["compath"]}";
|
||||
$pathparts = pathinfo($_SESSION['compath']);
|
||||
$data["parentpath"] = $pathparts["dirname"];
|
||||
$data["foldername"] = $pathparts["basename"];
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
var curpath = "/";
|
||||
var parentpath = "/";
|
||||
var foldername = "";
|
||||
|
||||
// This function is executed after the page load completes on the client
|
||||
$(document).ready(function() {
|
||||
$("#path").click(function() { changeFolder("/", "/"); });
|
||||
$("#path").click(function() { changeFolder(parentpath, parentpath); });
|
||||
getFolderContents();
|
||||
});
|
||||
|
||||
|
@ -31,7 +33,7 @@ function updatePathNavigator() {
|
|||
if ( curpath == "/" ) {
|
||||
navpath = "/";
|
||||
} else {
|
||||
navpath = "/Comics";
|
||||
navpath = "/Comics" + parentpath;
|
||||
}
|
||||
$("#path").html(navpath);
|
||||
}
|
||||
|
@ -46,6 +48,8 @@ function changeFolder(name, path) {
|
|||
success : function(data, stat, jqo) {
|
||||
console.log(data.message);
|
||||
curpath = path;
|
||||
parentpath = data.parentpath;
|
||||
foldername = data.foldername;
|
||||
getFolderContents();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user