What I ended up with was a set of events which is similar to what you can see in any web browser, but with a more consistent flow of events. It does not end in the same way, but it does end in an event which can do multiple things depending on what stage it is in.
That leads to the next bit of code, which is the string of events for the first character event (string first_character). I ended up with 3 of these, two for the string and one for the first character. It’s not quite as clean as I would like, but it works.
There certainly are some more complicated string of events, but I’m not going to go into that any further.
So I suppose that’s the way things should be done, but we can’t do everything at once. It also gives us the opportunity to add a second string of events to the first string (to use as a “fallback” when the first one doesn’t work). The idea is that we can have a number of scripts on our website where one can have a fallback if the first one doesn’t work.
For instance, we could use our regular script where we could have a fallback if the first script dont work, or for instance we could do a second script on a third page that would use the second script as a fallback if the first script doesnt work.
But the first script cant use the second script as well, so we have to make a third script that would both use the second script and the first script. A good way to do this is to make a class that would add the fallback functionality to the second script.
Now the first script would be able to use the second script if the first script didnt work. But the second script would also be able to use the first script if the first script worked. This would be good because it would allow us to use the second script as a fallback if the first script didnt work.