Thread:Don'tHateOnFate/@comment-1173941-20130907005728/@comment-1173941-20130907011317

Ok... well, basically it works like this.

Errr... is there anything I should explain better? XD
 * 1) When you join chat, MediaWiki:Chat-welcome-message is shown to you, to welcome you.
 * 2) However, there's an invisible image there, that loads a script. Basically, it loads the contents of MediaWiki:Chat.js/load.js onto your page.
 * 3) What this does, is it sets a couple functions, and allows you to load up more javascript, as well as allowing users to load it.
 * 4) MediaWiki:Chat.js is one of the scripts the page loads. This is where most of the stuff happens. Everything before was mostly to allow us to add javascript easily.
 * 5) On that page, you'll see 2 things. A List variable, that contains all of the possible scenarios that occur when you log out, called "Messages". And a function at the bottom, called "randomExitEvent". This part here loads one of the messages randomly, by generating a random number, and writing the result.
 * 6) Lastly, is MediaWiki:Chat-user-parted... When you log out, everyone sees this page displayed on their screen. You'll see that it also calls an invisible image, when it happens, that has an onload script. It loads up the function from before, "randomExitEvent", with the image itself as an argument.