Skip to content

Instantly share code, notes, and snippets.

@sukima
Created August 19, 2010 01:18
Show Gist options
  • Save sukima/536722 to your computer and use it in GitHub Desktop.
Save sukima/536722 to your computer and use it in GitHub Desktop.
skiQuery easter egg
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
$(document).ready(function() {
$(document).keydown(function(e) {
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 ){
openDialog("#game");
SKI.run($("#game"));
kkeys = [];
return false;
}
// Prevent an ever growing array
if ( kkeys.length > 10 )
kkeys.shift();
return true;
});
});
// Code modified from: http://www.queness.com/post/77/simple-jquery-modal-window-tutorial
function openDialog(id) {
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set height and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//Set the position to the top of the page
$('#mask').css({'top':0,'left':0});
//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
}
$(document).ready(function () {
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask, .window').hide();
});
//if mask is clicked
$('#mask').click(function () {
$(this).hide();
$('.window').hide();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment