// This function is executed after the page load completes on the client $(document).ready(function() { $(".folder").click(function() { changeFolder($(this).data("name"), $(this).data("path")); }); $(".issue").click(function() { showComic($(this).data("relcomic"), $(this).data("comname")); }); }); var lightbox = null; function updateCurrentPage() { var currentPage = lightbox.currentPosition; $.ajax({ url : 'ajax/setpage.php', data : {page: currentPage}, dataType : 'json', success : function(data, stat, jqo) { console.log(data.message); } }); } function changeFolder(name, path) { toastr.success("Opening comic \"" + name + "\"
If this is the first time it may take a while to generate thumbnails."); window.location.replace("index.php?newpath=" + path); } // // This JS function is called when a user clicks on a comic. // "showcomic.php" is called with the comic to view as a parameter. // It returns a JSON object representing the collection of images. // If in debug mode the javascript code is displayed in the browser. // If not in debug mode a lightbox object is created to display the comic. // function showComic(comic, name) { $("#" + comic).addClass("readborder"); toastr.success("Extracting and showing the comic \"" + name + "\"...", "Showing Comic"); $.ajax({ url : 'ajax/showcomic.php', data : {comic: comic}, dataType : 'json', success : function(data, stat, jqo) { // Clear out the debug DIV and start the fancybox. $("#debug").html(""); lightbox = SimpleLightbox.open({ items: data.images, captions: data.captions, startAt: data.startindex, beforeSetContent: updateCurrentPage }); } }); }