//the header of the site would be handled in this javascript file, so you don't have to copypaste the whole thing onto every page. //at the bottom of your page, but before the js script calls and the closing body tag, put an empty div with a class of "writeHeader" document.querySelector(".writeHeader").innerHTML = `
`; //comic_archive.js was created by geno7 //Writing sections of the archive page involves 2 steps: //first, use the writeArchive function in this .js file. set the parameters (the stuff inside the parenthesis, comma separated) to toggle options. //then, to place that section of the archive on the html page, you'd make a div, and give that div a class name of whatever you've called that section of the archive in the first parameter. //if you put anything in that div, the list of comics will get appended after it. i.e. you can put the title of that specific section as a header in that div. writeArchive( "chrono", //class of the div that you want this section of the archive to appear in. to have it be on your html page, make an empty div with this class. 1, //earliest page to list maxpg, //latest page to list. setting to maxpg will make it automatically update with the latest page -1, //if set to 0, list is displayed "latest first". if set to -1, list is displayed chronologically true, //if set to true, each comic will have its own thumbnail image next to it. if a comic doesn't have its own thumbnail, it'll be set to the default thumbnail. true //if set to true, each comic will have a display number ); writeArchive("lastfirst", 1, maxpg, 0, true,true); writeArchive("chapter1",1,3,-1,false,true) //writeArchive is for listing a RANGE of pages, take advantage of this by using headers to divide them into chapters or by month writeArchive("chapter2", 4, 9, -1, false,false); writeArchive("chapter3", 9, 12, -1, false,false); writeArchive("chapter4", 13, 15, -1, false,false); //below this point is stuff you don't really need to pay attention to if you're not super familiar with JS function writeArchive(divClass, min, max, reverseOrder, useThumbs,useNums) { //create a table to put the archive data let archiveTable = document.createElement("TABLE"); archiveTable.setAttribute("class", "archiveTable"); //set class to archiveTable for css styling let getDiv = document.getElementsByClassName(divClass)[0]; //get div class getDiv.appendChild(archiveTable); //make the table from the currently available comics for (i = min; i <= max; i++) { let row = archiveTable.insertRow(reverseOrder); //if reverseOrder is set to 0 it'll reverse the order, otherwise it'll display it in regular order //insert table cells let cellThumb = useThumbs ? row.insertCell() : 0; //only insert thumbs and number rows if useThumbs and useNums are toggled respectively let cellNum = useNums ? row.insertCell() : 0; let cellTitle = row.insertCell(); let cellDate = row.insertCell(); //default values when you don't have page data set let pgTitle = "Page " + i; let pgDate = ""; let pgNum = ""; //url of thumbnail let pgThumb = thumbFolder + "/" + image + i + "." + thumbExt; //url of default thumbnail let pgThumbDefault = thumbFolder + "/" + thumbDefault + "." + thumbExt; if (pgData.length >= i) { //set values to the values indicated in the pgData object if available if (pgData[i - 1].title) { pgTitle = pgData[i - 1].title; } if (pgData[i - 1].date) { pgDate = pgData[i - 1].date; } if (pgData[i - 1].date) { pgDate = pgData[i - 1].date; } if (pgData[i - 1].pgNum) { pgNum = pgData[i - 1].pgNum; } } //make the whole row a clickable link to the corresponding comic row.setAttribute("class", `archiveRow`); let linkToComic = `${indexPage}?pg=${i + navScrollTo}`; row.addEventListener("click", () => { window.location.href = linkToComic; }); if (useThumbs) { //draw thumbnails if you have thumbnails toggled cellThumb.innerHTML = `${pgTitle}`; cellThumb.setAttribute("class", "archiveCellThumb"); } if (useNums) { //same for numbers cellNum.innerHTML = `${pgNum}`; cellNum.setAttribute("class", "archiveCellNum"); } //draw each row cellTitle.innerHTML = `${pgTitle}`; cellTitle.setAttribute("class", "archiveCellTitle"); cellDate.innerHTML = " " + pgDate + " "; cellDate.setAttribute("class", "archiveCellDate"); console.log(i + `created row - ${pgTitle} - ${linkToComic}`); //left align text if not using thumbnails cellTitle.className += " leftAlignTableText"; } } /comic_show.js was created by geno7, with much needed assistance from Dannarchy //this is the script that actually displays the comics, nav and comic title on the page. //below are what's called some "function calls", each one is responsible for making an element of the page. to get something to actually show up on the page, all you'd need to do is make a div with a class that has the same name as the function call. i.e. writeNav shows comic navigation, to show it on a page youd use
wherever you want it to be. You can even put multiple divs with that same class name and it'll display multiple instances of the navigation. //a couple of the function calls have toggles too. writeNav(true); //show navigation for comic pages. to toggle either images or text for nav, set this to true or false. //debug console.log(pg) writePageTitle(".writePageTitle", true, " - "); //write title of page. true/false writePageClickable(".writePageClickable",true); //show the current page. to toggle whether pages can be clicked to move to the next one, set this to true or false. writeAuthorNotes(".writeAuthorNotes"); keyNav(); //enables navigation through the comic with the arrow keys and WSAD. It doesn't need a div with a class name, it automatically works. delete or comment out (add // at the beginning) here to disable. // below this point is more under-the-hood type stuff that we only encourage messing with if you're more familiar with js, // but it's still commented as extensively as possible anyway just in case //SHOW COMIC PAGE, with clickable link function writePageClickable(div,clickable) { if (!clickable) { document.querySelector(div).innerHTML = `
${writePage()}
`; //display comic page without link } else if (pg < maxpg) { //check whether comic is on the last page document.querySelector(div).innerHTML = `
${writePage()}
`; //display comic page and make it so that clicking it will lead you to the next page } else { document.querySelector(div).innerHTML = `
${writePage()}
`; //display comic page without link } } function writePageTitle(div,toggleNum, char) { if (pgData.length >= pg) { //display title of current page document.querySelector(div).innerHTML = `

