|
28
|
1 |
(function ($) { |
|
|
2 |
//console.log("flocullate loaded") |
|
|
3 |
$.fn._vs.flocculate = { |
|
|
4 |
|
|
|
5 |
buffer:[], |
|
|
6 |
|
|
|
7 |
init:function(_this){ |
|
|
8 |
console.log("init flocculate",_this) |
|
|
9 |
// create one buffer by data model (categorys) |
|
|
10 |
for (var i =0; i<_this.settings.data.model.length; i++) { |
|
|
11 |
this.buffer[i] = [] |
|
|
12 |
console.log(i) |
|
|
13 |
}; |
|
|
14 |
}, |
|
|
15 |
|
|
|
16 |
|
|
|
17 |
// OLD STUFF NOT USED |
|
|
18 |
addtobuffer:function(_this,token){ |
|
|
19 |
c = token.attr("category") |
|
|
20 |
bufferSize =_this.settings.sedimentation.flocculate.bufferSize |
|
|
21 |
this.buffer[c].push(token) |
|
|
22 |
_this.decay.tokens.splice(_this.decay.tokens.indexOf(token),1) |
|
|
23 |
// |
|
|
24 |
token.attr("callback","bufferFlocculation",token) |
|
|
25 |
|
|
|
26 |
if(this.buffer[c].length > bufferSize){ |
|
|
27 |
//console.log("order") |
|
|
28 |
this.update(_this,c,bufferSize) |
|
|
29 |
} |
|
|
30 |
}, |
|
|
31 |
|
|
|
32 |
destroyIt:function(_this,token){ |
|
|
33 |
token.attr("callback","flocculation",token) // callback |
|
|
34 |
token.attr("state",2) // flocullating state |
|
|
35 |
//token.myobj=null |
|
|
36 |
// console.log(token.attr('ID')) |
|
|
37 |
var del = _this.world.DestroyBody(token.myobj.GetBody()); |
|
|
38 |
|
|
|
39 |
return del |
|
|
40 |
}, |
|
|
41 |
|
|
|
42 |
update:function(_this,c,nbtokens) { |
|
|
43 |
if(_this.settings.sedimentation.flocculate.number==1){ |
|
|
44 |
while(this.buffer[c].length > nbtokens) { |
|
|
45 |
var token = this.buffer[c].shift(); |
|
|
46 |
this.destroyIt(_this,token) |
|
|
47 |
} |
|
|
48 |
}else { |
|
|
49 |
while(this.buffer[c].length > _this.settings.sedimentation.flocculate.number) { |
|
|
50 |
var token = this.buffer[c].shift(); |
|
|
51 |
this.destroyIt(_this,token) |
|
|
52 |
} |
|
|
53 |
} |
|
|
54 |
|
|
|
55 |
}, |
|
|
56 |
|
|
|
57 |
disapear:function(_this,token){ |
|
|
58 |
///draft doesn't work |
|
|
59 |
window.setInterval( |
|
|
60 |
function(){token.update(self);}, |
|
|
61 |
self.settings.options.refresh/2 |
|
|
62 |
); |
|
|
63 |
}, |
|
|
64 |
|
|
|
65 |
all:function(_this) { |
|
|
66 |
// TODO destroy all |
|
|
67 |
console.log(_this.settings.data) |
|
|
68 |
for (var i = _this.decay.tokens - 1; i >= 0; i--) { |
|
|
69 |
console.log(_this.decay.tokens) |
|
|
70 |
this.update(_this,i,_this.tokens.length); |
|
|
71 |
}; |
|
|
72 |
}, |
|
|
73 |
|
|
|
74 |
strategy:function(){ |
|
|
75 |
if(flocullateBuffer.length>0){ |
|
|
76 |
if (chart.flocullate.strategy=="Size" |
|
|
77 |
&& flocullateBuffer.length>=chart.flocullate.bufferSize){ |
|
|
78 |
console.log(flocullateBuffer.length); |
|
|
79 |
flocullateByArray(flocullateBuffer); |
|
|
80 |
|
|
|
81 |
}else if (chart.flocullate.strategy=="Time") { |
|
|
82 |
|
|
|
83 |
}else if (chart.flocullate.strategy=="Height") { |
|
|
84 |
|
|
|
85 |
}; |
|
|
86 |
} |
|
|
87 |
|
|
|
88 |
}} |
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
})(jQuery); |