提交 ad196808 编写于 作者: J Jason Park

Merge branch 'gh-pages' of https://github.com/parkjs814/AlgorithmVisualizer into gh-pages

......@@ -100,7 +100,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
case 'notify':
if (step.v) {
var $row = this.$table.find('.mtbl-row').eq(step.x);
$row.find('.mtbl-cell').eq(step.y).text(TracerUtil.refineNumber(step.v));
$row.find('.mtbl-cell').eq(step.y).text(TracerUtil.refineByType(step.v));
}
case 'denotify':
case 'select':
......@@ -130,7 +130,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
if (Tracer.prototype.setData.apply(this, arguments)) {
this.$table.find('.mtbl-row').each(function (i) {
$(this).children().each(function (j) {
$(this).text(TracerUtil.refineNumber(D[i][j]));
$(this).text(TracerUtil.refineByType(D[i][j]));
});
});
return true;
......@@ -143,7 +143,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
for (var j = 0; j < D[i].length; j++) {
var $cell = $('<div class="mtbl-cell">')
.css(this.getCellCss())
.text(TracerUtil.refineNumber(D[i][j]));
.text(TracerUtil.refineByType(D[i][j]));
$row.append($cell);
}
}
......
......@@ -45,7 +45,7 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
switch (step.type) {
case 'weight':
var targetNode = this.graph.nodes(this.n(step.target));
if (step.weight !== undefined) targetNode.weight = TracerUtil.refineNumber(step.weight);
if (step.weight !== undefined) targetNode.weight = TracerUtil.refineByType(step.weight);
break;
case 'visit':
case 'leave':
......@@ -53,7 +53,7 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
var targetNode = this.graph.nodes(this.n(step.target));
var color = visit ? this.color.visited : this.color.left;
targetNode.color = color;
if (step.weight !== undefined) targetNode.weight = TracerUtil.refineNumber(step.weight);
if (step.weight !== undefined) targetNode.weight = TracerUtil.refineByType(step.weight);
if (step.source !== undefined) {
var edgeId = this.e(step.source, step.target);
var edge = this.graph.edges(edgeId);
......@@ -97,7 +97,7 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
target: this.n(j),
color: this.color.default,
size: 1,
weight: TracerUtil.refineNumber(G[i][j])
weight: TracerUtil.refineByType(G[i][j])
});
}
}
......
......@@ -189,6 +189,12 @@ var TracerUtil = {
return value === "Infinity" ? Infinity : value;
});
},
refineByType: function (item) {
return $.isNumeric(item) ? this.refineNumber(item) : this.refineString(item);
},
refineString: function (string) {
return string === '' ? ' ' : string;
},
refineNumber: function (number) {
return number === Infinity ? '' : number;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册