Corrected segments widget, added excludePattern option to tagcloud widget popcorn-port
authorveltr
Tue, 06 Mar 2012 13:26:51 +0100
branchpopcorn-port
changeset 829 ae16691d183d
parent 828 bcf0c2bdcb8e
child 830 18ca612e9ff0
Corrected segments widget, added excludePattern option to tagcloud widget
src/js/widgets/segmentsWidget.js
src/js/widgets/tagCloudWidget.js
test/integration/polemic.htm
--- a/src/js/widgets/segmentsWidget.js	Mon Mar 05 18:11:58 2012 +0100
+++ b/src/js/widgets/segmentsWidget.js	Tue Mar 06 13:26:51 2012 +0100
@@ -50,7 +50,7 @@
   if (typeof(view_type) === "undefined") {
     view_type = this._serializer.getNonTweetIds()[0];  
   }
-  this.positionMarker = this.selector.children(":first");
+  this.positionMarker = this.selector.find(".Ldt-SegmentPositionMarker");
   
   this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.positionUpdater));
 
--- a/src/js/widgets/tagCloudWidget.js	Mon Mar 05 18:11:58 2012 +0100
+++ b/src/js/widgets/tagCloudWidget.js	Tue Mar 06 13:26:51 2012 +0100
@@ -6,23 +6,29 @@
 
 IriSP.TagCloudWidget.prototype.draw = function() {
     
-    var _stopwords = [
-            'aussi', 'and', 'avec', 'aux', 'car', 'cette', 'comme', 'dans', 'donc', 'des', 'elle', 'est',
-            'être', 'eux', 'fait', 'ici', 'ils', 'les', 'leur', 'leurs', 'mais', 'mes', 'même', 'mon', 'notre',
-            'non', 'nos', 'nous', 'ont', 'par', 'pas', 'peu', 'pour', 'que', 'qui', 'ses' ,'son', 'sont', 'sur',
-            'tes', 'très', 'the', 'ton', 'tous', 'tout', 'une', 'votre', 'vos', 'vous'
-        ],
+    var _urlRegExp = /https?:\/\/[0-9a-zA-Z\.%\/-_]+/g,
+        _stopWords = [
+            'aussi', 'and', 'avec', 'aux', 'bien', 'car', 'cette', 'comme', 'dans', 'donc', 'des', 'elle', 'encore', 'est',
+            'être', 'eux', 'faire', 'fait', 'http', 'ici', 'ils', 'les', 'leur', 'leurs', 'mais', 'mes', 'même', 'mon', 'notre',
+            'non', 'nos', 'nous', 'ont', 'par', 'pas', 'peu', 'peut', 'plus', 'pour', 'que', 'qui', 'ses' ,'son', 'sont', 'sur',
+            'tes', 'très', 'the', 'ton', 'tous', 'tout', 'une', 'votre', 'vos', 'vous' ],
         _regexpword = /[^\s\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g,
         _words = {},
         _showTitle = !this._config.excludeTitle,
         _showDescription = !this._config.excludeDescription,
+        _excludePattern = this._config.excludePattern || null,
         _tagCount = this._config.tagCount || 30;
+    if (typeof this._config.excludeWords !== "undefined" && this._config.excludeWords.length) {
+        IriSP._(this._config.excludeWords).each(function(_w) {
+            _stopWords.push(_w.toLowerCase());
+        });
+    }
     
     IriSP._(this._serializer._data.annotations).each(function(_annotation) {
        if (_annotation.content && _annotation.content.description) {
            var _txt = (_showTitle ? _annotation.content.title : '') + ' ' + (_showDescription ? _annotation.content.description : '')
-           IriSP._(_txt.toLowerCase().match(_regexpword)).each(function(_mot) {
-               if (_stopwords.indexOf(_mot) == -1) {
+           IriSP._(_txt.toLowerCase().replace(_urlRegExp, '').match(_regexpword)).each(function(_mot) {
+               if (_stopWords.indexOf(_mot) == -1 && (_excludePattern == null || !_excludePattern.test(_mot))) {
                    _words[_mot] = 1 + (_words[_mot] || 0);
                }
            })
--- a/test/integration/polemic.htm	Mon Mar 05 18:11:58 2012 +0100
+++ b/test/integration/polemic.htm	Tue Mar 06 13:26:51 2012 +0100
@@ -18,7 +18,7 @@
   <script type="text/javascript" src="../../build/LdtPlayer-release.js" type="text/javascript"></script>   
   
   <div id="video"></div>
-  <div id="LdtPlayer" style="float: right; position: relative;"></div>
+  <div id="LdtPlayer"></div>
   
   <script  type="text/javascript">
     var file = "polemic_fr.json";
@@ -67,11 +67,11 @@
             },            
             {type: "SliceWidget"},            
             {type: "ArrowWidget"},
-
-
             {type: "AnnotationsWidget"},
             {type: "TweetsWidget"},
-            {type: "createAnnotationWidget"}
+            {type: "createAnnotationWidget"},
+            {type: "TagCloudWidget",
+            excludeWords: ['#museoweb']}
             ]
         },
       player:{