Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution for ignoring the empty tags #490

Open
allaze-eroler opened this issue Sep 4, 2023 · 0 comments
Open

solution for ignoring the empty tags #490

allaze-eroler opened this issue Sep 4, 2023 · 0 comments

Comments

@allaze-eroler
Copy link

hello, i managed to add a small snippet code that will help the main.js ignore the class tags who don't have any contents when creating new paragraphs.

you need to add these directly after the CLEAR and RESTART tags like this:

                // CLEAR - removes all existing content.
                // RESTART - clears everything and restarts the story from the beginning
                else if( tag == "CLEAR" || tag == "RESTART" ) {
                    removeAll("p");
                    removeAll("img");

                    // Comment out this line if you want to leave the header visible when clearing
                    setVisible(".header", false);

                    if( tag == "RESTART" ) {
                        restart();
                        return;
                    }
                }
            }


/* ------------ important part of code ------------ */
            // Check if paragraphText is empty
            if (paragraphText.trim().length == 0) {
                continue; // Skip empty paragraphs
            }

this way, each time the script check the details from the story.js, it will simply and ignore and skip all the empty tags

here the results:

this is before the added code:
msedge_FJUxZERSbj

this is after the added code:
msedge_6vPX1kjOwS

as you can see, you will be able to use your own CSS styling without clashing with the other classes. otherwise, it would use the last class used for css styling. i hope it will help you out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant