Remove deprecated variables and return properties after simplifying the display of the path at the top right of the page

This commit is contained in:
Junior 2026-07-27 17:56:44 -04:00
parent cb0a1fed97
commit dacf7ce6d5
3 changed files with 4 additions and 35 deletions

View File

@ -31,11 +31,6 @@ function compareNames($a, $b) {
return strnatcmp($a["name"], $b["name"]);
}
$data["compath"] = $compath;
$pathparts = pathinfo($compath);
$data["parentpath"] = $pathparts['dirname'];
$data["foldername"] = $pathparts['basename'];
$adultcomics = getAdultComics();
$compath = $_SESSION['compath'];

View File

@ -8,7 +8,7 @@ require_once 'htmlheader.php';
?>
<div class='header' id='header'>
<div class='sorter'>Sort: <span id="sortorder"></span></div>
<div id="path" class='name link'></div>
<div id="path" class='name link'>/Comics/</div>
</div>
<div id="list" class='list'></div>
<?php

View File

@ -1,12 +1,8 @@
const NOREFRESH = false;
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(parentpath, parentpath); });
$("#path").click(function() { changeFolder("/"); });
$("#sortorder").on("click", cycleSortOrder);
getSortOrder();
});
@ -97,12 +93,10 @@ function getFolderContents() {
redirectToLogin();
return;
}
curpath = data.compath;
updatePathNavigator();
data.contents.forEach(function(entry, index) {
$("#list").append(entry.div);
});
$(".folder").click(function() { changeFolder($(this).data("name"), $(this).data("path")); });
$(".folder").click(function() { changeFolder($(this).data("path")); });
$(".issue").click(function() { $(this).parent().addClass("readborder"); showComic($(this).data("relcomic"), $(this).data("comname")); });
toastr.remove();
},
@ -113,23 +107,6 @@ function getFolderContents() {
});
}
/**
* Updates the navigation path displayed in the element with id "path".
* If the current path is the root ("/"), it sets the navigation path to "/".
* Otherwise, it sets the navigation path to "/Comics" followed by the parent path.
*
* Assumes the existence of global variables `curpath` and `parentpath`.
*/
function updatePathNavigator() {
var navpath = "";
if ( curpath == "/" ) {
navpath = "/";
} else {
navpath = "/Comics" + parentpath;
}
$("#path").html(navpath);
}
/**
* Changes the current folder by sending an AJAX request to update the path on the server.
* Displays a notification to the user and updates global variables upon success.
@ -137,7 +114,7 @@ function updatePathNavigator() {
* @param {string} name - The display name of the folder to open.
* @param {string} path - The path of the folder to open.
*/
function changeFolder(name, path) {
function changeFolder(path) {
$.ajax({
url : 'ajax/setpath.php',
data : {path: path},
@ -147,9 +124,6 @@ function changeFolder(name, path) {
redirectToLogin();
return;
}
curpath = path;
parentpath = data.parentpath;
foldername = data.foldername;
toastr.remove();
getFolderContents();
},