Closed dany-on-demand closed 10 years ago
Your code should not depend on the order in which messages are received.
Custom JS is not guaranteed to be executed before/after the MOTD is set
The ordering of CSS and MOTD is arbitrary, but I don't think explicitly lining up my packet order to suit specific channels' needs is a sustainable option.
I think the best way to handle this is to add your own listeners to the events CyTube sends. For example:
socket.on("setMotd", function (data) {
// The MOTD has been updated, do something to it.
});
You could easily wrap this in a helper function that checks if the desired state is present, and if it isn't, adds a listener for the event. Let me know if you have questions.
Thanks a lot!I Think I fixed it alright Just a few more notes... I just accidentally lost all of them so here's a lazy summary:
~Even sleepier dany
<br>
. It might be worth running a little script to update existing MOTDs and then remove this behavior, I'll have to think about it.edit: also 1. > it takes data-dismissable makes it datadismissable removes the -
.2. adding a dropdown pill/tab, if you click on it the dropdown menu stays on forever no matter what, I think I might've caused it though by calling the function that enables the dropdown menu twice .5. no idea, I will now use the sleeping pod of magical time teleportation to cure my tired brain
Marking as closed unless there are further issues.
I wanted to add support for different languages in the MOTD, and decided to use bootstrap tabs(pills) to do so, IMO easiest and fastest solution, it's only a few lines of text anyway.
Well apparently this needs some JS back code, so I added it, great it worked, but wait no, not after you reload the page.
So it turns out the custom javascript gets executed before the MOTD is set, not sure if this is intentional( security concerns:question: :warning: ) but doesn't that almost completely ruin the idea why it was added in the first place? Well, so when I set the JS after loading the page it works because it's refreshed after MOTD html is there.
Another thing I wanted to do was to add a warning "Please allow javascript in this channel to support dynamic content" and remove it via JS (obviously). That doesn't work too of course.
I could "hack" it, just execute the JS after a timer, but that's just ugly as hell. I like things proper if possible.
I tried actually hacking it, I thought if I can't get to the HTML this way, maybe I can just set the HTML in the JS code, it's short it'll fit the 20kb limit. But I didn't realize that setMotd will just clear anything there was if the MOTD custom data is empty. Damn. And the JS warning thing wouldn't appear anyway, what a waste :/
Well, any suggestions:question: The channel is at http://cytu.be/r/ex-yu_movie_club
~Sleepy Dany