this post was submitted on 01 Nov 2023
2 points (75.0% liked)

Perchance - Create a Random Text Generator

448 readers
16 users here now

⚄︎ Perchance

This is a Lemmy Community for perchance.org, a platform for sharing and creating random text generators.

Feel free to ask for help, share your generators, and start friendly discussions at your leisure :)

This community is mainly for discussions between those who are building generators. For discussions about using generators, especially the popular AI ones, the community-led Casual Perchance forum is likely a more appropriate venue.

See this post for the Complete Guide to Posting Here on the Community!

Rules

1. Please follow the Lemmy.World instance rules.

2. Be kind and friendly.

  • Please be kind to others on this community (and also in general), and remember that for many people Perchance is their first experience with coding. We have members for whom English is not their first language, so please be take that into account too :)

3. Be thankful to those who try to help you.

  • If you ask a question and someone has made a effort to help you out, please remember to be thankful! Even if they don't manage to help you solve your problem - remember that they're spending time out of their day to try to help a stranger :)

4. Only post about stuff related to perchance.

  • Please only post about perchance related stuff like generators on it, bugs, and the site.

5. Refrain from requesting Prompts for the AI Tools.

  • We would like to ask to refrain from posting here needing help specifically with prompting/achieving certain results with the AI plugins (text-to-image-plugin and ai-text-plugin) e.g. "What is the good prompt for X?", "How to achieve X with Y generator?"
  • See Perchance AI FAQ for FAQ about the AI tools.
  • You can ask for help with prompting at the 'sister' community Casual Perchance, which is for more casual discussions.
  • We will still be helping/answering questions about the plugins as long as it is related to building generators with them.

6. Search through the Community Before Posting.

  • Please Search through the Community Posts here (and on Reddit) before posting to see if what you will post has similar post/already been posted.

founded 1 year ago
MODERATORS
 

JadeRavens made a post on Reddit about the remember-plugin not being able to 'remember' the radio buttons.

So, I made a modification of the remember-plugin that handles the radio button groups. Here is the demo generator for it.

Essentially, it takes the 'group' of the buttons (by using .querySelectorAll to select all inputs that have the same name of the radio button) then saving the state of each radio button.

Which means that in the group, only one is checked and the others are not checked.

Though I am having problems with the saving of the value of a variable since after the second reload of the page, it will point to the last value.

The steps to see the problem (if there is an update() in the oninput of the radio button) is:

  1. Click a radio button.
  2. Reload the page, the variable will point to the last value in the group.

If there is no update() on the oninput, it will take two reloads of the page to point to the last value in the group.

EDIT: Seems to have fixed it by removing the triggerEvent upon loading the state/value of the inputs. Though, I'm sure there is a good reason why the 'triggerEvent' are there.

you are viewing a single comment's thread
view the rest of the comments
[–] VioneT 1 points 1 year ago* (last edited 1 year ago) (1 children)

I think the problem happens when the radio button has a oninput or onchange handlers in which the triggerEvent triggers. See this fork of the problem. If the radio button doesn't have any oninput and onchange it seems to be ok.

It saves the current checked radio button but the value is not the same due to the trigger.

[–] perchance 1 points 1 year ago (1 children)

Ohhh the value itself, rather than the visual display, gotcha. I think it is because (as it turns out...) only the "clicked" radio button in a group of radio buttons has its oninput and onchange fired, even though the state of one of the others (which was the previously selected one) does actually change (from true to false). You can see that in the console here: https://perchance.org/ghl3jlo1cc#edit

So the solution I think is to only run the triggerEvents for the checked radio button. That seems to fix it. Let me know if you notice any problems with that. Thanks for your help with this!

[–] VioneT 1 points 1 year ago (1 children)

That works wonderfully now! Thanks!!

[–] perchance 2 points 1 year ago* (last edited 1 year ago) (1 children)

No problem! Thanks again for your help. Also, weird place to mention this, but as of a couple of days ago perchance now has 5 layers of database backups, and then within 4 of those backups, they're duplicated across at least 2 data-centers. So I perhaps went a bit overboard lol, but I only had 3 layers for several years and it was also bugging me that I only had daily/weekly/monthly backups - i.e. no real-time database replication. So now we have that too. Previously it was possible for people to lose a day of work if something went terribly wrong with the server, since backups happened at most once a day.

And while I'm adding stuff that's irrelevant to this thread: This goes without saying, but don't feel even slightly pressured to keep the /hub up to date, or keep jams running every month, etc. - perchance is a weird website, and will always be a weird website, so we have full creative license to be weird in ways that help work-hobby balance. And that sometimes just means leaving the site for 6 months (or indefinitely) because you've got other stuff going on. Perchance will never go corpo in any sense, never be acquired, never put ads on generators (except if it is absolutely required and fully-opt-in - like with the AI plugins which need GPU servers), and in general never "sell out". In exchange for this, the community needs to be okay with weird stuff like me, you and other prominent perchance community members just abruptly leaving for several months if we want to, for literally whatever reason we want to. Obviously I'll always ensure the servers keep running smoothly and keep improving perchance when I feel like it, but there should be no expectation of weekly shiny new features, silicon valley startup-level UI polish, hyped marketing announcements, or anything like that. To the extent that anyone in the community is somehow expecting that, I'll happily keep disappointing them in exchange for keeping perchance weird and independent, and you should too RE balancing all your amazing hub/plugins/question-answering/jams/etc stuff with other work/life stuff you have going on. This wall of text is another way of saying you've done a lot of work for this community lol. Thank you 🥹🙏

[–] VioneT 2 points 1 year ago

Thank you for the kind words! I just like solving problems and try to increase my knowledge of JS/HTML/CSS through Perchance which is why I try to answer the questions on the forums (reddit, discord, and here), essentially helping myself (to learn new things and answers to the problems) by helping others. I'm also just doing it during my free time and when I don't have any important things to do, so no need to worry about me xD. Lastly, thank you for creating this website and keeping it open ♥.