Permalink
Browse files

app mouse movement mostly working...

  • Loading branch information...
1 parent a33fef2 commit 6ec58575f1b2760bb50522ad2f8d02305254def8 @pgte committed Dec 4, 2009
@@ -8,17 +8,17 @@ var Cyclops = function(type) {
}
else
{
- //pubsub.subscribe('/listen/start', this, 'startListening');
- pubsub.subscribe('/listen/new', this, 'startListeningFromStorage');
+ pubsub.subscribe('/listen/start', this, 'startListening');
+ //pubsub.subscribe('/listen/new', this, 'startListeningFromStorage');
//pubsub.subscribe('/listen/stop', this, 'stopListening');
}
}
Cyclops.prototype.startListening = function() {
$.get("/activity?id=final", {}, function(ev) {
ev = JSON.parse(ev);
- this['playEvent_'+ev.type](ev.data);
- this.startListening();
+ slave['playEvent_'+ev.type](ev);
+ slave.startListening();
});
}
@@ -35,7 +35,8 @@ Cyclops.prototype.startListeningFromStorage = function() {
}
Cyclops.prototype.startRecording = function() {
- $(document).bind('mousemove', this.storeEvent);
+ $(document).bind('mousemove', this.sendEvent);
+ $(document).bind('click', this.sendEvent);
// TODO: add more events
}
@@ -49,20 +50,51 @@ Cyclops.prototype.storeEvent = function(e) {
}
Cyclops.prototype.sendEvent = function(e) {
- ev = this['getEvent_'+e.type](e);
+
+ ev = master['getEvent_'+e.type](e);
$.post('/publish?id=final', ev.serialize(), function(data, textStatus) {
if (textStatus != "success")
console.info("failed posting! " + stextStatus);
});
}
+
Cyclops.prototype.getEvent_mousemove = function(e) {
event = new CyEvent("mousemove", { x:e.pageX, y:e.pageY });
return event;
}
+Cyclops.prototype.getEvent_click = function(e) {
+ event = new CyEvent("click", { x:e.pageX, y:e.pageY });
+ return event;
+}
+
+
Cyclops.prototype.playEvent_mousemove = function(e) {
- // TODO: move to dispatch event
- $("#mouse").css('top', e.pageY).css('left', e.pageX);
-}
+ // TODO: move to dispatch event
+ $("#mouse").css('top', e.data.y).css('left', e.data.x);
+ var evt = document.createEvent("MouseEvents");
+ evt.initMouseEvent("mousemove", true, true, window,
+ 0, 0, 0, 0, 0, false, false, false, false, 0, null);
+
+ if(el = document.elementFromPoint(e.data.x, e.data.y)) {
+ el.dispatchEvent(evt);
+ }
+}
+
+Cyclops.prototype.playEvent_click = function(e) {
+ // TODO: move to dispatch event
+ var evt = document.createEvent("MouseEvents");
+ evt.initMouseEvent("click", true, true, window,
+ 1, 0, 0, 0, 0, false, false, false, false, 0, null);
+ $('#mouse').hide();
+ if(el = document.elementFromPoint(e.data.x, e.data.y)) {
+ console.info(el);
+ el.dispatchEvent(evt);
+ } else {
+ console.error('No element in '+e.data.x + ', '+e.data.y);
+ }
+ $('#mouse').show();
+
+}
@@ -51,6 +51,7 @@ $(window).load(function() {
});
+
/*
function simulateClick() {
var evt = document.createEvent("MouseEvents");
@@ -38,5 +38,60 @@ $(document).ready(function() {
canvas_ctx.moveTo(x, y);
}
+
+ window.pubsub = new PubSub('/record/start', '/record/stop', '/listen/start', '/listen/stop', '/listen/new', '/listen/stop');
+ CyNotify.subscribe('/record/start');
+ CyNotify.subscribe('/record/stop');
+ CyNotify.subscribe('/listen/start');
+
+
-});
+});
+
+$(window).load(function() {
+
+ $(document).bind('keydown', 'm', function(e) {
+ $.jGrowl('Setting master mode');
+ master = new Cyclops('master');
+ $(document).bind('keydown', 'r', function(e) {
+ pubsub.publish('/record/start', e, 'recording started');
+ });
+
+ $(document).bind('keydown', 't', function(e) {
+ pubsub.publish('/record/stop', e, 'recording stopped');
+ });
+
+ });
+
+ $(document).bind('keydown', 's', function(e) {
+
+ $.jGrowl('Setting slave mode');
+ slave = new Cyclops('save');
+ $(document).bind('keydown', 'k', function(e) {
+ pubsub.publish('/listen/start', e, 'listen started');
+ });
+
+ $(document).bind('keydown', 'l', function(e) {
+ pubsub.publish('/listen/stop', e, 'listen stopped');
+ });
+
+
+ });
+
+
+
+/* $('img').click(function(e) {
+ console.info(e);
+ console.info("click on image");
+ })
+
+ $("#a").click(function() {
+ simulateClick();
+ });
+
+ $(document).click(function() {
+ console.info("click on document");
+ });*/
+
+});
+
@@ -8,4 +8,11 @@ canvas#painthere {
height: 300px;
padding: 0;
border: 1px solid black;
+}
+#overboard {
+ width: 100%;
+ height: 20px;
+}
+#overboard:hover {
+ background-color: red
}
View
@@ -2,7 +2,7 @@
<html>
<head>
<title>Cyclops Demo 2</title>
- <meta name="description" content="" />
+bde <meta name="description" content="" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../assets/stylesheets/master.css" type="text/css" media="screen" charset="utf-8">
<link rel="stylesheet" href="../assets/stylesheets/jquery.jgrowl.css" type="text/css" media="screen" charset="utf-8">
@@ -27,4 +27,4 @@
<script src="../assets/javascripts/jquery.hotkeys.js" type="text/javascript" charset="utf-8"></script>
<script src="../assets/javascripts/jquery.jgrowl.js" type="text/javascript" charset="utf-8"></script>
</body>
-</html>
+</html>
@@ -9,6 +9,8 @@
</head>
<body>
<h1>Cyclops Demo</h1>
+ <h2>Overboard</h2>
+ <div id="overboard"></div>
<h2>Message:</h2>
<div id="message" style="display:none"><h3>Hello World!</h3></div>
<button id="show_message">Show message</button>
View
@@ -45,10 +45,10 @@ http {
set $push_channel_id $arg_id; #/?id=239aff3 or somesuch
push_publisher;
- push_store_messages on; # enable message queueing
+ push_store_messages off; # enable message queueing
push_message_timeout 2h; # expire buffered messages after 2 hours
- push_max_message_buffer_length 10; # store 10 messages
- push_min_message_recipients 1; # minimum recipients before purge
+ push_max_message_buffer_length 100; # store 10 messages
+ push_min_message_recipients 0; # minimum recipients before purge
}
# public long-polling endpoint

0 comments on commit 6ec5857

Please sign in to comment.