Created
June 19, 2013 20:16
-
-
Save ToeJamson/5817648 to your computer and use it in GitHub Desktop.
PubNub + jQTouch
This file contains hidden or 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
| // Overlay (div) | |
| var over = $('#over'); | |
| // ==================== | |
| // STEP 1: SUBSCRIBE() | |
| // ==================== | |
| // Listen for updates on 'jqtouch' channel. | |
| $.PUBNUB.subscribe( { channel : 'jqtouch' }, function(message) { | |
| // Get Orientation on Local and Remote Device | |
| var local_orientation = jQT.getOrientation() | |
| , remote_orientation = message.orientation; | |
| // Indicate Not Same Orientation (Show or Hide div#over) | |
| if (local_orientation != remote_orientation) over.show(); | |
| else over.hide(); | |
| // Console Debug | |
| console.log({ | |
| local_orientation : local_orientation, | |
| remote_orientation : remote_orientation, | |
| message : message | |
| }); | |
| } ); // -- end Subscribe() | |
| // ==================== | |
| // STEP 2: PUBLISH() | |
| // ==================== | |
| // Orientation callback event | |
| $('body').bind( 'turn', function( e, data ) { | |
| // Send update to 'jqtouch' channel. | |
| $.PUBNUB.publish({ | |
| channel : 'jqtouch', | |
| message : { orientation : data.orientation } | |
| }); // -- end Publish() | |
| }); // -- end Orientation Event Bind |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment