From 584bf2b30cced071c368051673181a7549c9d34d Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Sun, 10 Jul 2011 04:30:18 -0400 Subject: [PATCH] Demo cleanup/enhance --- index.html | 32 ++++++++++++++++---------------- js/src/wii.js | 4 ++-- js/wii.js | 3 +-- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index 6ccc8ec..14c10d6 100644 --- a/index.html +++ b/index.html @@ -48,67 +48,67 @@ p4 = $('#player_4'); wiimote.when('pressed_down', function() { - p1.css({'top': parseInt(p1[0].style.top) + 50}); + p1.css({'top': parseInt(p1[0].position().top) + 50}); }); wiimote.when('pressed_right', function() { - p1.css({'left': parseInt(p1[0].style.left) + 50}); + p1.css({'left': parseInt(p1[0].position().left) + 50}); }); wiimote.when('pressed_left', function() { - p1.css({'left': parseInt(p1[0].style.left) - 50}); + p1.css({'left': parseInt(p1[0].position().left) - 50}); }); wiimote.when('pressed_up', function() { - p1.css({'top': parseInt(p1[0].style.top) - 50}); + p1.css({'top': parseInt(p1[0].position().top) - 50}); }); wiimote2.when('pressed_down', function() { - p2.css({'top': parseInt(p2[0].style.top) + 50}); + p2.css({'top': parseInt(p2[0].position().top) + 50}); }); wiimote2.when('pressed_right', function() { - p2.css({'left': parseInt(p2[0].style.left) + 50}); + p2.css({'left': parseInt(p2[0].position().left) + 50}); }); wiimote2.when('pressed_left', function() { - p2.css({'left': parseInt(p2[0].style.left) - 50}); + p2.css({'left': parseInt(p2[0].position().left) - 50}); }); wiimote2.when('pressed_up', function() { - p2.css({'top': parseInt(p2[0].style.top) - 50}); + p2.css({'top': parseInt(p2[0].position().top) - 50}); }); wiimote3.when('pressed_down', function() { - p3.css({'top': parseInt(p3[0].style.top) + 50}); + p3.css({'top': parseInt(p3[0].position().top) + 50}); }); wiimote3.when('pressed_right', function() { - p3.css({'left': parseInt(p3[0].style.left) + 50}); + p3.css({'left': parseInt(p3[0].position().left) + 50}); }); wiimote3.when('pressed_left', function() { - p3.css({'left': parseInt(p3[0].style.left) - 50}); + p3.css({'left': parseInt(p3[0].position().left) - 50}); }); wiimote3.when('pressed_up', function() { - p3.css({'top': parseInt(p3[0].style.top) - 50}); + p3.css({'top': parseInt(p3[0].position().top) - 50}); }); wiimote4.when('pressed_down', function() { - p4.css({'top': parseInt(p4[0].style.top) + 50}); + p4.css({'top': parseInt(p4[0].position().top) + 50}); }); wiimote4.when('pressed_right', function() { - p4.css({'left': parseInt(p4[0].style.left) + 50}); + p4.css({'left': parseInt(p4[0].position().left) + 50}); }); wiimote4.when('pressed_left', function() { - p4.css({'left': parseInt(p4[0].style.left) - 50}); + p4.css({'left': parseInt(p4[0].position().left) - 50}); }); wiimote4.when('pressed_up', function() { - p4.css({'top': parseInt(p4[0].style.top) - 50}); + p4.css({'top': parseInt(p4[0].position().top) - 50}); }); Wii.listen(); diff --git a/js/src/wii.js b/js/src/wii.js index da6c6d8..b30caed 100644 --- a/js/src/wii.js +++ b/js/src/wii.js @@ -132,8 +132,8 @@ Wii.parsePrimaryWiimote = function(e) { * Filter down and figure out which "event" we're really looking at based on code * matchups; this gets messy pretty quickly... */ - if(typeof buttonPressed !== 'undefined' && wii_remote.evtsInterestedIn[buttonPressed] !== 'undefined') { - try { wii_remote.evtsInterestedIn[buttonPressed](wii_remote, wii_remoteCurrStatus); } catch(e) { alert(e.message); alert(Wii.currentBrowsingRemote); } + if(typeof buttonPressed !== 'undefined' && typeof wii_remote.evtsInterestedIn[buttonPressed] === 'function') { + wii_remote.evtsInterestedIn[buttonPressed](wii_remote, wii_remoteCurrStatus); } /* Doing this in conjunction with preventDefault() halts an odd clicking bug or two. */ diff --git a/js/wii.js b/js/wii.js index 8e53ede..647bdfb 100644 --- a/js/wii.js +++ b/js/wii.js @@ -156,8 +156,7 @@ Wii.parsePrimaryWiimote = function(e) { * matchups; this gets messy pretty quickly... */ if(typeof buttonPressed !== 'undefined' && typeof wii_remote.evtsInterestedIn[buttonPressed] === 'function') { - try { wii_remote.evtsInterestedIn[buttonPressed](wii_remote, wii_remoteCurrStatus); - } catch(e) { alert(e.message); } + wii_remote.evtsInterestedIn[buttonPressed](wii_remote, wii_remoteCurrStatus); } /* Doing this in conjunction with preventDefault() halts an odd clicking bug or two. */