Advertisement
Guest User

Code

a guest
May 2nd, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. function retrieveMessages(groupid, callback){
  2. getAllMembers(groupid, function(allmembers){
  3. var json = {
  4. "name": "Vizualise",
  5. "data": {
  6. "$area": 4,
  7. "$dim": 4,
  8. "$color": "#001eff"
  9. }
  10. };
  11.  
  12. w=0;
  13. z=0;
  14. json.children = [];
  15. for (var i=0, l = allmembers.length; i<l; i++) // l = allmembers.length
  16. {
  17. FB.api(
  18. {
  19. method: 'fql.query',
  20. 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'
  21. }, function(resp){
  22. if(resp[0] != undefined)
  23. {
  24. //console.log(" ");
  25. //console.log("TO:" + resp[0].source_id);
  26. json.children[z] = {
  27. id: 'node'+ w,
  28. name: resp[0].source_id,
  29. data: {
  30. $area : 2,
  31. $dim : 2,
  32. $color: '#111'
  33.  
  34. }
  35. };
  36. w++;
  37. json.children[z].children = [];
  38. x=0;
  39. for (var j=0, k=resp.length; j<k; j++)
  40. {
  41. if(resp[j].message != undefined)
  42. {
  43.  
  44. json.children[z].children[x] = {
  45. id: 'node'+ w,
  46. name: resp[j].actor_id,
  47. data: {
  48. $area : 10,
  49. $dim : 10,
  50. $color: '#000'
  51.  
  52. }
  53. };
  54. w++;
  55.  
  56. //console.log("FROM: " + resp[j].actor_id);
  57. y=0;
  58. json.children[z].children[x].children = [];
  59.  
  60. for(m=0, n=resp.length; m<n;m++)
  61. {
  62. if(resp[j].actor_id == resp[m].actor_id)
  63. {
  64. //console.log("MESSAGE: " + resp[m].message);
  65. json.children[z].children[x].children[y] = {
  66. id:'node' + w,
  67. name: resp[m].message,
  68. data: {
  69. $area : 10,
  70. $dim : 10,
  71. $color: '#111'
  72.  
  73. }
  74.  
  75. }
  76.  
  77. w++;
  78. y++;
  79.  
  80. delete resp[m].message;
  81. }
  82. }
  83.  
  84. x++;
  85. }
  86.  
  87. }
  88. z++;
  89. }
  90. });
  91. }
  92. //console.log(json);
  93. /* setTimeout(function(){
  94. callback(json);
  95. },500);*/
  96. callback(json);
  97. });
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement