Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function retrieveMessages(groupid, callback){
- getAllMembers(groupid, function(allmembers){
- var json = {
- "name": "Vizualise",
- "data": {
- "$area": 4,
- "$dim": 4,
- "$color": "#001eff"
- }
- };
- w=0;
- z=0;
- json.children = [];
- for (var i=0, l = allmembers.length; i<l; i++) // l = allmembers.length
- {
- FB.api(
- {
- method: 'fql.query',
- query: 'SELECT actor_id, source_id, message FROM stream WHERE message != "" AND actor_id !=' + allmembers[i] + ' AND actor_id IN (' + allmembers + ') AND source_id =' + allmembers[i] + ' limit 1000'
- }, function(resp){
- if(resp[0] != undefined)
- {
- //console.log(" ");
- //console.log("TO:" + resp[0].source_id);
- json.children[z] = {
- id: 'node'+ w,
- name: resp[0].source_id,
- data: {
- $area : 2,
- $dim : 2,
- $color: '#111'
- }
- };
- w++;
- json.children[z].children = [];
- x=0;
- for (var j=0, k=resp.length; j<k; j++)
- {
- if(resp[j].message != undefined)
- {
- json.children[z].children[x] = {
- id: 'node'+ w,
- name: resp[j].actor_id,
- data: {
- $area : 10,
- $dim : 10,
- $color: '#000'
- }
- };
- w++;
- //console.log("FROM: " + resp[j].actor_id);
- y=0;
- json.children[z].children[x].children = [];
- for(m=0, n=resp.length; m<n;m++)
- {
- if(resp[j].actor_id == resp[m].actor_id)
- {
- //console.log("MESSAGE: " + resp[m].message);
- json.children[z].children[x].children[y] = {
- id:'node' + w,
- name: resp[m].message,
- data: {
- $area : 10,
- $dim : 10,
- $color: '#111'
- }
- }
- w++;
- y++;
- delete resp[m].message;
- }
- }
- x++;
- }
- }
- z++;
- }
- });
- }
- //console.log(json);
- /* setTimeout(function(){
- callback(json);
- },500);*/
- callback(json);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement