Created
October 26, 2012 23:17
-
-
Save peterchester/3962111 to your computer and use it in GitHub Desktop.
I Ching Random Walk
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> | |
<head> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
<style> | |
.ichingchar { | |
padding: 0; | |
margin: 0; | |
height: 24px; | |
width: 19px; | |
display: block; | |
float: left; | |
font-size: 33px; | |
} | |
</style> | |
</head> | |
<body> | |
<input type="submit" id="start" value="Random Walk with the I Ching" /> | |
<div id="iching"></div> | |
<script> | |
chars = [ | |
'䷀', // ䷀ | |
'䷪', // ䷪ | |
'䷍', // ䷍ | |
'䷈', // ䷈ | |
'䷉', // ䷉ | |
'䷌', // ䷌ | |
'䷫' // ䷫ | |
]; | |
i = 0; | |
function bounceiching() { | |
inc = Math.round(Math.random()*3) - 1; | |
i = Math.abs(( i + inc )) % chars.length; | |
$("#iching").html( '<span class="ichingchar" id="char'+i+'">'+chars[ i ]+'</span>' + $("#iching").html() ); | |
} | |
$(document).ready(function() { | |
interval = false; | |
interval_toggle = false; | |
$("#start").click(function() { | |
if (interval_toggle) { | |
clearInterval(interval); | |
interval_toggle = false; | |
$(this).val("CONTINUE"); | |
} else { | |
interval = setInterval("bounceiching()", 50); | |
interval_toggle = true; | |
$(this).val("STOP"); | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment