Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5557c27
commit a30bf06
Showing
6 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var Cyclops = { | ||
|
||
init:function() { | ||
this.eventStorage = {}; | ||
pubsub.subscribe('/record/start', this, "startRecording"); | ||
pubsub.subscribe('/record/stop', this, "stopRecording"); | ||
}, | ||
|
||
startRecording: function(e) { | ||
$(document).bind('mousemove', this.storeEvent); | ||
}, | ||
|
||
stopRecording: function(e) { | ||
$(document).unbind('mousemove', this.storeEvent); | ||
}, | ||
|
||
storeEvent: function(e) { | ||
this.eventStorage.push(e); | ||
this.sendEvent(e); | ||
}, | ||
|
||
sendEvent: function(e) { | ||
ev = this['getEvent_'+e.type](e); | ||
|
||
$.post('/publish?id=demo2', ev.serialize(), function(data, textStatus) { | ||
if (textStatus != "success") | ||
console.info("failed posting! " + stextStatus); | ||
}); | ||
}, | ||
|
||
getEvent_mousemove: function(e) { | ||
event = new CyEvent("mousemove", { x:e.pageX, y:e.pageY }); | ||
return event; | ||
}, | ||
|
||
playEvent_mousemove: function(e) { | ||
$("#mouse").css('top', e.x).css('left', e.y); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var CyNotify = { | ||
subscribe: function(eventname) { | ||
pubsub.subscribe(eventname, this, "notify"); | ||
}, | ||
|
||
unsubscribe: function(eventname) { | ||
|
||
}, | ||
|
||
notify: function(e,msg) { | ||
$.jGrowl(msg); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
|
||
$(document).ready(function() { | ||
window.pubsub = new PubSub('/record/start', '/record/stop'); | ||
CyNotify.subscribe('/record/start'); | ||
CyNotify.subscribe('/record/stop'); | ||
|
||
|
||
/*e = new CyEvent("mousemove", { x:10, y:20}); | ||
s = e.serialize(); | ||
e = JSON.parse(s);*/ | ||
|
||
|
||
|
||
}); | ||
|
||
$(window).load(function() { | ||
Cyclops.init(); | ||
|
||
$(document).bind('keydown', 'Ctrl+r', function(e) { | ||
pubsub.publish('/record/start', e, 'recording started'); | ||
}); | ||
|
||
$(document).bind('keydown', 'Ctrl+s', function(e) { | ||
pubsub.publish('/record/stop', e, 'recording 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"); | ||
});*/ | ||
|
||
}); | ||
|
||
/* | ||
function simulateClick() { | ||
var evt = document.createEvent("MouseEvents"); | ||
evt.initMouseEvent("click", true, true, window, | ||
0, 0, 0, 0, 0, false, false, false, false, 0, null); | ||
var element = document.elementFromPoint(16, 109); | ||
//document.getElementById('body').dispatchEvent(evt); | ||
element.dispatchEvent(evt); | ||
} | ||
*/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function CyEvent(type, data) { | ||
this.type = type; | ||
this.data = data; | ||
} | ||
|
||
CyEvent.prototype.serialize = function() { | ||
|
||
return JSON.stringify(this); | ||
} |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Cyclops Demo 2</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 id="body"> | ||
<header class="clearfix"> | ||
<h1>Proof of Concept 2</h1> | ||
</header> | ||
<div id="main"> | ||
<button id="a">Click me</button> | ||
</div> | ||
<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/demo2.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/cymain.js" type="text/javascript" charset="utf-8"></script> | ||
<script src="../assets/javascripts/cynotify.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> | ||
</body> | ||
</html> |