Add a closecomic callback to clear out the comfile session variable when a shown comic is closed
This commit is contained in:
parent
b3c86ac931
commit
078ea8d4fa
23
ajax/closecomic.php
Normal file
23
ajax/closecomic.php
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?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();
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION['comfile'] = "";
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode($data);
|
||||||
|
exit();
|
||||||
24
js/comics.js
24
js/comics.js
|
|
@ -190,6 +190,27 @@ function updateCurrentPage() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// This function hits the closecomic endpoint to clear out
|
||||||
|
// the current comic in the session.
|
||||||
|
//
|
||||||
|
function closeComic() {
|
||||||
|
$.ajax({
|
||||||
|
url : 'ajax/closecomic.php',
|
||||||
|
dataType : 'json',
|
||||||
|
success : function(data, stat, jqo) {
|
||||||
|
if ( !data.validated ) {
|
||||||
|
redirectToLogin();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error : function(xhr, stat, err) {
|
||||||
|
console.log(xhr.status);
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// This JS function is called when a user clicks on a comic.
|
// This JS function is called when a user clicks on a comic.
|
||||||
// "showcomic.php" is called with the comic to view as a parameter.
|
// "showcomic.php" is called with the comic to view as a parameter.
|
||||||
|
|
@ -211,7 +232,8 @@ function showComic(comic, name) {
|
||||||
items: data.images,
|
items: data.images,
|
||||||
captions: data.captions,
|
captions: data.captions,
|
||||||
startAt: data.startindex,
|
startAt: data.startindex,
|
||||||
beforeSetContent: updateCurrentPage
|
beforeSetContent: updateCurrentPage,
|
||||||
|
beforeClose: closeComic
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error : function(xhr, stat, err) {
|
error : function(xhr, stat, err) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user