Compare commits
13 Commits
a3765e8eee
...
5e58c8e28f
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e58c8e28f | |||
| 201a3f3529 | |||
| 158cb4e53a | |||
| 78314ae950 | |||
| 269e25c2e0 | |||
| 596148f4bb | |||
| 7b186c1898 | |||
| 0988f1df2a | |||
| 863a3d4af4 | |||
| 47c9375f10 | |||
| a6057ea3d8 | |||
| 7418063888 | |||
| dcb521cb49 |
|
|
@ -41,6 +41,7 @@ if ( !is_dir($fullcompath) ) {
|
|||
$_SESSION['compath'] = $compath;
|
||||
setcookie("compath", $compath, time()+31536000, "/", "jaj.com", true);
|
||||
}
|
||||
session_write_close();
|
||||
|
||||
// Build up a list of comics and issues which have been read in descending order by lastupdate
|
||||
$query = "SELECT comic, issue FROM pagetracker WHERE username=:username";
|
||||
|
|
@ -79,7 +80,7 @@ foreach ( $entries as $entry ) {
|
|||
$readclass = "";
|
||||
}
|
||||
$info["div"] = "<div class='item folder{$readclass}' data-path=\"{$info["newpath"]}\" data-name=\"{$info["comname"]}\">";
|
||||
$info["div"] .= "<img src=\"{$info["thumburl"]}\"><br clear=all />{$info["comname"]}</div>";
|
||||
$info["div"] .= "<img class='thumbnail' src=\"{$info["thumburl"]}\"><br clear=all />{$info["comname"]}</div>";
|
||||
$folders[] = $info;
|
||||
} else {
|
||||
if ( (substr($entry, -3) == "cbz") || (substr($entry, -3) == "cbr") ) {
|
||||
|
|
@ -105,7 +106,7 @@ foreach ( $entries as $entry ) {
|
|||
$readclass = "";
|
||||
}
|
||||
$info["div"] = "<div class='item{$readclass}'>";
|
||||
$info["div"] .= "<img class='issue' data-relcomic=\"{$info["relcomic"]}\" data-comname=\"{$info["comname"]}\" border=0 src=\"{$info["thumburl"]}\">";
|
||||
$info["div"] .= "<img class='issue thumbnail' data-relcomic=\"{$info["relcomic"]}\" data-comname=\"{$info["comname"]}\" border=0 src=\"{$info["thumburl"]}\">";
|
||||
$info["div"] .= "<br clear=all /><a href=\"downloadcomic.php?comic={$info["relcomic"]}\">{$info["comname"]}</a></div>";
|
||||
$issues[] = $info;
|
||||
$thumbfile = "../" . THUMBSDIR . $data['compath'] . "/" . $info['comname'] . ".jpg";
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
require '../header.php';
|
||||
|
||||
require_login();
|
||||
|
||||
$data = $_SESSION;
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
exit();
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
require '../header.php';
|
||||
session_write_close();
|
||||
$validated = require_login(NOREDIRECT);
|
||||
|
||||
$data = array();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ if ( !$validated ) {
|
|||
|
||||
$newpath = urldecode($_REQUEST['path']);
|
||||
|
||||
$comicfull = realpath(COMICSDIR . $newpath);
|
||||
$comicfull = realpath(COMICSDIR . "/" . $newpath);
|
||||
if ( ($newpath == "/") || ($comicfull === false) || (substr($comicfull, 0, strlen(COMICSDIR)) != COMICSDIR) ) {
|
||||
$_SESSION['compath'] = "/";
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ if ( isset($_REQUEST['comic']) ) {
|
|||
|
||||
$ext = strtolower(substr($comicfull, -3));
|
||||
$_SESSION['comfile'] = basename($comicfull);
|
||||
session_write_close();
|
||||
|
||||
// Get the current page for this comic or 0 (zero) if never opened
|
||||
$query = "SELECT currentpage FROM pagetracker WHERE username=:username AND issue=:issue";
|
||||
|
|
|
|||
|
|
@ -62,13 +62,18 @@ a, a:link, a:visited, a:active {
|
|||
|
||||
.item {
|
||||
cursor: pointer;
|
||||
width: 330px;
|
||||
height: 495px;
|
||||
width: 25vw;
|
||||
height: calc(25vw * 1.5 + 2em);
|
||||
margin: 5px;
|
||||
border: 2px solid var(--foreground-color);
|
||||
padding: 2px;
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
font-size: 2vw;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.readborder {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.38, minimum-scale=0.25, maximum-scale=3.0, user-scalable=yes" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.25, maximum-scale=3.0, user-scalable=yes" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<link rel="icon" sizes="128x128" href="img/comics_128.png" />
|
||||
|
|
|
|||
49
js/comics.js
49
js/comics.js
|
|
@ -1,14 +1,22 @@
|
|||
const NOREFRESH = false;
|
||||
let folderRequest = false;
|
||||
let lightbox = null;
|
||||
toastr.options.escapeHtml = true;
|
||||
toastr.options.preventDuplicates = true;
|
||||
|
||||
// This function is executed after the page load completes on the client
|
||||
$(document).ready(function() {
|
||||
$("#path").click(function() { changeFolder("/"); });
|
||||
$("#sortorder").on("click", cycleSortOrder);
|
||||
$("#list").on("click", ".folder", function() {
|
||||
changeFolder($(this).data("path"));
|
||||
});
|
||||
$("#list").on("click", ".issue", function() {
|
||||
$(this).parent().addClass("readborder");
|
||||
showComic($(this).data("relcomic"), $(this).data("comname"));
|
||||
});
|
||||
getSortOrder();
|
||||
});
|
||||
|
||||
var lightbox = null;
|
||||
|
||||
/**
|
||||
* Redirects the user to the login page by replacing the current location with "index.php".
|
||||
* Logs a message to the console before redirecting.
|
||||
|
|
@ -30,12 +38,12 @@ function getSortOrder(refresh = true) {
|
|||
if ( !data.validated ) {
|
||||
redirectToLogin();
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
$("#sortorder").html(data.order);
|
||||
if ( refresh ) getFolderContents();
|
||||
}
|
||||
},
|
||||
error : function(xhr, stat, err) {
|
||||
toastr.error("There was an error retrieving the current sort order.", "API Error...", {timeOut: 15000});
|
||||
console.log(xhr.status);
|
||||
console.log(err);
|
||||
}
|
||||
|
|
@ -50,17 +58,18 @@ function getSortOrder(refresh = true) {
|
|||
function cycleSortOrder() {
|
||||
$.ajax({
|
||||
url : 'ajax/cyclesortorder.php',
|
||||
type : 'POST',
|
||||
dataType : 'json',
|
||||
success : function(data, stat, jqo) {
|
||||
if ( !data.validated ) {
|
||||
redirectToLogin();
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
$("#sortorder").html(data.order);
|
||||
getFolderContents();
|
||||
}
|
||||
},
|
||||
error : function(xhr, stat, err) {
|
||||
toastr.error("There was an error retrieving the cycling sort order.", "API Error...", {timeOut: 15000});
|
||||
console.log(xhr.status);
|
||||
console.log(err);
|
||||
}
|
||||
|
|
@ -74,15 +83,15 @@ function cycleSortOrder() {
|
|||
* - Shows a loading notification to the user.
|
||||
* - Sends an AJAX request to retrieve folder contents as JSON.
|
||||
* - If the user is not validated, redirects to the login page.
|
||||
* - Updates the current path and path navigator.
|
||||
* - Appends each folder or issue entry to the list.
|
||||
* - Attaches click handlers to folder and issue elements for navigation and reading.
|
||||
* - Removes the loading notification upon completion.
|
||||
*
|
||||
* @function
|
||||
* @returns {void}
|
||||
*/
|
||||
function getFolderContents() {
|
||||
if ( folderRequest ) return;
|
||||
folderRequest = true;
|
||||
$("#list").html("");
|
||||
toastr.info("Loading folder contents. Comics containing a large number of issues, or issues with a large number of pages, that have not been opened recently may take some time to load. Thank you for your patience!", "Loading Contents...", {timeOut: 15000});
|
||||
$.ajax({
|
||||
|
|
@ -93,16 +102,16 @@ function getFolderContents() {
|
|||
redirectToLogin();
|
||||
return;
|
||||
}
|
||||
data.contents.forEach(function(entry, index) {
|
||||
$("#list").append(entry.div);
|
||||
});
|
||||
$(".folder").click(function() { changeFolder($(this).data("path")); });
|
||||
$(".issue").click(function() { $(this).parent().addClass("readborder"); showComic($(this).data("relcomic"), $(this).data("comname")); });
|
||||
$("#list").html(data.contents.map(e => e.div).join(""));
|
||||
toastr.remove();
|
||||
},
|
||||
error : function(xhr, stat, err) {
|
||||
toastr.error("There was an error retrieving the current folder contents.", "API Error...", {timeOut: 15000});
|
||||
console.log(xhr.status);
|
||||
console.log(err);
|
||||
},
|
||||
complete : function(xhr, stat) {
|
||||
folderRequest = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -111,12 +120,12 @@ function getFolderContents() {
|
|||
* 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.
|
||||
*
|
||||
* @param {string} name - The display name of the folder to open.
|
||||
* @param {string} path - The path of the folder to open.
|
||||
*/
|
||||
function changeFolder(path) {
|
||||
$.ajax({
|
||||
url : 'ajax/setpath.php',
|
||||
type : 'POST',
|
||||
data : {path: path},
|
||||
dataType : 'json',
|
||||
success : function(data, stat, jqo) {
|
||||
|
|
@ -128,6 +137,7 @@ function changeFolder(path) {
|
|||
getFolderContents();
|
||||
},
|
||||
error : function(xhr, stat, err) {
|
||||
toastr.error("There was an error setting the current folder.", "API Error...", {timeOut: 15000});
|
||||
console.log(xhr.status);
|
||||
console.log(err);
|
||||
}
|
||||
|
|
@ -144,9 +154,10 @@ function changeFolder(path) {
|
|||
* @returns {void}
|
||||
*/
|
||||
function updateCurrentPage() {
|
||||
var currentPage = lightbox.currentPosition;
|
||||
let currentPage = lightbox.currentPosition;
|
||||
$.ajax({
|
||||
url : 'ajax/setpage.php',
|
||||
type : 'POST',
|
||||
data : {page: currentPage},
|
||||
dataType : 'json',
|
||||
success : function(data, stat, jqo) {
|
||||
|
|
@ -157,6 +168,7 @@ function updateCurrentPage() {
|
|||
console.log(data.message);
|
||||
},
|
||||
error : function(xhr, stat, err) {
|
||||
toastr.error("There was an error setting current page for comic.", "API Error...", {timeOut: 15000});
|
||||
console.log(xhr.status);
|
||||
console.log(err);
|
||||
}
|
||||
|
|
@ -170,6 +182,7 @@ function updateCurrentPage() {
|
|||
function closeComic() {
|
||||
$.ajax({
|
||||
url : 'ajax/closecomic.php',
|
||||
type : 'POST',
|
||||
dataType : 'json',
|
||||
success : function(data, stat, jqo) {
|
||||
if ( !data.validated ) {
|
||||
|
|
@ -178,6 +191,7 @@ function closeComic() {
|
|||
}
|
||||
},
|
||||
error : function(xhr, stat, err) {
|
||||
toastr.error("There was an error closing the current comic.", "API Error...", {timeOut: 15000});
|
||||
console.log(xhr.status);
|
||||
console.log(err);
|
||||
}
|
||||
|
|
@ -202,7 +216,7 @@ function showComic(comic, name) {
|
|||
return;
|
||||
}
|
||||
toastr.remove();
|
||||
if ( data.images.length == 0 ) {
|
||||
if ( data.images.length === 0 ) {
|
||||
toastr.error("There doesn't seem to be any images in this comic. Please contact the admin!", "Comics is empty", {timeOut: 8000});
|
||||
return;
|
||||
}
|
||||
|
|
@ -215,6 +229,7 @@ function showComic(comic, name) {
|
|||
});
|
||||
},
|
||||
error : function(xhr, stat, err) {
|
||||
toastr.error("There was an error showing selected comic contents.", "API Error...", {timeOut: 15000});
|
||||
console.log(xhr.status);
|
||||
console.log(err);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user