Compare commits

..

2 Commits

4 changed files with 4 additions and 37 deletions

View File

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

View File

@ -29,8 +29,6 @@ if ( ($newpath == "/") || ($comicfull === false) || (substr($comicfull, 0, strle
} }
$data["message"] = "New comic path: {$_SESSION["compath"]}"; $data["message"] = "New comic path: {$_SESSION["compath"]}";
$pathparts = pathinfo($_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);

View File

@ -8,7 +8,7 @@ require_once 'htmlheader.php';
?> ?>
<div class='header' id='header'> <div class='header' id='header'>
<div class='sorter'>Sort: <span id="sortorder"></span></div> <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>
<div id="list" class='list'></div> <div id="list" class='list'></div>
<?php <?php

View File

@ -1,12 +1,8 @@
const NOREFRESH = false; const NOREFRESH = false;
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(parentpath, parentpath); }); $("#path").click(function() { changeFolder("/"); });
$("#sortorder").on("click", cycleSortOrder); $("#sortorder").on("click", cycleSortOrder);
getSortOrder(); getSortOrder();
}); });
@ -97,12 +93,10 @@ function getFolderContents() {
redirectToLogin(); redirectToLogin();
return; return;
} }
curpath = data.compath;
updatePathNavigator();
data.contents.forEach(function(entry, index) { data.contents.forEach(function(entry, index) {
$("#list").append(entry.div); $("#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")); }); $(".issue").click(function() { $(this).parent().addClass("readborder"); showComic($(this).data("relcomic"), $(this).data("comname")); });
toastr.remove(); 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. * 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. * 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} name - The display name of the folder to open.
* @param {string} path - The path of the folder to open. * @param {string} path - The path of the folder to open.
*/ */
function changeFolder(name, path) { function changeFolder(path) {
$.ajax({ $.ajax({
url : 'ajax/setpath.php', url : 'ajax/setpath.php',
data : {path: path}, data : {path: path},
@ -147,9 +124,6 @@ function changeFolder(name, path) {
redirectToLogin(); redirectToLogin();
return; return;
} }
curpath = path;
parentpath = data.parentpath;
foldername = data.foldername;
toastr.remove(); toastr.remove();
getFolderContents(); getFolderContents();
}, },