Compare commits
No commits in common. "4e582d96e1183949aadc1264c3a20733c699136a" and "1ef310a2b733f98bdfa2180b62b203307cdca89a" have entirely different histories.
4e582d96e1
...
1ef310a2b7
|
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require '../header.php';
|
|
||||||
|
|
||||||
$orders = [SORTBYNAME => SORTBYDATE, SORTBYDATE => SORTBYREAD, SORTBYREAD => SORTBYNAME];
|
|
||||||
|
|
||||||
$validated = require_login(NOREDIRECT);
|
|
||||||
|
|
||||||
$data = array();
|
|
||||||
$data["error"] = false;
|
|
||||||
$data["message"] = "";
|
|
||||||
$data["validated"] = $validated;
|
|
||||||
|
|
||||||
if ( !$validated ) {
|
|
||||||
$data["error"] = true;
|
|
||||||
$data["message"] = "Clients must validate accounts";
|
|
||||||
header('Content-Type: application/json');
|
|
||||||
echo json_encode($data);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$_SESSION['sortorder'] = $orders[$_SESSION['sortorder']];
|
|
||||||
|
|
||||||
$data["order"] = $_SESSION['sortorder'];
|
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
|
||||||
echo json_encode($data);
|
|
||||||
exit();
|
|
||||||
|
|
||||||
// vim: set ts=4 sw=4 et:
|
|
||||||
|
|
@ -36,9 +36,8 @@ $adultcomics = getAdultComics();
|
||||||
$compath = $_SESSION['compath'];
|
$compath = $_SESSION['compath'];
|
||||||
$fullcompath = COMICSDIR . (($compath == "/") ? "" : $compath) . "/";
|
$fullcompath = COMICSDIR . (($compath == "/") ? "" : $compath) . "/";
|
||||||
|
|
||||||
// Build up a list of comics and issues which have been read in descending order by lastupdate
|
// build up a list of comics and issues which have been
|
||||||
$query = "SELECT comic, issue FROM pagetracker WHERE username=:username";
|
$query = "SELECT comic, issue FROM pagetracker WHERE username=:username";
|
||||||
//$query = "SELECT comic, issue FROM pagetracker WHERE username=:username ORDER BY lastupdate DESC";
|
|
||||||
$fields = array();
|
$fields = array();
|
||||||
$fields[":username"] = $_SESSION['username'];
|
$fields[":username"] = $_SESSION['username'];
|
||||||
$sth = $globaldbh->prepare($query);
|
$sth = $globaldbh->prepare($query);
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require '../header.php';
|
|
||||||
|
|
||||||
$validated = require_login(NOREDIRECT);
|
|
||||||
|
|
||||||
$data = array();
|
|
||||||
$data["error"] = false;
|
|
||||||
$data["message"] = "";
|
|
||||||
$data["validated"] = $validated;
|
|
||||||
|
|
||||||
if ( !$validated ) {
|
|
||||||
$data["error"] = true;
|
|
||||||
$data["message"] = "Clients must validate accounts";
|
|
||||||
header('Content-Type: application/json');
|
|
||||||
echo json_encode($data);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$data["order"] = $_SESSION['sortorder'];
|
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
|
||||||
echo json_encode($data);
|
|
||||||
exit();
|
|
||||||
|
|
||||||
// vim: set ts=4 sw=4 et:
|
|
||||||
|
|
@ -4,7 +4,7 @@ body {
|
||||||
color: #ddddd1;
|
color: #ddddd1;
|
||||||
font-family: 'Comic Sans MS';
|
font-family: 'Comic Sans MS';
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 15pt;
|
font-size: 10pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
a, a:link, a:visited, a:active {
|
a, a:link, a:visited, a:active {
|
||||||
|
|
@ -12,11 +12,6 @@ a, a:link, a:visited, a:active {
|
||||||
color: #22dd22;
|
color: #22dd22;
|
||||||
}
|
}
|
||||||
|
|
||||||
#sortorder {
|
|
||||||
cursor: pointer;
|
|
||||||
color: #22dd22;
|
|
||||||
}
|
|
||||||
|
|
||||||
.link {
|
.link {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: #22dd22;
|
color: #22dd22;
|
||||||
|
|
@ -55,8 +50,8 @@ a, a:link, a:visited, a:active {
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: 330px;
|
width: 220px;
|
||||||
height: 495px;
|
height: 330px;
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
border: 2px solid #ddddd1;
|
border: 2px solid #ddddd1;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
|
|
|
||||||
|
|
@ -100,12 +100,12 @@ function makeThumb($item = "") {
|
||||||
$input->setImageFormat("jpg");
|
$input->setImageFormat("jpg");
|
||||||
$width = $input->getImageWidth();
|
$width = $input->getImageWidth();
|
||||||
$height = $input->getImageHeight();
|
$height = $input->getImageHeight();
|
||||||
$scale = 300 / $width;
|
$scale = 200 / $width;
|
||||||
$newx = 300;
|
$newx = 200;
|
||||||
$newy = intval($height * $scale);
|
$newy = intval($height * $scale);
|
||||||
if ( $newy > 450 ) {
|
if ( $newy > 300 ) {
|
||||||
$newy = 450;
|
$newy = 300;
|
||||||
$scale = $height / 450;
|
$scale = $height / 300;
|
||||||
$newx = intval($width / $scale);
|
$newx = intval($width / $scale);
|
||||||
}
|
}
|
||||||
$thumb = substr($outfile, 0, -4) . ".jpg";
|
$thumb = substr($outfile, 0, -4) . ".jpg";
|
||||||
|
|
|
||||||
15
index.php
15
index.php
|
|
@ -4,10 +4,23 @@ require 'header.php';
|
||||||
|
|
||||||
require_login();
|
require_login();
|
||||||
|
|
||||||
|
if ( isset($_REQUEST['sortorder']) ) {
|
||||||
|
if ( ($_REQUEST['sortorder'] == SORTBYNAME) || ($_REQUEST['sortorder'] == SORTBYDATE) ) {
|
||||||
|
$_SESSION['sortorder'] = $_REQUEST['sortorder'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
require_once 'htmlheader.php';
|
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:<?php
|
||||||
|
if ( $_SESSION['sortorder'] == SORTBYNAME ) {
|
||||||
|
echo "<a href='index.php?sortorder=", SORTBYDATE, "'>Name</a>";
|
||||||
|
} else {
|
||||||
|
echo "<a href='index.php?sortorder=", SORTBYNAME, "'>Date</a>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
<div id="path" class='name link'></div>
|
<div id="path" class='name link'></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="list" class='list'></div>
|
<div id="list" class='list'></div>
|
||||||
|
|
|
||||||
94
js/comics.js
94
js/comics.js
|
|
@ -1,5 +1,3 @@
|
||||||
const NOREFRESH = false;
|
|
||||||
|
|
||||||
var curpath = "/";
|
var curpath = "/";
|
||||||
var parentpath = "/";
|
var parentpath = "/";
|
||||||
var foldername = "";
|
var foldername = "";
|
||||||
|
|
@ -7,77 +5,16 @@ 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(parentpath, parentpath); });
|
||||||
$("#sortorder").on("click", cycleSortOrder);
|
getFolderContents();
|
||||||
getSortOrder();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var lightbox = null;
|
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.
|
|
||||||
*/
|
|
||||||
function redirectToLogin() {
|
function redirectToLogin() {
|
||||||
console.log("Redirecting for login...");
|
console.log("Redirecting for login...");
|
||||||
window.location.replace("index.php");
|
window.location.replace("index.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current sort order and optionally refreshes the folder contents.
|
|
||||||
* @param {boolean} [refresh=true] - Whether to refresh the folder contents after getting the sort order.
|
|
||||||
*/
|
|
||||||
function getSortOrder(refresh = true) {
|
|
||||||
$.ajax({
|
|
||||||
url : 'ajax/getsortorder.php',
|
|
||||||
dataType : 'json',
|
|
||||||
success : function(data, stat, jqo) {
|
|
||||||
if ( !data.validated ) {
|
|
||||||
redirectToLogin();
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$("#sortorder").html(data.order);
|
|
||||||
if ( refresh ) getFolderContents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends an AJAX request to update and display the current sort order.
|
|
||||||
* If the user is not validated, redirects to the login page.
|
|
||||||
* On success, updates the #sortorder element with the new order and refreshes folder contents.
|
|
||||||
*/
|
|
||||||
function cycleSortOrder() {
|
|
||||||
$.ajax({
|
|
||||||
url : 'ajax/cyclesortorder.php',
|
|
||||||
dataType : 'json',
|
|
||||||
success : function(data, stat, jqo) {
|
|
||||||
if ( !data.validated ) {
|
|
||||||
redirectToLogin();
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$("#sortorder").html(data.order);
|
|
||||||
getFolderContents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads and displays the contents of the current comic folder.
|
|
||||||
*
|
|
||||||
* - Clears the current list of displayed items.
|
|
||||||
* - 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() {
|
function getFolderContents() {
|
||||||
$("#list").html("");
|
$("#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});
|
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});
|
||||||
|
|
@ -101,13 +38,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() {
|
function updatePathNavigator() {
|
||||||
var navpath = "";
|
var navpath = "";
|
||||||
if ( curpath == "/" ) {
|
if ( curpath == "/" ) {
|
||||||
|
|
@ -118,15 +48,8 @@ function updatePathNavigator() {
|
||||||
$("#path").html(navpath);
|
$("#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.
|
|
||||||
*
|
|
||||||
* @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(name, path) {
|
||||||
toastr.success("If this is the first time it may take a while to generate thumbnails.", "Opening folder \"" + name + "\"");
|
toastr.success("If this is the first time it may take a while to generate thumbnails.", "Opening comic \"" + name + "\"");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : 'ajax/setpath.php',
|
url : 'ajax/setpath.php',
|
||||||
data : {path: path},
|
data : {path: path},
|
||||||
|
|
@ -136,24 +59,15 @@ function changeFolder(name, path) {
|
||||||
redirectToLogin();
|
redirectToLogin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log(data.message);
|
||||||
curpath = path;
|
curpath = path;
|
||||||
parentpath = data.parentpath;
|
parentpath = data.parentpath;
|
||||||
foldername = data.foldername;
|
foldername = data.foldername;
|
||||||
toastr.remove();
|
|
||||||
getFolderContents();
|
getFolderContents();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the current page number to the server via AJAX to update the user's current page
|
|
||||||
* in the comic being read.
|
|
||||||
* If the server response indicates the user is not validated, redirects to the login page.
|
|
||||||
* Logs the server response message to the console on success.
|
|
||||||
*
|
|
||||||
* @function
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
function updateCurrentPage() {
|
function updateCurrentPage() {
|
||||||
var currentPage = lightbox.currentPosition;
|
var currentPage = lightbox.currentPosition;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
@ -199,5 +113,3 @@ function showComic(comic, name) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: ts=3 sw=3 ai:
|
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,5 @@ define('DEBUG_SHOWCOMICAJAX', false);
|
||||||
//
|
//
|
||||||
// Constants
|
// Constants
|
||||||
//
|
//
|
||||||
define('SORTBYNAME', "Name");
|
define('SORTBYNAME', 10000001);
|
||||||
define('SORTBYDATE', "Date");
|
define('SORTBYDATE', 10000002);
|
||||||
define('SORTBYREAD', "Read");
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user