Skip to content

Instantly share code, notes, and snippets.

@KensakuKOMATSU
Created November 27, 2012 07:32
Show Gist options
  • Save KensakuKOMATSU/4152953 to your computer and use it in GitHub Desktop.
Save KensakuKOMATSU/4152953 to your computer and use it in GitHub Desktop.
ws-remocon の bookmarklet
/**
* A remote controller code for Google presentation.
*
* At the preview mode, when you execute below code as a bookmarklet, you can move
* slides next and previous by your handy smartphone.
* This code works with WebSocket application published in https://github.com/KensakuKOMATSU/ws-remocon.
* So, url for websocket server should be changed, depends on your environment.
*/
(function(){
var ws = new WebSocket('ws://localhost:3000');
ws.onopen = function(){
alert('connected!!');
};
var evt = document.createEvent('MouseEvents');
evt.initEvent('click', false, false);
ws.onmessage = function(e){
console.log(e.data);
switch(e.data) {
case 'Next':
document.querySelector('.punch-viewer-content').dispatchEvent(evt);
break;
case 'Prev':
history.back();
break;
default:
break;
}
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment