提交 21b6d2a4 编写于 作者: J Jason Park

prepare for other modules

上级 4860059b
var s = null, graph = null, graphMode = null, sigmaCanvas = null;
var s = null, graph = null, sigmaCanvas = null;
function GraphTracer(module) {
Tracer.call(this, module || GraphTracer);
return initGraph(this.module);
if (Tracer.call(this, module || WeightedGraphTracer)) {
initGraph();
return true;
}
return false;
}
GraphTracer.graphMode = "default";
GraphTracer.prototype = Object.create(Tracer.prototype);
GraphTracer.prototype.constructor = GraphTracer;
......@@ -59,7 +61,6 @@ GraphTracer.prototype.setTreeData = function (G, root) {
if (this.setData(G, root)) return true;
var place = function (node, x, y) {
console.log(node);
var temp = graph.nodes(n(node));
temp.x = x;
temp.y = y;
......@@ -190,10 +191,7 @@ GraphTracer.prototype.prevStep = function () {
this.step(finalIndex);
};
var initGraph = function (module) {
if (s && graph && graphMode == module.graphMode) return false;
graphMode = module.graphMode;
var initGraph = function () {
$('.visualize_container').empty();
if (sigmaCanvas == null) {
sigmaCanvas = $.extend(true, {}, sigma.canvas);
......@@ -232,8 +230,6 @@ var initGraph = function (module) {
drawArrow(edge, source, target, color, context, settings);
};
sigma.plugins.dragNodes(s, s.renderers[0]);
return true;
};
var graphColor = {
......
......@@ -6,7 +6,6 @@ function WeightedGraphTracer(module) {
return false;
}
WeightedGraphTracer.graphMode = "weighted";
WeightedGraphTracer.prototype = Object.create(GraphTracer.prototype);
WeightedGraphTracer.prototype.constructor = WeightedGraphTracer;
......
......@@ -13,6 +13,7 @@ var codeEditor = initEditor('code');
dataEditor.on('change', function () {
try {
eval(dataEditor.getValue());
lastModule = _tracer && _tracer.module;
_tracer = tracer;
} catch (err) {
}
......@@ -20,7 +21,6 @@ dataEditor.on('change', function () {
});
var loadFile = function (category, algorithm, file, explanation) {
lastModule = null;
lastData = null;
$('#explanation').html(explanation);
dataEditor.setValue('');
......@@ -134,6 +134,7 @@ $('#navigation').click(function () {
$('#btn_run').click(function () {
try {
eval(dataEditor.getValue());
lastModule = _tracer && _tracer.module;
_tracer = tracer;
_tracer.reset();
eval(codeEditor.getValue());
......
......@@ -9,6 +9,8 @@ var Tracer = function (module) {
this.traceOptions = null;
this.traceIndex = -1;
this.stepCnt = 0;
return lastModule != module;
};
Tracer.prototype.resize = function () {
......@@ -30,8 +32,7 @@ Tracer.prototype.createRandomData = function (arguments) {
Tracer.prototype.setData = function (arguments) {
var data = JSON.stringify(arguments);
if (lastModule == this.module && lastData == data) return true;
lastModule = this.module;
if (lastData == data) return true;
lastData = data;
return false;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册