Skip to content
Browse files

Fix no more goedemorgen-issue

  • Loading branch information...
1 parent 1d26ea5 commit cfe5586a128005a2650aa51ddfebd8a90221cc54 @hermanbanken hermanbanken committed Jul 25, 2012
Showing with 53 additions and 54 deletions.
  1. +3 −54 index.html
  2. +50 −0 js/cynthia.js
View
57 index.html
@@ -36,58 +36,7 @@
<script>
$("#keuken").width($("#body").height()*0.66745283);
</script>
-<script src="js/app.js"></script>
-
</body>
-<script>
- document.getElementById("arm").addEventListener('webkitAnimationEnd', function(){
- this.style.webkitAnimationName = '';
- document.body.className = "";
- }, false);
-
- document.body.onkeypress = function(){
- document.getElementById("arm").style.webkitAnimationName = 'shake';
- document.body.className = "smile";
- audio().play();
- };
-
- $("#keuken").width($("#body").height()*0.66745283);
-
- var can = true;
- var sounds = [
- {tag:new Audio("audio/goedemorgen.wav"), before: 12},
- {tag:new Audio("audio/hoihoi.wav")},
- {tag:new Audio("audio/hallo.wav")},
- {tag:new Audio("audio/goedemiddag.wav"), after: 12},
- {tag:new Audio("audio/burp.wav"), custom: function(){ return Math.random()>.9; }}
- ];
- var cd;
-
- function isMorning(){ return (cd = (new Date).getHours()) > 6 && cd < 10; }
- function audio(){
- var pos = [], h = (new Date()).getHours();
- for(n in sounds){
- var add = true;
- if(sounds[n].before && sounds[n].before < h) add = false;
- if(sounds[n].after && sounds[n].after > h) add = false;
- if(sounds[n].custom && !sounds[n].custom()) add = false;
- if(add)
- pos.push(sounds[n].tag);
- }
- var index = Math.round(Math.random()*pos.length-1);
- return pos[index];
- }
-
- function goedemorgen(){
- if(can){
- document.getElementById("arm").style.webkitAnimationName = 'shake';
- document.body.className = "smile";
- audio().play();
- can = false;
- setTimeout(function(){
- can = true;
- }, 1000 * (isMorning() && 7 || 3*60) );
- }
- }
-</script>
-</html>
+<script src="js/app.js"></script>
+<script src="js/cynthia.js"></script>
+</html>
View
50 js/cynthia.js
@@ -0,0 +1,50 @@
+document.getElementById("arm").addEventListener('webkitAnimationEnd', function(){
+ this.style.webkitAnimationName = '';
+ document.body.className = "";
+}, false);
+
+document.body.onkeypress = function(){
+ document.getElementById("arm").style.webkitAnimationName = 'shake';
+ document.body.className = "smile";
+ audio().play();
+};
+
+$("#keuken").width($("#body").height()*0.66745283);
+
+var can = true;
+var sounds = [
+ {tag:new Audio("audio/goedemorgen.wav"), before: 12},
+ {tag:new Audio("audio/hoihoi.wav")},
+ {tag:new Audio("audio/hallo.wav")},
+ {tag:new Audio("audio/goedemiddag.wav"), after: 12},
+ {tag:new Audio("audio/burp.wav"), custom: function(){ return Math.random()>.7; }}
+ ];
+var cd;
+
+function isMorning(){ return (cd = (new Date).getHours()) > 6 && cd < 10; }
+function audio(){
+ var pos = [], h = (new Date()).getHours();
+ for(var n = 0; n < sounds.length; n++){
+ var add = true;
+ if(sounds[n].before && sounds[n].before < h) add = false;
+ if(sounds[n].after && sounds[n].after > h) add = false;
+ if(sounds[n].custom && !sounds[n].custom()) add = false;
+ if(!sounds[n].play) add = false;
+ if(add)
+ pos.push(sounds[n].tag);
+ }
+ var index = Math.round(Math.random()*(pos.length-1));
+ return pos[index];
+}
+
+function goedemorgen(){
+ if(can){
+ document.getElementById("arm").style.webkitAnimationName = 'shake';
+ document.body.className = "smile";
+ audio().play();
+ can = false;
+ setTimeout(function(){
+ can = true;
+ }, 1000 * (isMorning() && 5 || 3*60) );
+ }
+}

0 comments on commit cfe5586

Please sign in to comment.
Something went wrong with that request. Please try again.