Permalink
Browse files

used modernizr for detection

  • Loading branch information...
1 parent 5e790bf commit 44c15e0ad14a9d324bdc31896165d8990da9f10d @daleharvey committed Jul 31, 2010
Showing with 329 additions and 290 deletions.
  1. +3 −16 index.html
  2. +28 −0 modernizr-1.5.min.js
  3. +298 −274 pacman.js
View
@@ -39,27 +39,14 @@
<div id="pacman"></div>
<script src="pacman.js"></script>
+ <script src="modernizr-1.5.min.js"></script>
<script>
var el = document.getElementById("pacman");
- function supports_canvas() {
- return !!document.createElement('canvas').getContext;
- };
-
- function supports_local_storage() {
- return ('localStorage' in window) && window['localStorage'] !== null;
- };
-
- function supports_audio() {
- var myAudio = document.createElement('audio');
- var canPlayOGG = !!(myAudio.canPlayType('audio/ogg').replace(/no/, ''));
- var canPlayMP3 = !!(myAudio.canPlayType('audio/mpeg').replace(/no/, ''));
- return canPlayOgg || canPlayMP3;
- };
-
- if (supports_canvas() && supports_local_storage() && supports_audio()) {
+ if (Modernizr.canvas && Modernizr.localstorage &&
+ Modernizr.audio && (Modernizr.audio.ogg || Modernizr.audio.mp3)) {
window.setTimeout(function () { PACMAN.init(el, "./"); }, 0);
} else {
el.innerHTML = "Sorry, needs a decent browser<br /><small>" +
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 44c15e0

Please sign in to comment.