| changeset 20 | bd58970ffd16 |
| parent 4 | f5297dde9053 |
| child 21 | b43dd87f7ffa |
| 19:d49b927bfe62 | 20:bd58970ffd16 |
|---|---|
1 Rkns.Serializers.RandomData = Rkns.Utils.inherit(Rkns.Serializers._Base); |
1 Rkns.RemoteModels.RandomData = Rkns.Utils.inherit(Rkns.RemoteModels._Base); |
2 |
2 |
3 Rkns.Serializers.RandomData.prototype._init = function() { |
3 Rkns.RemoteModels.RandomData.prototype._init = function() { |
4 this._USER_COUNT = 5; |
4 this._USER_COUNT = 5; |
5 this._NODE_COUNT = 20; |
5 this._NODE_COUNT = 20; |
6 this._EDGE_COUNT = 40; |
6 this._EDGE_COUNT = 40; |
7 this.user_colors = ["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"]; |
7 this.user_colors = ["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"]; |
8 this.load(); |
8 this.load(); |
9 } |
9 } |
10 |
10 |
11 Rkns.Serializers.RandomData.prototype.load = function() { |
11 Rkns.RemoteModels.RandomData.prototype.load = function() { |
12 var _p = this._project; |
12 var _p = this._project; |
13 _p.title = "Random Generated Data"; |
13 _p.title = "Random Generated Data"; |
14 for (var i = 0; i < this._USER_COUNT; i++) { |
14 for (var i = 0; i < this._USER_COUNT; i++) { |
15 _p.users.push(new Rkns.Model.User(_p, { |
15 _p.users.push(new Rkns.ViewModel.User(_p, { |
16 id: "user-"+i, |
16 id: "user-"+i, |
17 title: "User #"+(1+i), |
17 title: "User #"+(1+i), |
18 color: this.user_colors[i] |
18 color: this.user_colors[i] |
19 })); |
19 })); |
20 } |
20 } |
21 for (var i = 0; i < this._NODE_COUNT; i++) { |
21 for (var i = 0; i < this._NODE_COUNT; i++) { |
22 _p.nodes.push(new Rkns.Model.Node(_p, { |
22 _p.nodes.push(new Rkns.ViewModel.Node(_p, { |
23 id: "node-"+i, |
23 id: "node-"+i, |
24 title: "Node #"+(1+i), |
24 title: "Node #"+(1+i), |
25 created_by: "user-" + Math.floor(this._USER_COUNT*Math.random()), |
25 created_by: "user-" + Math.floor(this._USER_COUNT*Math.random()), |
26 position: { |
26 position: { |
27 // x: 200 * Math.random(), |
27 // x: 200 * Math.random(), |
35 var _from, _to; |
35 var _from, _to; |
36 _from = _to = Math.floor(this._NODE_COUNT*Math.random()); |
36 _from = _to = Math.floor(this._NODE_COUNT*Math.random()); |
37 while(_from === _to) { |
37 while(_from === _to) { |
38 _to = Math.floor(this._NODE_COUNT*Math.random()); |
38 _to = Math.floor(this._NODE_COUNT*Math.random()); |
39 } |
39 } |
40 _p.edges.push(new Rkns.Model.Edge(_p, { |
40 _p.edges.push(new Rkns.ViewModel.Edge(_p, { |
41 id: "edge-"+i, |
41 id: "edge-"+i, |
42 title: "Edge #"+(1+i), |
42 title: "Edge #"+(1+i), |
43 created_by: "user-" + Math.floor(this._USER_COUNT*Math.random()), |
43 created_by: "user-" + Math.floor(this._USER_COUNT*Math.random()), |
44 from: "node-" + _from, |
44 from: "node-" + _from, |
45 to: "node-" + _to |
45 to: "node-" + _to |