Metadataplayer Upgrade
authorveltr
Fri, 25 Jan 2013 18:17:18 +0100
changeset 1084 179ab492a798
parent 1082 28f591b96612
child 1085 2ccbf3c410b2
Metadataplayer Upgrade
src/ldt/ldt/static/ldt/metadataplayer/Annotation.css
src/ldt/ldt/static/ldt/metadataplayer/Annotation.js
src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css
src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js
src/ldt/ldt/static/ldt/metadataplayer/CreateAnnotation.js
src/ldt/ldt/static/ldt/metadataplayer/LdtPlayer-core.css
src/ldt/ldt/static/ldt/metadataplayer/LdtPlayer-core.js
src/ldt/ldt/static/ldt/metadataplayer/MultiSegments.js
src/ldt/ldt/static/ldt/metadataplayer/Slideshare.js
src/ldt/ldt/static/ldt/metadataplayer/Tweet.js
--- a/src/ldt/ldt/static/ldt/metadataplayer/Annotation.css	Wed Jan 23 18:14:24 2013 +0100
+++ b/src/ldt/ldt/static/ldt/metadataplayer/Annotation.css	Fri Jan 25 18:17:18 2013 +0100
@@ -6,10 +6,6 @@
     margin: 0;
 }
 
-.Ldt-Annotation-Highlight {
-    background: #ffa0fc;
-}
-
 .Ldt-Annotation-Widget.Ldt-Annotation-ShowTop {
     border-top-style: solid;
     padding-top: 1px;
--- a/src/ldt/ldt/static/ldt/metadataplayer/Annotation.js	Wed Jan 23 18:14:24 2013 +0100
+++ b/src/ldt/ldt/static/ldt/metadataplayer/Annotation.js	Fri Jan 25 18:17:18 2013 +0100
@@ -76,17 +76,12 @@
             return;
         }
         var title = currentAnnotation.title,
-            description = currentAnnotation.description.replace(/(^\s+|\s+$)/g,'');
-        if (currentAnnotation.found) {
-            var rgxp = _this.source.getAnnotations().regexp || /^$/,
-                repl = '<span class="Ldt-Annotation-Highlight">$1</span>';
-            title = title.replace(rgxp,repl);
-            description = description.replace(rgxp,repl).replace(/[\n\r]+/gm,'<br />');
-        }
-        _this.$.find(".Ldt-Annotation-Title").html(title || "(" + _this.l10n.untitled + ")");
+            description = currentAnnotation.description.replace(/(^\s+|\s+$)/g,''),
+            rx = (currentAnnotation.found ? (_this.source.getAnnotations().regexp || false) : false);
+        _this.$.find(".Ldt-Annotation-Title").html(IriSP.textFieldHtml(title,rx)  || "(" + _this.l10n.untitled + ")");
         if (description) {
             _this.$.find(".Ldt-Annotation-Description-Block").removeClass("Ldt-Annotation-EmptyBlock");
-            _this.$.find(".Ldt-Annotation-Description").html(description);
+            _this.$.find(".Ldt-Annotation-Description").html(IriSP.textFieldHtml(description,rx));
         } else {
             _this.$.find(".Ldt-Annotation-Description-Block").addClass("Ldt-Annotation-EmptyBlock");
         }
@@ -156,7 +151,7 @@
         this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), { type: "Social" }, "socialWidget");
     }
     
-    this.insertSubwidget(this.$.find(".Ldt-Annotation-Arrow"), { type: "Arrow" }, "arrow");
+    this.insertSubwidget(this.$.find(".Ldt-Annotation-Arrow"), { type: "Arrow", width: this.width }, "arrow");
     this.onMediaEvent("timeupdate",timeupdate);
     this.onMdpEvent("Annotation.hide","hide");
     this.onMdpEvent("Annotation.show","show");
--- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css	Wed Jan 23 18:14:24 2013 +0100
+++ b/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css	Fri Jan 25 18:17:18 2013 +0100
@@ -28,9 +28,6 @@
 .Ldt-AnnotationsList-li.selected {
     background-image: url(img/pinstripe-grey.png);
 }
-.Ldt-AnnotationsList-highlight {
-    background: #FFA0FC;
-}
 .Ldt-AnnotationsList-ThumbContainer {
     float: left;
     width: 80px;
@@ -57,14 +54,25 @@
     margin: 2px 2px 0 82px;
     font-weight: bold;
 }
