integ/js/vs/_vs.stream.js
changeset 65 b13a409f01dc
parent 64 2937fe1ba865
child 66 a77532772aa4
equal deleted inserted replaced
64:2937fe1ba865 65:b13a409f01dc
     1 // ....................................................................
       
     2 // Stream function 
       
     3 // 
       
     4 // ....................................................................
       
     5 
       
     6 (function ($) {
       
     7 
       
     8 $.fn._vs.stream = {
       
     9     i:null,
       
    10     buffer:[],
       
    11     speed:10000/6,
       
    12     strategy:null,
       
    13     type:null,
       
    14 
       
    15     init:function(_this){
       
    16       this.speed = _this.settings.data.stream.refresh
       
    17       type       = _this.settings.data.stream.provider
       
    18     },
       
    19 
       
    20     push:function(elements){
       
    21       console.log(elements)
       
    22       for (var i = elements.length - 1; i >= 0; i--) {
       
    23         buffer.push(elements)
       
    24       };
       
    25     },
       
    26 
       
    27     update:function (_this){
       
    28       if(type=='generator'){
       
    29         for(var i = 0 ; i<_this.settings.data.model.length ; i++) {
       
    30          _this.dataFlow[i] = setInterval(
       
    31                             (function(i,_this){
       
    32                               return function() { 
       
    33                                 _this.settings.data.stream.now++
       
    34                                 // find the element inside the chart conf files
       
    35                                 var token = _this.chart[_this.settings.chart.type](_this,'token',i)
       
    36                                 _this.addToken(token);
       
    37                               }
       
    38                             })(i,_this)
       
    39                             ,this.speed);
       
    40         }
       
    41 
       
    42       }else if (type=='tokens'){
       
    43 
       
    44         _this.dataFlow[0] = setInterval(
       
    45                             (function(i,_this){
       
    46                               return function() { 
       
    47 
       
    48                                 _this.settings.data.stream.now++
       
    49                                 //if(){
       
    50                                   //console.log('tokens',_this.settings.stream.now)
       
    51                                   for(var i = 0 ; i<_this.settings.data.tokens.length ; i++) {
       
    52                                      if(_this.settings.data.tokens[i].t==_this.settings.data.stream.now){
       
    53                                         _this.addToken(_this.settings.data.tokens[i]);
       
    54                                      }
       
    55                                   }
       
    56                                 //}
       
    57                               }
       
    58                             })(i,_this)
       
    59                             ,this.speed);
       
    60 
       
    61       }else{
       
    62         //console.log('direct no stream')
       
    63       }
       
    64     },
       
    65     generator:function(_this,fn){
       
    66       /*
       
    67       function sine(){}
       
    68       function cosine(){}
       
    69       function tane(){}
       
    70     */
       
    71     },
       
    72     test:function (_this){                                              
       
    73        _this.tokens.push(
       
    74          _this.token.createDataBarBall(
       
    75              _this,
       
    76              (_this.settings.sedimentation.incoming[i].x+(Math.random()*2)),
       
    77              (_this.settings.sedimentation.incoming[i].y+(Math.random()*1)),
       
    78               _this.settings.sedimentation.token.size,
       
    79               i)
       
    80        )                  
       
    81     },
       
    82     setSpeed:function(_this,speed){
       
    83       speedFlow  = speed;
       
    84       for( var i = 0 ; i<categorys.length ; i++) {
       
    85         window.clearInterval(dataFlow[i]);
       
    86       }
       
    87       window.clearInterval(decayFlow);
       
    88       dataFlow(categorys);
       
    89     }
       
    90 }
       
    91 
       
    92 
       
    93 })(jQuery);