Permalink
Browse files

first working replay

  • Loading branch information...
1 parent 0b548e3 commit 52cc812bb62eb20f5776f644f1435485f520ab75 @andregoncalves andregoncalves committed Dec 3, 2009
Showing with 17 additions and 23 deletions.
  1. +17 −23 demo1/application.js
View
@@ -22,6 +22,7 @@ $(document).ready(function() {
});
var eventStorage = [];
+var events = [];
function storeEvent(e) {
@@ -38,36 +39,29 @@ function stopRecording() {
}
function playRecording() {
- $.each(eventStorage, function(index, el) {
+ events = eventStorage.reverse();
+
+
+ intervalID = setInterval(function() {
+ el = events.pop();
+ if (!el) {
+ clearInterval(intervalID);
+ console.info("stopped");
+ }
+ else
+ window["run_"+el.type](el);
+ }, 30);
+ //$.each(eventStorage, function(index, el) {
//console.info("X,Y: " + el.pageX + "," + el.pageY);
- window["run_"+el.type](el);
- });
+ //window["run_"+el.type](el);
+
+ //});
}
function run_mousemove(e) {
-
$("#mouse").css('top', e.pageY).css('left', e.pageX);
console.info("tick");
- sleep(2);
-}
-
-
-
-function sleep(naptime)
-{
- naptime = naptime * 1000;
- var sleeping = true;
- var now = new Date();
- var alarm;
- var startingMSeconds = now.getTime();
- //alert("starting nap at timestamp: " + startingMSeconds + "\nWill sleep for: " + naptime + " ms");
- while(sleeping){
- alarm = new Date();
- alarmMSeconds = alarm.getTime();
- if(alarmMSeconds - startingMSeconds > naptime){ sleeping = false; }
- }
- //alert("Wakeup!");
}

0 comments on commit 52cc812

Please sign in to comment.