-h3.Ldt-AnnotationsList-Title a {
+
+.Ldt-AnnotationsList-Title a {
     color: #0068c4;
 }
+
 p.Ldt-AnnotationsList-Description {
     margin: 2px 0 2px 82px;
     font-size: 12px;
     color: #333333;
 }
+
+.Ldt-AnnotationsList-Description a {
+    color: #0068c4;
+}
+
+.Ldt-AnnotationsList-Description a:hover {
+    text-decoration: underline; color: #800000;
+}
+
 ul.Ldt-AnnotationsList-Tags {
     list-style: none;
     padding: 0;
--- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js	Wed Jan 23 18:14:24 2013 +0100
+++ b/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js	Fri Jan 25 18:17:18 2013 +0100
@@ -71,9 +71,9 @@
     + '</div>'
     + '<div class="Ldt-AnnotationsList-Duration">{{begin}} - {{end}}</div>'
     + '<h3 class="Ldt-AnnotationsList-Title">'
-    + '<a href="{{url}}">{{title}}</a>'
+    + '<a href="{{url}}">{{{title}}}</a>'
     + '</h3>'
-    + '<p class="Ldt-AnnotationsList-Description">{{description}}</p>'
+    + '<p class="Ldt-AnnotationsList-Description">{{{description}}}</p>'
     + '{{#tags.length}}'
     + '<ul class="Ldt-AnnotationsList-Tags">'
     + '{{#tags}}'
@@ -202,8 +202,8 @@
             var _data = {
                 id : _annotation.id,
                 media_id : _annotation.getMedia().id,
-                title : _title,
-                description : _description,
+                title : IriSP.textFieldHtml(_title),
+                description : IriSP.textFieldHtml(_description),
                 begin : _annotation.begin.toString(),
                 end : _annotation.end.toString(),
                 thumbnail : typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail,
@@ -265,10 +265,11 @@
         });
         
         if (this.source.getAnnotations().searching) {
+            var rx = _this.source.getAnnotations().regexp || false;
             this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() {
                 var _$ = IriSP.jQuery(this);
-                _$.html(_$.text().replace(/(^\s+|\s+$)/g,'').replace(_this.source.getAnnotations().regexp, '<span class="Ldt-AnnotationsList-highlight">$1</span>'))
-            })
+                _$.html(IriSP.textFieldHtml(_$.text(), rx));
+            });
         }
     }
     
--- a/src/ldt/ldt/static/ldt/metadataplayer/CreateAnnotation.js	Wed Jan 23 18:14:24 2013 +0100
+++ b/src/ldt/ldt/static/ldt/metadataplayer/CreateAnnotation.js	Fri Jan 25 18:17:18 2013 +0100
@@ -149,7 +149,7 @@
     if (this.tag_titles && !this.tags) {
         this.tags = IriSP._(this.tag_titles).map(function(_tag_title) {
             var _tag,
-                _tags = _this.source.getTags().searchByTitle(_tag_title);
+                _tags = _this.source.getTags().searchByTitle(_tag_title, true);
             if (_tags.length) {
                 _tag = _tags[0];
             } else {
@@ -370,10 +370,11 @@
         this.recorder.stopRecord();
     }
     
-    var _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager), /* Création d'une liste d'annotations contenant une annotation afin de l'envoyer au serveur */
+    var _this = this,
+        _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager), /* Création d'une liste d'annotations contenant une annotation afin de l'envoyer au serveur */
         _export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}), /* Création d'un objet source utilisant un sérialiseur spécifique pour l'export */
         _annotation = new IriSP.Model.Annotation(false, _export), /* Création d'une annotation dans cette source avec un ID généré à la volée (param. false) */
-        _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type), /* Récupération du type d'annotation dans lequel l'annotation doit être ajoutée */
+        _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type, true), /* Récupération du type d'annotation dans lequel l'annotation doit être ajoutée */
         _annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)), /* Si le Type d'Annotation n'existe pas, il est créé à la volée */
         _url = Mustache.to_html(this.api_endpoint_template, {id: this.source.projectId}); /* Génération de l'URL à laquelle l'annotation doit être envoyée, qui doit inclure l'ID du projet */
     
@@ -400,8 +401,24 @@
     }
     _annotation.created = new Date(); /* Date de création de l'annotation */
     _annotation.description = this.$.find(".Ldt-CreateAnnotation-Description").val(); /* Champ description */
