#dev 2026-08-22

2026-08-22 UTC
MD87, cotsuka, grufwub, ax562, WinnerWind, IWSlackGateway, chenghiz_, k3can8, [KevinMarks]1, [capjamesg], lavandula, Maxpm, lavandula_, kishy, sage_rakurai, thatoddshade, streety, barnaby, rMdes, Pixi, JadedBlueEyes1 and Guest7734 joined the channel
#
rMdes-bnc
Damn b2.. I also remember B2 Evolution, which was a fork if I'm not wrong
lavandula, cotsuka, thatoddshade, lavandula_, [jeremycherfas], ZodiacalComet, barnaby, GuestZero, pimeille and IWDiscord joined the channel
#
ruecharli
does anyone know how i can check if a file exists (in the same directory as the active page) with js? i need it to return a boolean
#
ruecharli
i have the path and file name, but i dont want to navigate to it
#
ruecharli
just check if it exists
#
[snarfed]
js is client side. it can do HTTP, but not server-side filesystem access
cotsuka joined the channel
#
[snarfed]
if the web server is serving that file, you can fetch it with eg the fetch API and check the response status code
#
doesnm
what if trying HEAD request
#
ruecharli
dang it, i assumed it would work :( im trying to check if another html page (on my site) exists before linking to it.. is there some way i can get the same effect? im not sure what fetch api is but i will look into it
#
Loqi
*sniff*
#
ruecharli
otherwise i will just have to have like, a list of all my html files that ill have to keep updated and read from
#
tdrayson
what are you actually trying to achieve? maybe that might help with giving a better answer
#
ruecharli
the whole site takes place in a book. every page has a page number and chapter number in the title. i need to know if the next page is in the same chapter before i try to link to it, otherwise it might move to a page that doesnt exist. i cant give each page its own page number because ill constantly be adding to the end of each chapter
#
ruecharli
so, chapter 1 page 50 might be the last of the chapter, so it would need to move to chapter 2 page 1
#
ruecharli
(each chapter is like a category. one would be for a blog, another for a gallery, etc)
#
tdrayson
Page numbers don't change regardless of what chapter it is though, page numbers are always in order and don't restart
#
tdrayson
Are you using any sort of content management system framework or anything like that? Because if it is an actual category, like a taxonomy, then you could get the total count of the category entries. But again, it kind of depends on how you are actually building this and what you are using.
#
IWDiscord
<t​drayson>
#
ruecharli
yes, i know, in a regular book, but i dont want to have to update every pages number because i added a new page near the start
#
ruecharli
not using anything but html, css, and js. its all just in a folder on my desktop for now
#
tdrayson
But would you not have to do that anyway, if you added a new page into page 2 of 50, then you still have to update the other 48 pages
#
ruecharli
i guess? but i dont intend on doing that
#
tdrayson
But your files are ordered, right, and named ?
#
tdrayson
That's how you're getting the URL structure you mentioned above with the chapter and page number
#
ruecharli
yes, with the convention (chapter).(page).html, e.g. 01.050.html
#
ruecharli
i will generally only be adding to the end of a chapter
#
ruecharli
dots because more convenient for .split
#
tdrayson
You just said you might add a page into the start of a chapter?
#
ruecharli
oh, in my first explanation? i mean that at runtime it needs to check if the next page is in the same chapter or the next, not creating anything
#
tdrayson
Just keep an array of how many pages are in each chapter in the JavaScript
#
ruecharli
ah ok, yeah that wouldnt be too hard to update
#
tdrayson
If you add a new page, just update it
#
[snarfed]
at a higher level, the "write in public" idea sounds like https://books.worksinprogress.co/
#
ruecharli
ok, ill do that!
#
tdrayson
That's going to be the simplest approach without having to do tones of fetch api calls and checks
#
tdrayson
Then all you have to do is compare the current page number with the total pages in the chapter
#
ruecharli
thanks!!
#
tdrayson
no problem 😄
morganwebdev joined the channel
#
ruecharli
do i need to parseInt before comparing number strings? like, would "021" > "002" return true?
#
ruecharli
nvm it works
Pixi, Virtual, sage_rakurai and ludovicchabant_ joined the channel
#
[snarfed]
careful there. JS will say that '2' > '10'
#
[snarfed]
I recommend you parseInt 😁
cotsuka joined the channel
#
ruecharli
haha yeah i realised and fixed it
girlonthemoon joined the channel
#
ruecharli
is there some js i can use that acts like an href hyperlink?
#
ruecharli
i'd like to put it inside a click event listener
cotsuka, pimeille, [Tabitha], ax562, ax5623, barnaby, Saphire and rMdes joined the channel
#
IWDiscord
<t​drayson>
#
tdrayson
window.location.replace()
rMdes, cotsuka, thatoddshade, barnaby, rrix, [artlung], sage_rakurai2, pimeille, ax562, vikanezrimaya, ax5623, WinnerWind, tanok111, bterry and fluffy joined the channel