No quarters required

Thanks to a little assist from my coworker John Boker, the amazing Asteroids javascript from Erkie is now fully integrated into this here very web site. Alls you have to do is type asteroids on any web page of this roided up web site (just make sure the focus is not set on a text field or the URL field), and blast away.

Here is the javascript that I added to the footer of my pages:

<!-- asteroids -->
 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
 
    <script type="text/javascript">
        function asteroids()
        {
            var s = document.createElement('script');
            s.type = 'text/javascript';
            document.body.appendChild(s);
            s.src = 'http://erkie.github.com/asteroids.min.js';
        }
        var roids = "";
        $(document).keypress(function(e)
        {
            roids += String.fromCharCode(e.which);
            if ("asteroids".indexOf(roids) != 0)
            {
                roids = "";
            }
            else if (roids == "asteroids")
            {
                roids = "";
                asteroids();
            }
        });        
    </script>

Enjoy.

Leave a Reply