vaporstrike

Dork, Streamer, Nerd

PFP by: Pericote9

Hello! I am a nerd who is working on a TTRPG game! Check out my Pinned posts for more info!

I am legally required to state that I am over 14,000 pokecoins in debt to Professor Willow.


Get a Free Copy of my game's alpha test!
vaporstrike19.itch.io/barrage-ttrpg-pre-alpha
IN THE WAKE OF THE DEATH OF COHOST, PLEASE CLICK THIS TO FIND MY WEBSITE, THE ONLY GUARANTEED PLACE TO FIND ALL PLACES I AM.
vaporstike.online/

I am working on my Neocities site, and I'm looking to add a button to my site that when clicked increments a number, I'd like that number to be universal between all users. Upon research, it seems that Neocities doesn't really allow this. That said, looking in other places it seems there's a way to sort of emulate it.. Outside of that, they do have official API access I may be able to tinker with though.

So, my big question is, for those more experienced with this kind of thing, what would you recommend me doing to make this button thing work? I'm extremely green to Javascript and web design and while I have more experience in other languages like Python, this is really my first time using Javascript in anything outside of practice, so I think the simplest method would be ideal even if it's not necessarily a "best practice". I have gotten the button to work client side (I took it down due to frustration).


You must log in to comment.

in reply to @vaporstrike's post:

as far as i'm aware, the only way you can really make this work is by not using a static website service. or at the very least, using an external server to handle the backend code for your counter, which is pretty much what is suggested in that 2nd article.

what you could do is this:

  • on your frontend, have a script that makes a request to your 2nd server when a button is clicked.
  • on your backend, you can set up an incredibly basic HTTP server that tracks the number of requests it receives, and simply responds with that same number. you may also consider periodically saving this number to disk so it isn't permanently lost whenever the server restarts or shuts down.
  • when the response is received by the frontend script, you can simply update the text on the button (or however you wanna display it).

the other thing is that you may have to worry about ratelimiting by whatever external service you end up using. either that or the possibility of your server getting overrun with tons of requests (this is essentially a DoS). there are plenty of ways to solve it (like having the frontend script only send one request with the total amount of clicks made within that period every 5 seconds or something), but obviously this does add more complexity. just something to think about

the really, truly complicated part of all this is just setting up the networking, which means sorting out the IP addresses and DNS fuckery. but there's plenty of guides for that online, and i'm sure that glitch service has documentation for it.

Thanks for this, it does seem like it's gonna be a bit difficult, so I may have to just wait to do it until I have a but more experience, but at the same time, this may be a good learning method since it seems like a general simple thing minus the networking part. I'm glad I had a correct general assumption of how to do it in my head. It's a bummer you can't have JS just read and update a txt file uploaded to the server. That was what I originally wanted to do. That's what I tend to do with python if I need data stored between instances.

Pinned Tags