The
Konami cheat code finally made its way into facebook. There were a lot of posts that spoke about the up-up-down-down-left-right-left-right-B-A-Enter code and the
lens flare effect on facebook. I did a little probing and here is how it is implemented and can be reused in your own site.
First, there is the handler that catches the secret key. You can find it in
this file. Just search for
[38,38,40,40,37,39,37,39,66,65,13] which represent the character codes for the secret key combination. The function is called onloadRegister which typically registers a key handler on the window. The function effectively loads
this response that in turn loads the file responsible for the
lens flare javascript file.
The lens flare is initialized using the following code after the required javascript file is loaded.
var lf = new LensFlare("http:\/\/static.ak.fbcdn.net\/images\/lensflare\/*?8:162521");LensFlare.flareClick(lf).flareScroll(lf).flareKeyPress(lf);
This is done after some variable are set in the win.Env object, the use of which is still a mystery to me. To execute this in our page, we need to initialize some objects, defined in
this file. To get lens flare running, this file also has to be included. Here is the consolidated code that you need to use.
Paste this in the browser URL first,
and then, after sometime, to activate the flares, paste this.
You can try the code on this very blog window.
To include this in your page, you have to include the following script in your page.
The interesting part in this is the animation of the images to create the lens flare, another example of fine javascript wizadary !!