${pgData[pg - 1].title}

`; if (toggleNum) { //toggle whether you want to display the page number document.querySelector(div).innerHTML = `

${pgData[pg - 1].pgNum + char + pgData[pg - 1].title}

`; //char denotes a separating character between the number and the title } } } function writeAuthorNotes(div) { //display author notes if (pgData.length >= pg) { return document.querySelector(div).innerHTML = `${pgData[pg-1].authorNotes}` } } //function used to split pages into multiple images if needed, and add alt text function writePage() { let partExtension = ""; //part extension to add to the url if the image is split into multiple parts let altText = ""; //variable for alt text let path = (folder != "" ? folder + "/" : "") + image + pg + partExtension + "." + ext; //path for your comics made out of variables strung together let page = ``; if (pgData.length < pg) { //if the array is blank or not long enough to have an entry for this page //debug console.log("page code to insert - " + page); console.log("alt text to print - " + altText); // page = `` + altText + ``; return page; } else if (pgData.length >= pg) { //if the array is not blank, and if its at least long enough to have an entry for the current page altText = pgData[pg - 1].altText; //set alt text to the text defined in the array if (pgData[pg-1].imageFiles > 1) { //if theres more than one page segment for (let i = 1; i < pgData[pg-1].imageFiles+1; i++) { //for loop to put all the parts of the image on the webpage partExtension = imgPart + i.toString(); path = (folder != "" ? folder + "/" : "") + image + pg + partExtension + "." + ext; //reinit path (there has to be a less dumb way to do this) if (i > 1) {page += `
`} //add line break page += `` + altText + ``; //add page segment } } else { page = `` + altText + ``; } //debug console.log("page code to insert - " + page); console.log("alt text to print - " + altText); // return page; } } //debug console.log("array blank/not long enough? " + (pgData.length < pg)); console.log("array length - " + pgData.length); console.log("current page - " + pg); console.log("number of page segments - " + pgData[pg-1].imageFiles); console.log("alt text - " + `"` + pgData[pg - 1].altText + `"`); console.log("nav text - " + navText); console.log("nav image file extension - " + navExt); function imgOrText(setImg,navTextSet) { //function that writes the indicated nav button as either an image or text if (setImg) { //if its an image return `` + navText[navTextSet] + ``; } else { return navText[navTextSet]; } } function writeNav(imageToggle) { let writeNavDiv = document.querySelectorAll(".writeNav"); writeNavDiv.forEach(function(element) { element.innerHTML = `
${firstButton()} ${divider()} ${prevButton()} ${divider()} ${nextButton()} ${divider()} ${lastButton()}
`;}) function firstButton() { //FIRST BUTTON if (pg > 1) { //wait until page 2 to make button active return `` + imgOrText(imageToggle, 0) + ``; } else { if (!imageToggle) { return imgOrText(imageToggle, 0); } else { return ``; } } } function divider() { //divider if (!imageToggle) { return ` | `; } return ``; } function prevButton() { //PREV BUTTON if (pg > 1) { //wait until page 2 to make button active return `` + imgOrText(imageToggle, 1) + ``; } else { if (!imageToggle) { return imgOrText(imageToggle, 1); } else { return ``; } } } function nextButton() { //NEXT BUTTON if (pg < maxpg) { //only make active if not on the last page return `` + imgOrText(imageToggle, 2) + ``; } else { if (!imageToggle) { return imgOrText(imageToggle, 2); } else { return ``; } } } function lastButton() { //LAST BUTTON if (pg < maxpg) { //only make active if not on last page return `` + imgOrText(imageToggle, 3) + ``; } else { if (!imageToggle) { return imgOrText(imageToggle, 3); } else { return ``; } } } } //KEYBOARD NAVIGATION function keyNav() { document.addEventListener("keydown", (e) => { if ((e.key == 'ArrowRight' || e.key.toLowerCase() == 'd') && pg < maxpg) { //right arrow or D goes to next page window.location.href = "?pg=" + (pg + 1) + navScrollTo; } else if ((e.key == "ArrowLeft" || e.key.toLowerCase() == "a") && pg > 1) { //left arrow or A goes to previous page window.location.href = "?pg=" + (pg - 1) + navScrollTo; } else if (e.key.toLowerCase() == "w") { //W scrolls up window.scrollBy({ top: -30 }); } else if (e.key.toLowerCase() == "s") { //S scrolls down window.scrollBy({ top: 30 }); } });}; //the footer of the site would be handled in this javascript file, so you don't have to copypaste the whole thing onto every page. //at the bottom of your page, but before the js script calls and the closing body tag, put an empty div with a class of "writeFooter" document.querySelector(".writeFooter").innerHTML = ` `;