Skip to content

Instantly share code, notes, and snippets.

@akkkix
Last active January 2, 2016 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akkkix/f01b435c8eed6d540338 to your computer and use it in GitHub Desktop.
Save akkkix/f01b435c8eed6d540338 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>おうちで初詣</title>
<script type="text/javascript">
var d=0;
var audio=new Audio("nc117961.wav");
window.addEventListener("devicemotion", function(event){
var x = event.accelerationIncludingGravity.x;
if(d+15<x || d-15>x){
audio.play();
d=x;
}
});
function omikuji(){
rand=Math.floor(Math.random()*10)%7;
switch(rand){
case 0:
kuji="大吉";
break;
case 1:
kuji="中吉";
break;
case 2:
kuji="小吉";
break;
case 3:
kuji="吉";
break;
case 4:
kuji="末吉";
break;
case 5:
kuji="凶";
break;
case 6:
kuji="大凶";
break;
}
kuji="<b>"+kuji+"</b>";
document.getElementById("omikuji").innerHTML=kuji;
}
</script>
</head>
<body>
<img src="shrine.png">
<div id="omikuji">
<button onclick="omikuji();">おみくじ</button>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment