web/res/js-tweetcast/live-polemic.js
changeset 408 4141c5821c98
parent 407 5ab44abc46df
child 412 97c082990f8d
--- a/web/res/js-tweetcast/live-polemic.js	Wed Dec 14 16:58:57 2011 +0100
+++ b/web/res/js-tweetcast/live-polemic.js	Wed Dec 14 18:22:27 2011 +0100
@@ -524,36 +524,10 @@
         });
 }
 
-function updateSuggested() {
-    if (!suggested_keywords || !suggested_keywords.length) {
-        return;
-    }
-    var _skw = suggested_keywords.map(function(_e) {
-        return {
-            "word" : _e,
-            "rgxp" : new RegExp(_e, "im"),
-            "freq" : 0,
-            "annotations" : {}
-        }
-    })
-    _(twCx.tweets).each(function(_t) {
-        _(_skw).each(function(_k) {
-            if (_t.text.search(_k.rgxp) != -1) {
-                _k.freq++;
-                _(_t.annotations).each(function(_a) {
-                    _k.annotations[_a] = 1 + ( _k.annotations[_a] || 0 )
-                })
-            }
-        });
-    });
-    makeTagCloud(_skw, "#suggkw");
-}
-
 function updateDisplay() {
     if (!twCx.tweets) {
         return;
     }
-    updateSuggested();
     if (twCx.filtre) {
         var tweets = twCx.tweets.filter(function(tweet) {
             var mention = '@' + tweet.user.screen_name;
@@ -581,7 +555,19 @@
             p = (twCx.followLast ? twCx.idIndex.length - 1 : 0);
         }
     }
-
+    
+    
+    if (suggested_keywords && suggested_keywords.length) {
+        var _skw = suggested_keywords.map(function(_e) {
+            return {
+                "word" : _e,
+                "rgxp" : new RegExp(_e, "im"),
+                "freq" : 0,
+                "annotations" : {}
+            }
+        })
+    }
+    
     var l = tweets.length,
         lines = 0,
         ppy = 0,
@@ -590,9 +576,24 @@
         localWords = {};
     
     function pushTweet(tp, className) {
+        
         if (tp < l && tp >= 0) {
-            html += tweetToHtml(tweets[tp], className)
+            
+            if (_skw) {
+                _(_skw).each(function(_k) {
+                    if (tweets[tp].text.search(_k.rgxp) != -1) {
+                        _k.freq++;
+                        _(tweets[tp].annotations).each(function(_a) {
+                            _k.annotations[_a] = 1 + ( _k.annotations[_a] || 0 )
+                        })
+                    }
+                });
+            }
+            
+            html += tweetToHtml(tweets[tp], className);
+            
             tweetsOnDisplay.push(tp);
+            
             for (var i in tweets[tp].words) {
                 var w = tweets[tp].words[i];
                 if (localWords[w]) {
@@ -665,6 +666,9 @@
             tlBuffer = html;
         }
         
+        if (_skw) {
+            makeTagCloud(_skw, "#suggkw");
+        }
         /* Recherche des mots pertinents correspondant à la sélection */
         
         var tab = _(localWords).map(function(v, k) {