forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracer.js
More file actions
57 lines (56 loc) · 1.4 KB
/
tracer.js
File metadata and controls
57 lines (56 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function Tracer(module) {
this.module = module || Tracer;
this.capsule = tm.allocate(this);
$.extend(this, this.capsule);
if (this.new) {
Tracer.prototype.init.call(this);
return true;
}
return false;
}
Tracer.prototype = {
constructor: Tracer,
init: function () {
this.$container.append($('<span class="name">').text(this.name));
},
_setData: function () {
tm.pushStep(this.capsule, {type: 'setData', arguments: arguments});
},
_clear: function () {
tm.pushStep(this.capsule, {type: 'clear'});
},
_next: function () {
tm.newStep();
},
processStep: function (step, options) {
switch (step.type) {
case 'setData':
this.setData.apply(this, step.arguments);
break;
case 'clear':
this.clear();
break;
}
},
setData: function () {
var data = JSON.stringify(arguments);
if (!this.new && this.lastData == data) return true;
this.new = this.capsule.new = false;
this.lastData = this.capsule.lastData = data;
return false;
},
resize: function () {
},
refresh: function () {
},
clear: function () {
},
mousedown: function (e) {
},
mousemove: function (e) {
},
mouseup: function (e) {
},
mousewheel: function (e) {
}
};