crea/integration/generator.html
changeset 2 44deeff592e2
child 15 f1d070549d94
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/crea/integration/generator.html	Thu May 31 14:45:36 2012 +0200
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html lang="fr">
+    <head>
+        <meta charset="utf-8" />
+        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
+        <title>Musitag - Futur en Seine 2012</title>
+        <link rel="stylesheet" type="text/css" href="css/musitag.css" />
+        <script type="text/javascript" src="libs/underscore-min.js"></script>
+        <script type="text/javascript" src="metadataplayer/LdtPlayer-core.js"></script>
+
+    </head>
+    <body>
+ 
+    <script type="text/javascript">
+    
+    IriSP._ = _;
+    
+    var _directory = new IriSP.Model.Directory(),
+        _source = _directory.newLocalSource({
+            serializer: IriSP.serializers.ldt
+        }),
+        _mediaList = new IriSP.Model.List(_directory),
+        _annotationList = new IriSP.Model.List(_directory),
+        _tagList = new IriSP.Model.List(_directory),
+        _annotationTypeList = new IriSP.Model.List(_directory),
+        _colors = ['red','yellow','green','blue'],
+        _emoticons = ['happy','unhappy','laughing','surprised'],
+        _alltags = _colors.concat(_emoticons),
+        _duration = 147000;
+    
+    
+    var _media = new IriSP.Model.Media('au-clair-de-la-lune',_source);
+    _media.video = 'media/wari_0710.mp3';
+    _media.setDuration(_duration);
+    _media.title = "Au Clair de La Lune";
+    _media.description = "Steve Waring";
+    _mediaList.push(_media);
+    
+    var _annotationType = new IriSP.Model.Media('musitag',_source);
+    _annotationType.title = "Musitag";
+    _annotationType.description = "Une couleur + une émotion, déposés par Musitag";
+    _annotationTypeList.push(_annotationType);
+    
+    _alltags.forEach(function(_name) {
+        var _tag = new IriSP.Model.Tag(_name, _source);
+        _tag.title = _name;
+        _tagList.push(_tag);
+    });
+    
+    for (var _i = 0; _i < 50; _i++) {
+        var _time = Math.floor(_duration * Math.random()),
+            _color = _colors[Math.floor(4*Math.random())],
+            _emoticon = _emoticons[Math.floor(4*Math.random())],
+            _annotation = new IriSP.Model.Annotation('annotation-'+_i,_source);
+        _annotation.setTags([_color,_emoticon]);
+        _annotation.setBegin(_time);
+        _annotation.setEnd(_time);
+        _annotation.setAnnotationType('musitag');
+        _annotation.setMedia('au-clair-de-la-lune');
+        _annotation.created = new Date();
+        _annotation.creator = "Math.random()";
+        _annotation.description = _color + " " + _emoticon;
+        _annotationList.push(_annotation);
+    }
+    
+    _source.addList('media',_mediaList);
+    _source.addList('tag',_tagList);
+    _source.addList('annotationType',_annotationTypeList);
+    _source.addList('annotation',_annotationList);
+    
+    console.log(_source);
+    console.log(_source.serialize());
+    </script>
+    </body>
+</html>