-    _annotation.setTags(this.$.find(".Ldt-CreateAnnotation-TagLi.selected")
-        .map(function() { return IriSP.jQuery(this).attr("tag-id")})); /*Liste des ids de tags */
+   
+    var tagIds = this.$.find(".Ldt-CreateAnnotation-TagLi.selected")
+        .map(function() { return IriSP.jQuery(this).attr("tag-id")});
+    
+    IriSP._(_annotation.description.match(/#[\w\d]+/g)).each(function(_tt) {
+        var _tag,
+            _tag_title = _tt.replace(/^#/,'')
+            _tags = _this.source.getTags().searchByTitle(_tag_title, true);
+        if (_tags.length) {
+            _tag = _tags[0];
+        } else {
+            _tag = new IriSP.Model.Tag(false, _this.source);
+            _tag.title = _tag_title;
+        }
+        tagIds.push(_tag.id);
+    })
+   
+    _annotation.setTags(IriSP._(tagIds).uniq()); /*Liste des ids de tags */
     if (this.audio_url) {
         _annotation.audio = {
             src: "mic",
--- a/src/ldt/ldt/static/ldt/metadataplayer/LdtPlayer-core.css	Wed Jan 23 18:14:24 2013 +0100
+++ b/src/ldt/ldt/static/ldt/metadataplayer/LdtPlayer-core.css	Fri Jan 25 18:17:18 2013 +0100
@@ -12,4 +12,8 @@
 /*    font-family: Arial, Helvetica, sans-serif; */
     color: black;
     font-size: 12px;
-}
\ No newline at end of file
+}
+
+.Ldt-Highlight {
+    background: #ffa0fc;
+}
--- a/src/ldt/ldt/static/ldt/metadataplayer/LdtPlayer-core.js	Wed Jan 23 18:14:24 2013 +0100
+++ b/src/ldt/ldt/static/ldt/metadataplayer/LdtPlayer-core.js	Fri Jan 25 18:17:18 2013 +0100
@@ -246,6 +246,79 @@
     }
 }
 
