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