crea/integration/metadataplayer/MusitagAnnotations.js
changeset 54 402fad4d9495
parent 40 02960e91525d
child 56 af969d762e03
--- a/crea/integration/metadataplayer/MusitagAnnotations.js	Mon Jun 11 12:23:53 2012 +0200
+++ b/crea/integration/metadataplayer/MusitagAnnotations.js	Mon Jun 11 15:09:37 2012 +0200
@@ -8,11 +8,11 @@
     '<div class="Musitag-Annotations-Main"></div><div id="Musitag-Annotations-Audioplayer"></div>';
     
 IriSP.Widgets.MusitagAnnotations.prototype.annotation_template =
-    '<div class="Musitag-Annotations-tag" begin-time="{{begin}}">'
+    '<div class="Musitag-Annotations-tag" begin-time="{{begin.milliseconds}}" title="{{color.name}}, {{emoticon.name}} à {{begin}}">'
     + '<div class="Musitag-container-50">'
     + '<div class="Musitag-shadow"></div>'
-    + '<div class="Musitag-color Musitag-{{color_tag}}"></div>'
-    + '<div class="Musitag-emoticon Musitag-{{emoticon_tag}}"></div>'
+    + '<div class="Musitag-color Musitag-{{color.tag}}"></div>'
+    + '<div class="Musitag-emoticon Musitag-{{emoticon.tag}}"></div>'
     + '</div>{{#audio}}<div class="Musitag-Annotations-Balloon" audio-url="{{audio.href}}"></div>{{/audio}}'
     + '</div>';
 
@@ -20,8 +20,18 @@
     annotation_type: false,
     columns: 15,
     max_by_column: 10,
-    emoticons: ['happy', 'unhappy', 'laughing', 'surprised'],
-    colors: ['red', 'yellow', 'green', 'blue'],
+    emoticons: [
+        { tag: "happy", name: "content"},
+        { tag: "unhappy", name: "mécontent"},
+        { tag: "laughing", name: "rigolard"},
+        { tag: "surprised", name: "étonné"}
+    ],
+    colors: [
+        { tag: "red", name: "rouge"},
+        { tag: "yellow", name: "jaune"},
+        { tag: "green", name: "vert"},
+        { tag: "blue", name: "bleu"}
+    ],
     rtmp_streamer: "rtmp://media.iri.centrepompidou.fr/ddc_micro_record/"
 };
 
@@ -71,15 +81,15 @@
         _this = this;
     _annotations.forEach(function(_annotation) {
         var _tags = _annotation.getTagTexts();
-        _annotation.color_tag = false;
-        _annotation.emoticon_tag = false;
-        _tags.forEach(function(_tag) {
-            if (_this.emoticons.indexOf(_tag) != -1) {
-                _annotation.emoticon_tag = _tag;
-            }
-            if (_this.colors.indexOf(_tag) != -1) {
-                _annotation.color_tag = _tag;
-            }
+        _annotation.emoticon = IriSP._(_this.emoticons).find(function(_emoticon) {
+            return IriSP._(_tags).find(function(_tag) {
+                return _tag == _emoticon.tag;
+            });
+        });
+        _annotation.color = IriSP._(_this.colors).find(function(_color) {
+            return IriSP._(_tags).find(function(_tag) {
+                return _tag == _color.tag;
+            });
         });
     });
     for (var i = 0; i < this.columns; i++) {
@@ -88,8 +98,8 @@
             _column = _annotations.filter(function(_annotation) {
                 return _annotation.begin >= _sliceStart
                     && _annotation.begin < _sliceEnd
-                    && _annotation.emoticon_tag
-                    && _annotation.color_tag
+                    && _annotation.emoticon
+                    && _annotation.color
             }).sortBy(function(_annotation) {
                 return _annotation.created;
             });