Compare commits
No commits in common. "5e58c8e28f47f723e34caf9cc6d7e2ed1006a74b" and "a3765e8eeefe8c6ff7fedfef80908542b5def6a4" have entirely different histories.
5e58c8e28f
...
a3765e8eee
|
|
@ -41,7 +41,6 @@ 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";
|
||||
|
|
@ -80,7 +79,7 @@ foreach ( $entries as $entry ) {
|
|||
$readclass = "";
|
||||
}
|
||||
$info["div"] = "<div class='item folder{$readclass}' data-path=\"{$info["newpath"]}\" data-name=\"{$info["comname"]}\">";
|
||||
$info["div"] .= "<img class='thumbnail' src=\"{$info["thumburl"]}\"><br clear=all />{$info["comname"]}</div>";
|
||||
$info["div"] .= "<img src=\"{$info["thumburl"]}\"><br clear=all />{$info["comname"]}</div>";
|
||||
$folders[] = $info;
|
||||
} else {
|
||||
if ( (substr($entry, -3) == "cbz") || (substr($entry, -3) == "cbr") ) {
|
||||
|
|
@ -106,7 +105,7 @@ foreach ( $entries as $entry ) {
|
|||
$readclass = "";
|
||||
}
|
||||
$info["div"] = "<div class='item{$readclass}'>";
|
||||
$info["div"] .= "<img class='issue thumbnail' data-relcomic=\"{$info["relcomic"]}\" data-comname=\"{$info["comname"]}\" border=0 src=\"{$info["thumburl"]}\">";
|
||||
$info["div"] .= "<img class='issue' 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";
|
||||
|
|
|
|||
11
ajax/sess.php
Normal file
11
ajax/sess.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
require '../header.php';
|
||||
|
||||
require_login();
|
||||
|
||||
$data = $_SESSION;
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
exit();
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
<?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,7 +32,6 @@ 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,18 +62,13 @@ a, a:link, a:visited, a:active {
|
|||
|
||||
.item {
|
||||
cursor: pointer;
|
||||
width: 25vw;
|
||||
height: calc(25vw * 1.5 + 2em);
|
||||
width: 330px;
|
||||
height: 495px;
|
||||
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=1.0, minimum-scale=0.25, maximum-scale=3.0, user-scalable=yes" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.38, 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" />
|
||||
|
|
|
|||
53
js/comics.js
53
js/comics.js
|
|
@ -1,22 +1,14 @@
|
|||
let folderRequest = false;
|
||||
let lightbox = null;
|
||||
toastr.options.escapeHtml = true;
|
||||
toastr.options.preventDuplicates = true;
|
||||
const NOREFRESH = false;
|
||||
|
||||
// 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.
|
||||
|
|
@ -38,12 +30,12 @@ function getSortOrder(refresh = true) {
|
|||
if ( !data.validated ) {
|
||||
redirectToLogin();
|
||||
return;
|
||||
} else {
|
||||
$("#sortorder").html(data.order);
|
||||
if ( refresh ) getFolderContents();
|
||||
}
|
||||
$("#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);
|
||||
}
|
||||
|
|
@ -58,18 +50,17 @@ 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();
|
||||
}
|
||||
$("#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);
|
||||
}
|
||||
|
|
@ -83,15 +74,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({
|
||||
|
|
@ -102,16 +93,16 @@ function getFolderContents() {
|
|||
redirectToLogin();
|
||||
return;
|
||||
}
|
||||
$("#list").html(data.contents.map(e => e.div).join(""));
|
||||
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")); });
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -120,12 +111,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) {
|
||||
|
|
@ -137,7 +128,6 @@ 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);
|
||||
}
|
||||
|
|
@ -154,10 +144,9 @@ function changeFolder(path) {
|
|||
* @returns {void}
|
||||
*/
|
||||
function updateCurrentPage() {
|
||||
let currentPage = lightbox.currentPosition;
|
||||
var currentPage = lightbox.currentPosition;
|
||||
$.ajax({
|
||||
url : 'ajax/setpage.php',
|
||||
type : 'POST',
|
||||
data : {page: currentPage},
|
||||
dataType : 'json',
|
||||
success : function(data, stat, jqo) {
|
||||
|
|
@ -168,7 +157,6 @@ 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);
|
||||
}
|
||||
|
|
@ -182,7 +170,6 @@ function updateCurrentPage() {
|
|||
function closeComic() {
|
||||
$.ajax({
|
||||
url : 'ajax/closecomic.php',
|
||||
type : 'POST',
|
||||
dataType : 'json',
|
||||
success : function(data, stat, jqo) {
|
||||
if ( !data.validated ) {
|
||||
|
|
@ -191,7 +178,6 @@ 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);
|
||||
}
|
||||
|
|
@ -216,7 +202,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;
|
||||
}
|
||||
|
|
@ -229,7 +215,6 @@ 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