Created
August 21, 2012 23:12
-
-
Save amadeus/3420258 to your computer and use it in GitHub Desktop.
Ghetto Slideshow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Slideshow</title> | |
<style type="text/css"> | |
html, body { margin:0; padding:0; } | |
img { display:block; margin:0 auto; } | |
</style> | |
</head> | |
<body oncontextmenu="return false;"> | |
<!-- Add any number of images --> | |
<img src="lion.jpg" alt="" /> | |
<img src="tubes.jpg" alt="" /> | |
<img src="zx10.jpg" alt="" /> | |
<!-- Make sure this is always AFTER all images --> | |
<script type="text/javascript"> | |
var els = Array.prototype.slice.call(document.getElementsByTagName('img')), | |
i = els.length - 1, | |
clean = function(){ | |
for (var x = 0; x < els.length; x++){ | |
if (els[x].parentNode) | |
els[x] = els[x].parentNode.removeChild(els[x]); | |
} | |
}, | |
cycle = function(e){ | |
if (e && e.preventDefault) e.preventDefault(); | |
if (e && e.ctrlKey){ | |
i -= 2; | |
return cycle(); | |
} | |
i++; | |
if (i >= els.length) i = 0; | |
if (i < 0) i = els.length - 1; | |
clean(); | |
document.body.appendChild(els[i]); | |
}; | |
cycle(); | |
document.body.addEventListener('click', cycle, false); | |
document.body.addEventListener('mousedown', function(e){ if (e && e.preventDefault) e.preventDefault(); }, false); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment