Browse files

events mostly working

  • Loading branch information...
1 parent a62c960 commit 1d8ef427e09e52d034dad05180f9b72f59652ed1 @pgte committed Dec 5, 2009
View
113 assets/javascripts/cymain.js
@@ -74,9 +74,13 @@ Cyclops.prototype.startListeningFromStorage = function() {
}
Cyclops.prototype.startRecording = function() {
- $(document).bind('mousemove', this.sendEvent);
+
+ $(document).bind('mousemove', this.sendEvent);
$(document).bind('click', this.sendEvent);
$(document).bind('mouseover', this.sendEvent);
+ $(window).bind('resize', this.sendEvent);
+ $(window).bind('scroll', this.sendEvent);
+
/*
$(document).bind('mouseout', this.sendEvent);
$(document).bind('mouseenter', this.sendEvent);
@@ -99,58 +103,62 @@ Cyclops.prototype.storeEvent = function(e) {
Cyclops.prototype.sendEvent = function(e) {
- ev = master['getEvent_'+e.type](e);
+ var ev = master['getEvent_'+e.type](e);
//console.info(ev.when+': sending '+e.type);
-
- $.post('/publish?id='+$.cookie('cyclops_queue_id'), ev.serialize(), function(data, textStatus) {
- });
+
+ $.post('/publish?id='+$.cookie('cyclops_queue_id'), ev.serialize(), function(data, textStatus) {});
+
+ if(e.type == 'click') {
+ var href = $(e.target).attr('href');
+ if(href) {
+ $(e.target).attr('href', href+'?cyclops_master=true');
+ }
+ //console.info(e.nodeName);
+ };
}
Cyclops.prototype.getEvent_mousemove = function(e) {
- event = new CyEvent("mousemove", { x:e.pageX, y:e.pageY });
- return event;
+ return new CyEvent("mousemove", { x:e.pageX, y:e.pageY });
}
Cyclops.prototype.getEvent_mouseover = function(e) {
//console.info('getting mouseover:'+e.type);
- if(e.type == 'mouseover') {
- event = new CyEvent("mouseover", { x:e.pageX, y:e.pageY });
- return event;
- }
+ return new CyEvent("mouseover", { x:e.pageX, y:e.pageY });
}
Cyclops.prototype.getEvent_mouseout = function(e) {
//console.info('getting mouseout:'+e.type);
- if(e.type == 'mouseout') {
- event = new CyEvent("mouseout", { x:e.pageX, y:e.pageY });
- return event;
- }
+ return new CyEvent("mouseout", { x:e.pageX, y:e.pageY });
}
Cyclops.prototype.getEvent_mouseenter = function(e) {
- event = new CyEvent("mouseenter", { x:e.pageX, y:e.pageY });
- return event;
+ return new CyEvent("mouseenter", { x:e.pageX, y:e.pageY });
}
Cyclops.prototype.getEvent_mouseleave = function(e) {
- event = new CyEvent("mouseleave", { x:e.pageX, y:e.pageY });
- return event;
+ return new CyEvent("mouseleave", { x:e.pageX, y:e.pageY });
}
Cyclops.prototype.getEvent_mouseup = function(e) {
- event = new CyEvent("mouseup", { x:e.pageX, y:e.pageY, clicks:e.detail });
- return event;
+ return new CyEvent("mouseup", { x:e.pageX, y:e.pageY, clicks:e.detail });
}
Cyclops.prototype.getEvent_mousedown = function(e) {
- event = new CyEvent("mousedown", { x:e.pageX, y:e.pageY, clicks:e.detail });
- return event;
+ return new CyEvent("mousedown", { x:e.pageX, y:e.pageY, clicks:e.detail });
}
Cyclops.prototype.getEvent_click = function(e) {
- event = new CyEvent("click", { x:e.pageX, y:e.pageY });
- return event;
+ return new CyEvent("click", { x:e.pageX, y:e.pageY });
+}
+
+Cyclops.prototype.getEvent_resize = function(e) {
+// console.info('resize');
+ return new CyEvent("resize", { height:$(window).height(), width:$(window).width() });
+}
+
+Cyclops.prototype.getEvent_scroll = function(e) {
+ return new CyEvent("scroll", { left:document.body.scrollLeft+ document.documentElement.scrollLeft, top: document.body.scrollTop + document.documentElement.scrollTop });
}
@@ -177,9 +185,10 @@ Cyclops.prototype.__create_event = function(type, pageX, pageY) {
Cyclops.prototype.playEvent_mousemove = function(e) {
// TODO: move to dispatch event
$("#mouse").css('top', e.data.y).css('left', e.data.x);
+ var el;
if(el = slave.__find_object_in_location(e.data.x, e.data.y)) {
//el.dispatchEvent(evt);
- jsEvent = this.__create_event('mousemove', e.data.x, e.data.y);
+ var jsEvent = this.__create_event('mousemove', e.data.x, e.data.y);
$(el).trigger(jsEvent);
}
}
@@ -188,19 +197,19 @@ Cyclops.prototype.playEvent_mouseover = function(e) {
// TODO: move to dispatch event
$("#mouse").css('top', e.data.y).css('left', e.data.x);
var evt = document.createEvent("MouseEvents");
- el = slave.__find_object_in_location(e.data.x, e.data.y)
+ var el = slave.__find_object_in_location(e.data.x, e.data.y)
if(el) {
- jsEvent = this.__create_event('mouseover', e.data.x, e.data.y);
+ var jsEvent = this.__create_event('mouseover', e.data.x, e.data.y);
$(el).trigger(jsEvent);
}
}
Cyclops.prototype.playEvent_mouseout = function(e) {
// TODO: move to dispatch event
$("#mouse").css('top', e.data.y).css('left', e.data.x);
-
+ var el;
if(el = slave.__find_object_in_location(e.data.x, e.data.y)) {
- jsEvent = this.__create_event('mouseout', e.data.x, e.data.y);
+ var jsEvent = this.__create_event('mouseout', e.data.x, e.data.y);
$(el).trigger(jsEvent);
}
}
@@ -209,44 +218,68 @@ Cyclops.prototype.playEvent_mouseout = function(e) {
Cyclops.prototype.playEvent_mouseenter = function(e) {
// TODO: move to dispatch event
$("#mouse").css('top', e.data.y).css('left', e.data.x);
-
+ var el;
if(el = slave.__find_object_in_location(e.data.x, e.data.y)) {
- jsEvent = this.__create_event('mouseenter', e.data.x, e.data.y);
+ var jsEvent = this.__create_event('mouseenter', e.data.x, e.data.y);
$(el).trigger(jsEvent);
}
}
Cyclops.prototype.playEvent_mouseleave = function(e) {
// TODO: move to dispatch event
$("#mouse").css('top', e.data.y).css('left', e.data.x);
-
+ var el;
if(el = slave.__find_object_in_location(e.data.x, e.data.y)) {
- jsEvent = this.__create_event('mouseleave', e.data.x, e.data.y);
+ var jsEvent = this.__create_event('mouseleave', e.data.x, e.data.y);
$(el).trigger(jsEvent);
}
}
Cyclops.prototype.playEvent_mouseup = function(e) {
// TODO: move to dispatch event
+ var el;
if(el = slave.__find_object_in_location(e.data.x, e.data.y)) {
- jsEvent = this.__create_event('mouseup', e.data.x, e.data.y);
+ var jsEvent = this.__create_event('mouseup', e.data.x, e.data.y);
$(el).trigger(jsEvent);
}
}
Cyclops.prototype.playEvent_mousedown = function(e) {
// TODO: move to dispatch event
+ var el;
if(el = slave.__find_object_in_location(e.data.x, e.data.y)) {
- jsEvent = this.__create_event('mousedown', e.data.x, e.data.y);
+ var jsEvent = this.__create_event('mousedown', e.data.x, e.data.y);
$(el).trigger(jsEvent);
}
}
Cyclops.prototype.playEvent_click = function(e) {
// TODO: move to dispatch event
- if(el = slave.__find_object_in_location(e.data.x, e.data.y)) {
- jsEvent = this.__create_event('click', e.data.x, e.data.y);
- $(el).trigger(jsEvent);
- }
+ //console.info('CLICK!');
+ var el, href;
+ if(el = slave.__find_object_in_location(e.data.x, e.data.y)) {
+ //console.info(el);
+ if(href = $(el).attr('href')) {
+ document.location = href+'?cyclops_slave=true';
+ } else {
+ $(el).click();
+ }
+ } else {
+ //console.info('object not found for click');
+ }
+
+}
+
+Cyclops.prototype.playEvent_resize = function(e) {
+ window.resizeTo(e.data.width, e.data.height+170);
+}
+Cyclops.prototype.playEvent_scroll = function(e) {
+ //console.info('scrolling to '+e.data.left+','+e.data.top);
+ window.scrollTo(e.data.left, e.data.top);
}
+
+$(window).load(function() {
+
+});
+
View
21 assets/javascripts/final.js
@@ -53,7 +53,7 @@ $(document).ready(function() {
$(window).load(function() {
- $(document).bind('keydown', 'm', function(e) {
+ function set_master_mode() {
$.jGrowl('Setting master mode');
master = new Cyclops('master');
$(document).bind('keydown', 'r', function(e) {
@@ -63,11 +63,19 @@ $(window).load(function() {
$(document).bind('keydown', 't', function(e) {
pubsub.publish('/record/stop', e, 'recording stopped');
});
+ }
+ $(document).bind('keydown', 'm', function(e) {
+ set_master_mode();
});
- $(document).bind('keydown', 's', function(e) {
+ if(jQuery.url.param('cyclops_master') == 'true') {
+ set_master_mode();
+ master.startRecording();
+
+ }
+ function set_slave_mode() {
$.jGrowl('Setting slave mode');
slave = new Cyclops('save');
$(document).bind('keydown', 'k', function(e) {
@@ -77,8 +85,15 @@ $(window).load(function() {
$(document).bind('keydown', 'l', function(e) {
pubsub.publish('/listen/stop', e, 'listen stopped');
});
-
+ }
+ if(jQuery.url.param('cyclops_slave') == 'true') {
+ set_slave_mode();
+ slave.startListening();
+ }
+
+ $(document).bind('keydown', 's', function(e) {
+ set_slave_mode();
});
/* $('img').click(function(e) {
View
8 demo_final/application.html
@@ -8,15 +8,17 @@
<link rel="stylesheet" href="../assets/stylesheets/jquery.jgrowl.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
- <h1>Cyclops Demo</h1>
- <h2>Overboard</h2>
- <div id="overboard"></div>
+ <h1>Cyclops Demo 1</h1>
+ <p>
+ <a href="application2.html">Página 2 »</a>
+ </p>
<h2>Message:</h2>
<div id="message" style="display:none"><h3>Hello World!</h3></div>
<button id="show_message">Show message</button>
<button id="hide_message">Hide message</button>
<h2>Paint here:</h2>
<canvas width="300" height="300" id="painthere"></canvas>
+
<footer>
</footer>
<img src="../assets/images/cursor.png" id="mouse" style="position:absolute" />
View
38 demo_final/application2.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Cyclops Demo Final2</title>
+ <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">
+</head>
+<body>
+ <h1>Cyclops Demo 2</h1>
+ <p>
+ <a href="application.html">« Página 1</a>
+ </p>
+ <h2>Message:</h2>
+ <div id="message" style="display:none"><h3>Hello World!</h3></div>
+ <button id="show_message">Show message</button>
+ <button id="hide_message">Hide message</button>
+ <h2>Paint here:</h2>
+ <canvas width="300" height="300" id="painthere"></canvas>
+
+ <footer>
+ </footer>
+ <img src="../assets/images/cursor.png" id="mouse" style="position:absolute" />
+ <script src="../assets/javascripts/jquery.js" type="text/javascript" charset="utf-8"></script>
+ <script src="../assets/javascripts/final.js" type="text/javascript" charset="utf-8"></script>
+ <script src="../assets/javascripts/json2.js" type="text/javascript" charset="utf-8"></script>
+ <script src="../assets/javascripts/pubsub.js" type="text/javascript" charset="utf-8"></script>
+ <script src="../assets/javascripts/event.js" type="text/javascript" charset="utf-8"></script>
+ <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>
+ <script src="../assets/javascripts/jquery.url.js" type="text/javascript" charset="utf-8"></script>
+ <script src="../assets/javascripts/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
+ <script src="../assets/javascripts/cymain.js" type="text/javascript" charset="utf-8"></script>
+ <script src="../assets/javascripts/cynotify.js" type="text/javascript" charset="utf-8"></script>
+
+</body>
+</html>
View
6 demo_final/start.html
@@ -16,6 +16,12 @@
var queue_id = jQuery.url.param("queue_id");
$.cookie('cyclops_queue_id', queue_id);
var redirect_to = jQuery.url.param("redirect_to");
+ var cyclops_slave = jQuery.url.param("cyclops_slave");
+ if(cyclops_slave == 'true')
+ redirect_to += '?cyclops_slave=true';
+ var cyclops_master = jQuery.url.param("cyclops_master");
+ if(cyclops_master == 'true')
+ redirect_to += '?cyclops_master=true';
//alert(unescape(redirect_to));
document.location = redirect_to;
</script>
View
13 demo_final/start_master.html
@@ -14,15 +14,17 @@
<input type="text" id="url" value="http://localhost:8000/demo_final/application.html"/>
</p>
<p>
- <input type="submit" id="go" value="generate URL" />
+ <input type="submit" id="go" value="generate URLs" />
</p>
<p>
- <input type="text" id="generated_url" />
+ <label for="slave_url">
+ <input style="width:600px" type="text" id="slave_url" />
</p>
</form>
+ <h4>Master link:</h4>
<p id="link_container"></p>
<script src="../assets/javascripts/jquery.js" type="text/javascript" charset="utf-8"></script>
@@ -45,9 +47,10 @@
$('form').submit(function() {
var url = $('#url').val();
var queueId = randomString(10);
- var final_url = 'http://localhost:8000/demo_final/start.html?queue_id='+escape(queueId)+'&redirect_to='+url;
- $('#generated_url').val(final_url);
- $('#link_container').html('<a href="'+final_url+'" >'+final_url+'</a>');
+ var slave_url = 'http://localhost:8000/demo_final/start.html?queue_id='+escape(queueId)+'&redirect_to='+url;
+ $('#slave_url').val(slave_url+'&cyclops_slave=true');
+ var master_url = slave_url+'&cyclops_master=true';
+ $('#link_container').html('<a href="'+master_url+'" >'+master_url+'</a>');
return false;
});
</script>
View
2 nginx/nginx.conf
@@ -46,7 +46,7 @@ http {
push_publisher;
push_store_messages off; # enable message queueing
- push_message_timeout 2h; # expire buffered messages after 2 hours
+ push_message_timeout 2s; # expire buffered messages after 2 hours
push_max_message_buffer_length 100; # store 10 messages
push_min_message_recipients 1; # minimum recipients before purge
}

0 comments on commit 1d8ef42

Please sign in to comment.