+IriSP.textFieldHtml = function(_text, _regexp, _extend) {
+    var list = [],
+        positions = [],
+        text = _text.replace(/(^\s+|\s+$)/g,'');
+    
+    function addToList(_rx, _startHtml, _endHtml) {
+        while(true) {
+            var result = _rx.exec(text);
+            if (!result) {
+                break;
+            }
+            var end = _rx.lastIndex,
+                start = result.index;
+            list.push({
+                start: start,
+                end: end,
+                startHtml: (typeof _startHtml === "function" ? _startHtml(result) : _startHtml),
+                endHtml: (typeof _endHtml === "function" ? _endHtml(result) : _endHtml)
+            });
+            positions.push(start);
+            positions.push(end);
+        }
+    }
+    
+    if (_regexp) {
+        addToList(_regexp, '<span class="Ldt-Highlight">', '</span>');
+    }
+    
+    addToList(/(https?:\/\/)?\w+\.\w+\S+/gm, function(matches) {
+        return '<a href="' + (matches[1] ? '' : 'http://') + matches[0] + '" target="_blank">'
+    }, '</a>');
+    addToList(/@([\d\w]{1,15})/gm, function(matches) {
+        return '<a href="http://twitter.com/' + matches[1] + '" target="_blank">'
+    }, '</a>');
+    addToList(/\*[^*]+\*/gm, '<b>', '</b>');
+    addToList(/[\n\r]+/gm, '', '<br />');
+    
+    IriSP._(_extend).each(function(x) {
+        addToList.apply(null, x);
+    });
+    
+    positions = IriSP._(positions)
+        .chain()
+        .uniq()
+        .sortBy(function(p) { return parseInt(p) })
+        .value();
+    
+    var res = "", lastIndex = 0;
+    
+    for (var i = 0; i < positions.length; i++) {
+        var pos = positions[i];
+        res += text.substring(lastIndex, pos);
+        for (var j = list.length - 1; j >= 0; j--) {
+            var item = list[j];
+            if (item.start < pos && item.end >= pos) {
+                res += item.endHtml;
+            }
+        }
+        for (var j = 0; j < list.length; j++) {
+            var item = list[j];
+            if (item.start <= pos && item.end > pos) {
+                res += item.startHtml;
+            }
+        }
+        lastIndex = pos;
+    }
+    
+    res += text.substring(lastIndex);
+    
+    return res;
+    
+}
+
 IriSP.log = function() {
     if (typeof console !== "undefined" && typeof IriSP.logging !== "undefined" && IriSP.logging) {
         console.log.apply(console, arguments);
@@ -272,11 +345,12 @@
     var uidbase = rand16(8) + "-" + rand16(4) + "-", uidincrement = Math.floor(Math.random()*0x10000);
     
     var charsub = [
-        [ 'a', 'á', 'à', 'â', 'ä' ],
-        [ 'c', 'ç' ],
-        [ 'e', 'é', 'è', 'ê', 'ë' ],
-        [ 'i', 'í', 'ì', 'î', 'ï' ],
-        [ 'o', 'ó', 'ò', 'ô', 'ö' ]
+        '[aáàâä]',
+        '[cç]',
+        '[eéèêë]',
+        '[iíìîï]',
+        '[oóòôö]',
+        '[uùûü]'
     ];
     
     var removeChars = [
@@ -324,10 +398,7 @@
             remrx = new RegExp(remsrc,"gm"),
             txt = _text.toLowerCase().replace(remrx,"")
             res = [],
-            charsrc = ns._(charsub).map(function(c) {
-                return "(" + c.join("|") + ")";
-            }),
-            charsrx = ns._(charsrc).map(function(c) {
+            charsrx = ns._(charsub).map(function(c) {
                 return new RegExp(c);
             }),
             src = "";
@@ -336,7 +407,7 @@
                 src += remsrc + "*";
             }
             var l = txt[j];
-            ns._(charsrc).each(function(v, k) {
+            ns._(charsub).each(function(v, k) {
                 l = l.replace(charsrx[k], v);
             });
             src += l;
@@ -476,7 +547,7 @@
  */
 Model.List.prototype.searchByTitle = function(_text, _iexact) {
     var _iexact = _iexact || false,
-        _rgxp = Model.regexpFromTextOrArray(_text, true);
+        _rgxp = Model.regexpFromTextOrArray(_text, true, _iexact);
     return this.filter(function(_element) {
         return _rgxp.test(_element.title);
     });
@@ -484,7 +555,7 @@
 
 Model.List.prototype.searchByDescription = function(_text, _iexact) {
     var _iexact = _iexact || false,
-        _rgxp = Model.regexpFromTextOrArray(_text, true);
+        _rgxp = Model.regexpFromTextOrArray(_text, true, _iexact);
     return this.filter(function(_element) {
         return _rgxp.test(_element.description);
     });
@@ -492,7 +563,7 @@
 
 Model.List.prototype.searchByTextFields = function(_text, _iexact) {
     var _iexact = _iexact || false,
-        _rgxp =  Model.regexpFromTextOrArray(_text, true);
+        _rgxp =  Model.regexpFromTextOrArray(_text, true, _iexact);
     return this.filter(function(_element) {
         var keywords = (_element.keywords || _element.getTagTexts() || []).join(", ");
         return _rgxp.test(_element.description) || _rgxp.test(_element.title) || _rgxp.test(keywords);
@@ -1072,17 +1143,6 @@
 
 Model.Mashup.prototype = new Model.Playable();
 
-Model.Mashup.prototype.checkLoaded = function() {
-    var loaded = !!this.segments.length;
-    this.getMedias().forEach(function(_m) {
-        loaded = loaded && _m.loaded;
-    });
-    this.loaded = loaded;
-    if (loaded) {
-        this.trigger("loadedmetadata");
-    }
-}
-
 Model.Mashup.prototype.updateTimes = function() {
     var _time = 0;
     this.segments.forEach(function(_segment) {
@@ -1450,6 +1510,9 @@
 return Model;
 
 })(IriSP);
+
+/* END model.js */
+
 IriSP.language = 'en';
 
 IriSP.libFiles = {
@@ -1595,8 +1658,10 @@
        _this[_key] = _value;
     });
     
+    this.$ = IriSP.jQuery('#' + this.container);
+    
     if (typeof this.width === "undefined") {
-        this.width = player.config.width;
+        this.width = this.$.width();
     }
     
     /* Setting this.player at the end in case it's been overriden
@@ -1605,7 +1670,6 @@
     this.player = player;
     
     /* Adding classes and html attributes */
-    this.$ = IriSP.jQuery('#' + this.container);
     this.$.addClass("Ldt-TraceMe Ldt-Widget").attr("widget-type", _type);
     
     this.l10n = (
--- a/src/ldt/ldt/static/ldt/metadataplayer/MultiSegments.js	Wed Jan 23 18:14:24 2013 +0100
+++ b/src/ldt/ldt/static/ldt/metadataplayer/MultiSegments.js	Fri Jan 25 18:17:18 2013 +0100
@@ -79,7 +79,8 @@
                 line.segmentWidget,
                 IriSP._({
                     type: "Segments",
-                    annotation_type: _anntype
+                    annotation_type: _anntype,
+                    width: _this.width
                 }).extend(segmentsopts)
             );
             
@@ -87,7 +88,8 @@
                 line.annotationWidget,
                 IriSP._({
                     type: "Annotation",
-                    annotation_type: _anntype
+                    annotation_type: _anntype,
+                    width: _this.width
                 }).extend(annotationopts)
             );
             
--- a/src/ldt/ldt/static/ldt/metadataplayer/Slideshare.js	Wed Jan 23 18:14:24 2013 +0100
+++ b/src/ldt/ldt/static/ldt/metadataplayer/Slideshare.js	Fri Jan 25 18:17:18 2013 +0100
@@ -9,16 +9,14 @@
 IriSP.Widgets.Slideshare.prototype.defaults = {
     annotation_type: "slide",
     sync: true,
-    embed_width: 400,
-    embed_height: 300
 }
 
 IriSP.Widgets.Slideshare.prototype.messages = {
     fr: {
-        slides_ : "Diapositives&nbsp;:"
+        slides_ : "Diapositives"
     },
     en: {
-        slides_ : "Slides:"
+        slides_ : "Slides"
     }
 }
 
@@ -27,14 +25,9 @@
 
 IriSP.Widgets.Slideshare.prototype.draw = function() {
     
-    var _embedObject = null,
-        $container,
-        _lastEmbedded = "",
-        _this = this;
-    
     function insertSlideshare(_presentation, _slide) {
         if (_lastEmbedded === _presentation) {
-            if (_.embedObject && typeof _embedObject.jumpTo === "function") {
+            if (_embedObject && typeof _embedObject.jumpTo === "function") {
                 _embedObject.jumpTo(parseInt(_slide));
             }
         } else {
@@ -75,8 +68,13 @@
         var _lastPres = "",
             _embedObject = null,
             _oembedCache = {},
-            _this = this;
-        $container = this.$.find(".Ldt-SlideShare-Container");
+            _lastEmbedded = "",
+            _this = this
+            $container = this.$.find(".Ldt-SlideShare-Container");
+            
+        this.embed_width = this.embed_width || $container.innerWidth();
+        this.embed_height = this.embed_height || Math.floor(this.embed_width * 3/4);
+        
         _annotations.forEach(function(_a) {
             _a.on("leave", function() {
                 $container.hide();
--- a/src/ldt/ldt/static/ldt/metadataplayer/Tweet.js	Wed Jan 23 18:14:24 2013 +0100
+++ b/src/ldt/ldt/static/ldt/metadataplayer/Tweet.js	Fri Jan 25 18:17:18 2013 +0100
@@ -93,83 +93,44 @@
 
 IriSP.Widgets.Tweet.prototype.show = function(_tweet) {
     if (typeof _tweet !== "undefined" && typeof _tweet.source !== "undefined") {
-        var _entities = [];
-        for (var _i = 0; _i < _tweet.source.entities.hashtags.length; _i++) {
-            var _hash = _tweet.source.entities.hashtags[_i];
-            _entities.push({
-                is_link: true,
-                text: '#' + _hash.text,
-                url: 'http://twitter.com/search?q=%23' + encodeURIComponent(_hash.text),
-                indices: _hash.indices
-            });
-        }
-        for (var _i = 0; _i < _tweet.source.entities.urls.length; _i++) {
-            var _url = _tweet.source.entities.urls[_i],
-                _displayurl = (typeof _url.display_url !== "undefined" && _url.display_url !== null ? _url.display_url : _url.url),
-                _linkurl = (typeof _url.expanded_url !== "undefined" && _url.expanded_url !== null ? _url.expanded_url : _url.url);
-            _displayurl = _displayurl.replace(/^\w+:\/\//,'');
-            if (!/^\w+:\/\//.test(_linkurl)) {
-                _linkurl = 'http://' + _linkurl;
-            }
-            _entities.push({
-                is_link: true,
-                text: _displayurl,
-                url: _linkurl,
-                indices: _url.indices
-            });
-        }
-        for (var _i = 0; _i < _tweet.source.entities.user_mentions.length; _i++) {
-            var _user = _tweet.source.entities.user_mentions[_i];
-            _entities.push({
-                is_link: true,
-                text: '@' + _user.screen_name,
-                url: 'http://twitter.com/' + encodeURIComponent(_user.screen_name),
-                indices: _user.indices
-            });
-        }
-        for (var _i = 0; _i < this.polemics.length; _i++) {
-            for (var _j = 0; _j < this.polemics[_i].keywords.length; _j++) {
-                var _p = _tweet.source.text.indexOf(this.polemics[_i].keywords[_j]);
-                while (_p !== -1) {
-                    var _end = (_p + this.polemics[_i].keywords[_j].length);
-                    _entities.push({
-                        is_link: false,
-                        text: this.polemics[_i].keywords[_j],
-                        color: this.polemics[_i].color,
-                        indices: [_p, _end]
-                    });
-                    _p = _tweet.source.text.indexOf(this.polemics[_i].keywords[_j], _end);
-                }
-            }
-        }
-        _entities = IriSP._(_entities).sortBy(function(_entity) {
+        var extend = [
+            [
+                /#(\w+)/gm,
+                function(matches) {
+                    return '<a href="http://twitter.com/search?q=%23' + matches[1] + '" target="_blank">'
+                },
+                '</a>'
+            ]
+        ];
+        var _urls = IriSP._(_tweet.source.entities.urls).sortBy(function(_entity) {
             return _entity.indices[0];
         });
+        
         var _currentPos = 0,
             _txt = '';
-        for (var _i = 0; _i < _entities.length; _i++) {
-            if (_entities[_i].indices[0] >= _currentPos) {
-                _txt += _tweet.source.text.substring(_currentPos, _entities[_i].indices[0]);
-                _currentPos = _entities[_i].indices[1];
-                if (_entities[_i].is_link) {
-                    _txt += '<a href="' + _entities[_i].url + '" target="_blank">';
-                } else {
-                    _txt += '<span style="background:' + _entities[_i].color + '">';
-                }
-                _txt += _entities[_i].text;
-                if (_entities[_i].is_link) {
-                    _txt += '</a>';
-                } else {
-                    _txt += '</span>';
-                }
+        IriSP._(_urls).each(function(_url) {
+            if (_url.indices[0] >= _currentPos) {
+                _txt += _tweet.source.text.substring(_currentPos, _url.indices[0]);
+                _txt += (typeof _url.expanded_url !== "undefined" && _url.expanded_url !== null ? _url.expanded_url : _url.url);
+                _currentPos = _url.indices[1];
             }
+        });
+        _txt += _tweet.source.text.substring(_currentPos);
+        
+        for (var _i = 0; _i < this.polemics.length; _i++) {
+            var rx = IriSP.Model.regexpFromTextOrArray(this.polemics[_i].keywords);
+            extend.push([
+                rx,
+                '<span style="background: ' + this.polemics[_i].color + '">',
+                '</span>'
+            ]);
         }
-        _txt += _tweet.source.text.substring(_currentPos);
+        var rx = (_tweet.found ? (_this.source.getAnnotations().regexp || false) : false);
         this.$.find(".Ldt-Tweet-Avatar").attr("src",_tweet.source.user.profile_image_url);
         this.$.find(".Ldt-Tweet-ScreenName").html('@'+_tweet.source.user.screen_name);
         this.$.find(".Ldt-Tweet-ProfileLink").attr("href", "https://twitter.com/" + _tweet.source.user.screen_name);
         this.$.find(".Ldt-Tweet-FullName").html(_tweet.source.user.name);
-        this.$.find(".Ldt-Tweet-Contents").html(_txt);
+        this.$.find(".Ldt-Tweet-Contents").html(IriSP.textFieldHtml(_txt, rx, extend));
         this.$.find(".Ldt-Tweet-Time").html(this.l10n.original_time + new Date(_tweet.source.created_at).toLocaleTimeString() + " / " + this.l10n.video_time + _tweet.begin.toString());
         this.$.find(".Ldt-Tweet-Retweet").attr("href", "https://twitter.com/intent/retweet?tweet_id=" + _tweet.source.id_str);
         this.$.find(".Ldt-Tweet-Reply").attr("href", "https://twitter.com/intent/tweet?in_reply_to=" + _tweet.source.id_str);