summaryrefslogtreecommitdiff
path: root/src/client/model
diff options
context:
space:
mode:
authorLV-426 <lv-426@taproot.org.il>2015-01-20 14:12:48 +0200
committerLV-426 <lv-426@taproot.org.il>2015-01-20 14:12:48 +0200
commit2359f31cce1e71389e18b6e8f28b5e5ccbb7bfbe (patch)
tree4f89f011335c6c08dd3364ff12b839e4211a3cf7 /src/client/model
parent1b8856d9c89e247510eb1237b7fd7c20446122c2 (diff)
graph.js: fix node position based on type (head|commit) + ugly window.commit_idx hackgraph-view-commit-log
Diffstat (limited to 'src/client/model')
-rw-r--r--src/client/model/graph.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/client/model/graph.js b/src/client/model/graph.js
index 49ac4c3c..2de46b3f 100644
--- a/src/client/model/graph.js
+++ b/src/client/model/graph.js
@@ -151,6 +151,23 @@ function Graph(spec) {
}
util.assert(undefined != node.id, '__addNode: node id missing');
+
+ /*
+ * Fix node position if of 'commit' type
+ */
+ if (node.type == 'head') {
+ node.x = 50;
+ node.y = 250;
+ node.fixed = true;
+ } else if (node.type == 'commit') {
+ node.__commit_seq = window.commit_idx;
+ Object.defineProperty(node, 'x', { get: function() { return 50; }});
+ Object.defineProperty(node, 'px', { get: function() { return 50; }});
+ Object.defineProperty(node, 'y', { get: function() { return 250 + 50 * this.__commit_seq; }});
+ Object.defineProperty(node, 'py', { get: function() { return 250 + 50 * this.__commit_seq; }});
+ window.commit_idx += 1;
+ }
+
_node_add_helper(node);
if (debug) {
console.log('__addNode: node added: id: ' + node.id + ' state ' + node.state);
@@ -159,6 +176,7 @@ function Graph(spec) {
return node;
}
this.__addNode = __addNode;
+ window.commit_idx = 1;
var _node_remove_helper = function (node_id) {
util.assert(node_id, "missing node id");