Konami Code for Floating or Dancing Images in Webpage
In continuation to my last post... here is js file to have Konami Code for Floating or Dancing Images in Webpage.
Konami code triggers the piece of JavaScript pulls off all the images from any web page and rotates or float’s them in a circular order.
Just copy the below code in a js file and give a reference to it in you webpage.
<!-- Konami Code -->
<script src="konamicode.js" type="text/javascript"></script>
js file
function onKonamiCode(fn) {
var codes = (function(){
var c = [38,38,40,40,37,39,37,39,66,65];
onKonamiCode.requireEnterKey && c.push(13);
return c;
})(),
expecting = function(){
expecting.codes = expecting.codes || Array.apply({}, codes);
expecting.reset = function() { expecting.codes = null; };
return expecting.codes;
},
handler = function(e) {
if (expecting()[0] == (e||window.event).keyCode) {
expecting().shift();
if (!expecting().length) {
expecting.reset();
fn();
}
} else { expecting.reset(); }
};
window.addEventListener ?
window.addEventListener('keydown', handler, false)
: document.attachEvent('onkeydown', handler);
}
onKonamiCode.requireEnterKey = false; // True/false
onKonamiCode(function(){
// Do something CRAZY!
//alert('You just Entered Konami Code');
start();
});
function start() {
var r = 0;
var x1 = 0.1;
var y1 = 0.05;
var x2 = 0.25;
var y2 = 0.24;
var x3 = 1.6;
var y3 = 0.24;
var x4 = 300;
var y4 = 200;
var x5 = 300;
var y5 = 200;
var theElem = document.getElementsByTagName("img");
function aaa(){
for(i=0; i<theElem.length; i++){
elemStyle = theElem[i].style;
elemStyle.position = "absolute";
elemStyle.left = Math.sin(r*x1+i*x2+x3)*x4+x5+"px";
elemStyle.top = Math.cos(r*y1+i*y2+y3 )*y4+y5+"px";
}
r++;
}
setInterval(aaa,100);
}
You can experiment more by changing img with a or div tags...
- By Vinod Kotiya
www.vinodkotiya.com
Konami code triggers the piece of JavaScript pulls off all the images from any web page and rotates or float’s them in a circular order.
Just copy the below code in a js file and give a reference to it in you webpage.
<!-- Konami Code -->
<script src="konamicode.js" type="text/javascript"></script>
js file
function onKonamiCode(fn) {
var codes = (function(){
var c = [38,38,40,40,37,39,37,39,66,65];
onKonamiCode.requireEnterKey && c.push(13);
return c;
})(),
expecting = function(){
expecting.codes = expecting.codes || Array.apply({}, codes);
expecting.reset = function() { expecting.codes = null; };
return expecting.codes;
},
handler = function(e) {
if (expecting()[0] == (e||window.event).keyCode) {
expecting().shift();
if (!expecting().length) {
expecting.reset();
fn();
}
} else { expecting.reset(); }
};
window.addEventListener ?
window.addEventListener('keydown', handler, false)
: document.attachEvent('onkeydown', handler);
}
onKonamiCode.requireEnterKey = false; // True/false
onKonamiCode(function(){
// Do something CRAZY!
//alert('You just Entered Konami Code');
start();
});
function start() {
var r = 0;
var x1 = 0.1;
var y1 = 0.05;
var x2 = 0.25;
var y2 = 0.24;
var x3 = 1.6;
var y3 = 0.24;
var x4 = 300;
var y4 = 200;
var x5 = 300;
var y5 = 200;
var theElem = document.getElementsByTagName("img");
function aaa(){
for(i=0; i<theElem.length; i++){
elemStyle = theElem[i].style;
elemStyle.position = "absolute";
elemStyle.left = Math.sin(r*x1+i*x2+x3)*x4+x5+"px";
elemStyle.top = Math.cos(r*y1+i*y2+y3 )*y4+y5+"px";
}
r++;
}
setInterval(aaa,100);
}
You can experiment more by changing img with a or div tags...
- By Vinod Kotiya
www.vinodkotiya.com
Comments