< Pete Goodman Web developer >
Labs - Konami Code
Sunday 12th September 2010, 22:08
Using three different JavaScript files I have added the Konami Code to this website:
- Konami-JS to 'harness the power of the Konami Code' through JavaScript
- $.getImageData is a back-end service that allows you to use the getImageData() JavaScript method to get the raw pixel data for images from different domains, without encountering the usual security error
- This tutorial from Ajax Blender shows how to turn colour images into greyscale.
Changing text and background imagery is done by adding (or removing) styles depending on whether the Konami Code is currently active.
Here's my JS file that controls the creation and fading in/out of greyscale images. (It's fairly sloppy and hastily put together…)
This is the initialisation code:
// enable konami code
konami = new Konami();
// once the Konami code has been entered successfully
konami.code = function() {
// condition : konami code already set?
// (assumes 3rd-party JS cookie library present)
if (cookie.get('konami')) {
// remove cookie
cookie.remove('konami', '/');
// remove stylesheet
$('#bw').remove();
// this doesn't work in IE!
if (!$.browser.msie) {
// remove greyscale images
greyscale.hideGreyscaleImages();
}
// konami code not currently set, initialise it
} else {
// add cookie
cookie.set('konami', true, 0, '/');
// add stylesheet
$('')
.attr('id', "bw")
.attr('rel', "stylesheet")
.attr('type', "text/css")
.attr('media', "screen")
.attr('href', "/_includes/css/site/bw.css")
.appendTo('head');
// doesn't work in IE!
if (!$.browser.msie) {
// greyscale all images
greyscale.showGreyscaleImages();
}
}
};
konami.load();
Give it a go! (UP, UP, DOWN, DOWN, LEFT, RIGHT, LEFT, RIGHT, B, A, ENTER)
Image on this domain
Image from flickr
Comments
Be the first person to comment on this lab...
Please feel free to add a comment
* denotes a required field.
Email addresses are for verification only, and will not be published
The RECAPTCHA spam protection enables me to differentiate between genuine human comments and computer-generated spam.