Skip to content

Commit c8325f6

Browse files
committed
Merge branch 'gh-pages' of https://github.com/parkjs814/AlgorithmVisualizer into feature/chartTracer
2 parents b4bacc6 + 0d0a27c commit c8325f6

9 files changed

Lines changed: 523 additions & 507 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ http://parkjs814.github.io/AlgorithmVisualizer
1111
### Contributing
1212
If you run _Algorithm Visualizer_ locally and files are not loaded because Cross-Origin Requests are blocked, use [http-server](https://github.com/indexzero/http-server) or [SimpleHTTPServer](https://docs.python.org/2/library/simplehttpserver.html) to resolve the issue. [(Issue #2)](https://github.com/parkjs814/AlgorithmVisualizer/issues/2)
1313

14-
If in need of any help check out or [**Wiki**](https://github.com/parkjs814/AlgorithmVisualizer/wiki) or join our [Gitter](https://gitter.im/parkjs814/AlgorithmVisualizer?utm_source=share-link&utm_medium=link&utm_campaign=share-link) chatroom!
14+
If in need of any help check out [**Wiki**](https://github.com/parkjs814/AlgorithmVisualizer/wiki) or join our [Gitter](https://gitter.im/parkjs814/AlgorithmVisualizer?utm_source=share-link&utm_medium=link&utm_campaign=share-link) chatroom!
1515
### Backers
1616

1717
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/algorithmvisualizer#backer)]

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ <h3>
111111
<script src="js/sigma/plugins/sigma.plugins.dragNodes.min.js"></script>
112112
<script src="js/ace/ace.js"></script>
113113
<script src="js/ace/ext-language_tools.js"></script>
114-
<script src="js/module/tracer_manager.js"></script>
114+
<script src="js/tracer_manager.js"></script>
115115
<script src="js/module/tracer.js"></script>
116116
<script src="js/module/log_tracer.js"></script>
117117
<script src="js/module/array2d.js"></script>

js/module/array2d.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
1313
this.$container.append(this.$table);
1414
},
1515
_notify: function (x, y, v) {
16-
tm.pushStep(this.capsule, {
16+
this.tm.pushStep(this.capsule, {
1717
type: 'notify',
1818
x: x,
1919
y: y,
@@ -22,7 +22,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
2222
return this;
2323
},
2424
_denotify: function (x, y) {
25-
tm.pushStep(this.capsule, {
25+
this.tm.pushStep(this.capsule, {
2626
type: 'denotify',
2727
x: x,
2828
y: y
@@ -93,14 +93,14 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
9393
type: type
9494
};
9595
$.extend(step, coord);
96-
tm.pushStep(this.capsule, step);
96+
this.tm.pushStep(this.capsule, step);
9797
},
9898
processStep: function (step, options) {
9999
switch (step.type) {
100100
case 'notify':
101101
if (step.v) {
102102
var $row = this.$table.find('.mtbl-row').eq(step.x);
103-
$row.find('.mtbl-cell').eq(step.y).text(refineNumber(step.v));
103+
$row.find('.mtbl-cell').eq(step.y).text(TracerUtil.refineNumber(step.v));
104104
}
105105
case 'denotify':
106106
case 'select':
@@ -130,7 +130,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
130130
if (Tracer.prototype.setData.apply(this, arguments)) {
131131
this.$table.find('.mtbl-row').each(function (i) {
132132
$(this).children().each(function (j) {
133-
$(this).text(refineNumber(D[i][j]));
133+
$(this).text(TracerUtil.refineNumber(D[i][j]));
134134
});
135135
});
136136
return true;
@@ -143,7 +143,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
143143
for (var j = 0; j < D[i].length; j++) {
144144
var $cell = $('<div class="mtbl-cell">')
145145
.css(this.getCellCss())
146-
.text(refineNumber(D[i][j]));
146+
.text(TracerUtil.refineNumber(D[i][j]));
147147
$row.append($cell);
148148
}
149149
}

js/module/directed_graph.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ DirectedGraphTracer.prototype = $.extend(true, Object.create(Tracer.prototype),
4646
this.graph = this.capsule.graph = this.s.graph;
4747
},
4848
_setTreeData: function (G, root) {
49-
tm.pushStep(this.capsule, {type: 'setTreeData', arguments: arguments});
49+
this.tm.pushStep(this.capsule, {type: 'setTreeData', arguments: arguments});
5050
return this;
5151
},
5252
_visit: function (target, source) {
53-
tm.pushStep(this.capsule, {type: 'visit', target: target, source: source});
53+
this.tm.pushStep(this.capsule, {type: 'visit', target: target, source: source});
5454
return this;
5555
},
5656
_leave: function (target, source) {
57-
tm.pushStep(this.capsule, {type: 'leave', target: target, source: source});
57+
this.tm.pushStep(this.capsule, {type: 'leave', target: target, source: source});
5858
return this;
5959
},
6060
processStep: function (step, options) {

js/module/log_tracer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LogTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
1313
this.$container.append(this.$wrapper);
1414
},
1515
_print: function (msg) {
16-
tm.pushStep(this.capsule, {type: 'print', msg: msg});
16+
this.tm.pushStep(this.capsule, {type: 'print', msg: msg});
1717
return this;
1818
},
1919
processStep: function (step, options) {

js/module/tracer.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
function Tracer(name) {
22
this.module = this.constructor;
3-
this.capsule = tm.allocate(this);
3+
this.capsule = this.tm.allocate(this);
44
$.extend(this, this.capsule);
55
this.setName(name);
66
return this.new;
77
}
88

99
Tracer.prototype = {
1010
constructor: Tracer,
11+
tm: null,
1112
_setData: function () {
1213
var args = Array.prototype.slice.call(arguments);
13-
tm.pushStep(this.capsule, {type: 'setData', args: toJSON(args)});
14+
this.tm.pushStep(this.capsule, {type: 'setData', args: TracerUtil.toJSON(args)});
1415
return this;
1516
},
1617
_clear: function () {
17-
tm.pushStep(this.capsule, {type: 'clear'});
18+
this.tm.pushStep(this.capsule, {type: 'clear'});
1819
return this;
1920
},
2021
_wait: function () {
21-
tm.newStep();
22+
this.tm.newStep();
2223
return this;
2324
},
2425
processStep: function (step, options) {
2526
switch (step.type) {
2627
case 'setData':
27-
this.setData.apply(this, fromJSON(step.args));
28+
this.setData.apply(this, TracerUtil.fromJSON(step.args));
2829
break;
2930
case 'clear':
3031
this.clear();
@@ -42,7 +43,7 @@ Tracer.prototype = {
4243
$name.text(name || this.defaultName);
4344
},
4445
setData: function () {
45-
var data = toJSON(arguments);
46+
var data = TracerUtil.toJSON(arguments);
4647
if (!this.new && this.lastData == data) return true;
4748
this.new = this.capsule.new = false;
4849
this.lastData = this.capsule.lastData = data;

js/module/weighted_directed_graph.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,30 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
3030
});
3131
},
3232
_weight: function (target, weight) {
33-
tm.pushStep(this.capsule, {type: 'weight', target: target, weight: weight});
33+
this.tm.pushStep(this.capsule, {type: 'weight', target: target, weight: weight});
3434
return this;
3535
},
3636
_visit: function (target, source, weight) {
37-
tm.pushStep(this.capsule, {type: 'visit', target: target, source: source, weight: weight});
37+
this.tm.pushStep(this.capsule, {type: 'visit', target: target, source: source, weight: weight});
3838
return this;
3939
},
4040
_leave: function (target, source, weight) {
41-
tm.pushStep(this.capsule, {type: 'leave', target: target, source: source, weight: weight});
41+
this.tm.pushStep(this.capsule, {type: 'leave', target: target, source: source, weight: weight});
4242
return this;
4343
},
4444
processStep: function (step, options) {
4545
switch (step.type) {
4646
case 'weight':
4747
var targetNode = this.graph.nodes(this.n(step.target));
48-
if (step.weight !== undefined) targetNode.weight = refineNumber(step.weight);
48+
if (step.weight !== undefined) targetNode.weight = TracerUtil.refineNumber(step.weight);
4949
break;
5050
case 'visit':
5151
case 'leave':
5252
var visit = step.type == 'visit';
5353
var targetNode = this.graph.nodes(this.n(step.target));
5454
var color = visit ? this.color.visited : this.color.left;
5555
targetNode.color = color;
56-
if (step.weight !== undefined) targetNode.weight = refineNumber(step.weight);
56+
if (step.weight !== undefined) targetNode.weight = TracerUtil.refineNumber(step.weight);
5757
if (step.source !== undefined) {
5858
var edgeId = this.e(step.source, step.target);
5959
var edge = this.graph.edges(edgeId);
@@ -97,7 +97,7 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
9797
target: this.n(j),
9898
color: this.color.default,
9999
size: 1,
100-
weight: refineNumber(G[i][j])
100+
weight: TracerUtil.refineNumber(G[i][j])
101101
});
102102
}
103103
}

0 commit comments

Comments
 (0)