integration/js/editor.js
changeset 43 5a5024bc74e6
parent 42 40909e8d6855
child 45 f39df810caab
equal deleted inserted replaced
42:40909e8d6855 43:5a5024bc74e6
     8     delete_segment: "Supprimer le segment",
     8     delete_segment: "Supprimer le segment",
     9     clone_segment: "Cloner le segment",
     9     clone_segment: "Cloner le segment",
    10     From_: "De :",
    10     From_: "De :",
    11     to_: "à :",
    11     to_: "à :",
    12     segment_title_placeholder: "Segment sans titre",
    12     segment_title_placeholder: "Segment sans titre",
    13     mashup_title_placeholder: "Hashcut sans titre"
    13     mashup_title_placeholder: "Hashcut sans titre",
       
    14     copy_of_: "Copie de ",
    14 }
    15 }
    15 
    16 
    16 IriSP.editor = function(options) {
    17 IriSP.editor = function(options) {
    17     
    18     
    18     /* Load Media List */
    19     /* Load Media List */
    22         project = directory.remoteSource({
    23         project = directory.remoteSource({
    23             url: options.url,
    24             url: options.url,
    24             serializer: IriSP.serializers.medialist
    25             serializer: IriSP.serializers.medialist
    25         }),
    26         }),
    26         mashup = new IriSP.Model.Mashup(false, project),
    27         mashup = new IriSP.Model.Mashup(false, project),
    27         mediatemplate = _.template('<li class="item-video media" data-media-id="<%= id %>"><img src="<%= thumbnail %>" alt="<%= title %>" />'
    28         mediatemplate = _.template('<li class="item-video media" data-media-id="<%= id %>"><div class="media-count-wrap"><span class="media-count"></span></div>'
    28             + '<span class="video-info"><span class="title-video"><%= title %></span><span class="author"><%= description %></span>'
    29             + '<img src="<%= thumbnail %>" alt="<%= title %>" />'
    29             + '<span class="time-length"><%= IriSP.hc_messages.Duration_ %> <span><%= duration.toString() %></span></span></span></li>'),
    30             + '<div class="video-info"><h3 class="title-video"><%= title %></h3><p class="description"><%= description %></p>'
       
    31             + '<p class="time-length"><%= IriSP.hc_messages.Duration_ %> <span><%= duration.toString() %></span></p></div></li>'),
    30         segmenttemplate = _.template('<li class="item-video annotation" data-segment-id="<%= annotation.id %>" data-media-id="<%= annotation.getMedia().id %>">'
    32         segmenttemplate = _.template('<li class="item-video annotation" data-segment-id="<%= annotation.id %>" data-media-id="<%= annotation.getMedia().id %>">'
    31             + '<img src="<%= annotation.getMedia().thumbnail %>" alt="<%= annotation.getMedia().title %>" />'
    33             + '<img src="<%= annotation.thumbnail %>" alt="<%= annotation.getMedia().title %>" />'
    32             + '<div class="validate <%= annotation.status %>"><div class="validate-tooltip"><ul><li><%= annotation.status_messages.join("</li><li>") %></li></ul></div></div><span class="video-info"><span class="title-video"><%= annotation.getMedia().title %></span>'
    34             + '<div class="validate <%= annotation.status %>"><div class="validate-tooltip"><ul><li><%= annotation.status_messages.join("</li><li>") %></li></ul></div></div><div class="video-info"><h3 class="title-video"><%= annotation.getMedia().title %></h3>'
    33             + '<span class="subtitle"><%= annotation.title %></span><span class="duration"><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)</span>'
    35             + '<p class="subtitle"><%= annotation.title %></p><p class="duration"><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)</p>'
    34             + '<ul class="tools"><li><a class="edit" href="#" title="<%= IriSP.hc_messages.edit_segment %>"></a></li><li><a class="bottom" href="#" title="<%= IriSP.hc_messages.segment_down %>"></a></li>'
    36             + '<ul class="tools"><li><a class="edit" href="#" title="<%= IriSP.hc_messages.edit_segment %>"></a></li><li><a class="bottom" href="#" title="<%= IriSP.hc_messages.segment_down %>"></a></li>'
    35             + '<li><a class="top" href="#" title="<%= IriSP.hc_messages.segment_up %>"></a></li><li><a class="delete" href="#" title="<%= IriSP.hc_messages.delete_segment %>"></a></li></ul></span></li>'),
    37             + '<li><a class="top" href="#" title="<%= IriSP.hc_messages.segment_up %>"></a></li><li><a class="delete" href="#" title="<%= IriSP.hc_messages.delete_segment %>"></a></li></ul></div></li>'),
    36         mediasegmenttemplate = _.template('<div class="media-segments-list"><div class="media-segment">'
    38         mediasegmenttemplate = _.template('<div class="media-segments-list"><div class="media-segment">'
    37             + '<div class="media-section media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= annotation.color %>"></div>'
    39             + '<div class="media-section media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= color %>"></div>'
    38             + '<div class="media-section media-current-section" style="left:<%= currentleft %>px; width:<%= currentwidth %>px;"><div class="media-current-section-inner"></div></div>'
    40             + '<div class="media-section media-current-section" style="left:<%= currentleft %>px; width:<%= currentwidth %>px;"><div class="media-current-section-inner"></div></div>'
    39             + '<div class="popin media-segment-popin" style="left:<%= popleft %>px"><img style="left:<%= pointerpos %>px;" class="pointer" src="img/popin-triangle.png" alt="" /><div class="popin-content">'
    41             + '<div class="popin media-segment-popin" style="left:<%= popleft %>px"><img style="left:<%= pointerpos %>px;" class="pointer" src="img/popin-triangle.png" alt="" /><div class="popin-content">'
    40             + '<h3><%= annotation.title %></h3><a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>"><%= IriSP.hc_messages.clone_segment %></a>'
    42             + '<h3><%= annotation.title %></h3><a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>"><%= IriSP.hc_messages.clone_segment %></a>'
    41             + '<p><%= IriSP.hc_messages.From_ %> <span><%= annotation.begin.toString() %></span> <%= IriSP.hc_messages.to_ %> <span><%= annotation.end.toString() %></span> (<%= IriSP.hc_messages.duration_ %> <span><%= annotation.getDuration().toString() %></span>)</p>'
    43             + '<p><%= IriSP.hc_messages.From_ %> <span><%= annotation.begin.toString() %></span> <%= IriSP.hc_messages.to_ %> <span><%= annotation.end.toString() %></span> (<%= IriSP.hc_messages.duration_ %> <span><%= annotation.getDuration().toString() %></span>)</p>'
    42             + '</div></div></div></div>'),
    44             + '</div></div></div></div>'),
       
    45         mashupstatus = '',
    43         addMode, currentMedia, currentSegment;
    46         addMode, currentMedia, currentSegment;
    44     
    47     
    45     IriSP.mashupcore(project, mashup);
    48     IriSP.mashupcore(project, mashup);
    46     
    49     
    47     /* Validation of segments and mashup */
    50     /* Validation of segments and mashup */
   110         var html = '';
   113         var html = '';
   111         project.getMedias().forEach(function(_m) {
   114         project.getMedias().forEach(function(_m) {
   112             html += mediatemplate(_m);
   115             html += mediatemplate(_m);
   113         });
   116         });
   114         $(".col-left .list-video").html(html);
   117         $(".col-left .list-video").html(html);
       
   118         project.getMedias().forEach(function(_m) {
       
   119 /*            var dataType = (IriSP.Model.isLocalURL(options.segment_api_endpoint) ? "json" : "jsonp");
       
   120             $.ajax({
       
   121                 url: ,
       
   122                 dataType: dataType,
       
   123                 data: {
       
   124                     format: dataType,
       
   125                     iri_id: _m.id
       
   126                 },
       
   127                 success: function(data) {
       
   128                     console.log(data);
       
   129                     if (data.objects && data.objects.length) {
       
   130                         var mediaid = data.objects[0].iri_id;
       
   131                         mediasegmentscache[mediaid] = data.objects;
       
   132                        if (currentMedia && mediaid === currentMedia.id && currentSegment) {
       
   133                             showOtherSegments();
       
   134                         }
       
   135                     }
       
   136                 }
       
   137             }); */
       
   138             apidirectory.remoteSource({
       
   139                 url: options.segment_api_endpoint,
       
   140                 url_params: {
       
   141                     iri_id: _m.id,
       
   142                     limit: 0
       
   143                 },
       
   144                 serializer: IriSP.serializers.segmentapi
       
   145             }).onLoad(function() {
       
   146                 var medias = this.getMedias(),
       
   147                     annotations = this.getAnnotations();
       
   148                 if (medias && medias.length) {
       
   149                     var mediaid = medias[0].id;
       
   150                     el = $(".item-video[data-media-id='" + mediaid + "'] .media-count");
       
   151                     el.text(annotations.length).parent().show();
       
   152                     mediasegmentscache[mediaid] = annotations;
       
   153                     if (currentMedia && mediaid === currentMedia.id && currentSegment) {
       
   154                         showOtherSegments();
       
   155                     }
       
   156                 }
       
   157             });
       
   158         });
   115     });
   159     });
   116     
   160     
   117     /* Search Media with left column form */
   161     /* Search Media with left column form */
   118     
   162     
   119     $(".col-left input").on("keyup change input paste", function() {
   163     $(".col-left input").on("keyup change input paste", function() {
   168         });
   212         });
   169         mashup.status = critical ? "critical" : (warning ? "warning" : "valid");
   213         mashup.status = critical ? "critical" : (warning ? "warning" : "valid");
   170         if (!messages.length) {
   214         if (!messages.length) {
   171             messages.push("Le hashcut est valide !");
   215             messages.push("Le hashcut est valide !");
   172         }
   216         }
       
   217         mashupstatus = ' - ' + messages.join('\n - ');
       
   218         
   173         $(".publier-button").toggleClass("disable", critical);
   219         $(".publier-button").toggleClass("disable", critical);
   174         
   220         
   175         $(".liste-segment .validate").removeClass("critical warning valid").addClass(mashup.status);
   221         $(".liste-segment .validate").removeClass("critical warning valid").addClass(mashup.status);
   176         $(".liste-segment .validate-tooltip").html("<ul><li>" + messages.join("</li><li>")+"</li></ul>");
   222         $(".liste-segment .validate-tooltip").html("<ul><li>" + messages.join("</li><li>")+"</li></ul>");
   177         
   223         
   299                 currentSegment.setMedia(currentMedia.id);
   345                 currentSegment.setMedia(currentMedia.id);
   300                 currentSegment.setBegin(0);
   346                 currentSegment.setBegin(0);
   301                 currentSegment.setEnd(currentMedia.duration);
   347                 currentSegment.setEnd(currentMedia.duration);
   302                 currentSegment.title = IriSP.hc_messages.segment_title_placeholder;
   348                 currentSegment.title = IriSP.hc_messages.segment_title_placeholder;
   303                 currentSegment.color = currentMedia.color;
   349                 currentSegment.color = currentMedia.color;
       
   350                 currentSegment.thumbnail = currentMedia.thumbnail;
   304                 currentSegment.created = new Date();
   351                 currentSegment.created = new Date();
   305                 currentSegment.keywords = [];
   352                 currentSegment.keywords = [];
   306                 currentSegment.description = "";
   353                 currentSegment.description = "";
   307                 currentSegment.on("change-begin", function() {
   354                 currentSegment.on("change-begin", function() {
   308                     if (currentMedia && currentSegment === this) {
   355                     if (currentMedia && currentSegment === this) {
   337             updateSegmentUI();
   384             updateSegmentUI();
   338             var relatedSegments = mashup.segments.filter(function(_s) {
   385             var relatedSegments = mashup.segments.filter(function(_s) {
   339                 return _s.getMedia() === currentMedia && _s.annotation !== currentSegment;
   386                 return _s.getMedia() === currentMedia && _s.annotation !== currentSegment;
   340             });
   387             });
   341             var html = "",
   388             var html = "",
   342                 k = $(".Ldt-Slider").width() / currentSegment.getMedia().duration,
   389                 k = $(".Ldt-Slider").width() / currentMedia.duration,
   343                 currentleft = k * currentSegment.begin,
   390                 currentleft = k * currentSegment.begin,
   344                 currentwidth = k * currentSegment.getDuration();
   391                 currentwidth = k * currentSegment.getDuration();
   345             if (relatedSegments.length) {
   392             if (relatedSegments.length) {
   346                 relatedSegments.forEach(function(_s) {
   393                 relatedSegments.forEach(function(_s) {
   347                     var pos = k * (_s.annotation.begin + _s.annotation.end) / 2,
   394                     var pos = k * (_s.annotation.begin + _s.annotation.end) / 2,
   360                 $(".self-media-segments").show();
   407                 $(".self-media-segments").show();
   361             } else {
   408             } else {
   362                 $(".self-media-segments").hide();
   409                 $(".self-media-segments").hide();
   363             }
   410             }
   364             $(".self-media-segments .media-segments-list").html(html);
   411             $(".self-media-segments .media-segments-list").html(html);
   365             
   412             showOtherSegments();
   366             $(".other-media-segments").hide();
   413             project.trigger("mouseout-annotation");
   367             apidirectory.remoteSource({
       
   368                 url: options.segment_api_endpoint + currentMedia.id + "/0/" + currentMedia.duration.milliseconds + "?format=json",
       
   369                 serializer:  IriSP.serializers.ldt
       
   370             }).onLoad(function() {
       
   371                 var medias = this.getMedias(),
       
   372                     annotations = this.getAnnotations();
       
   373                 if (medias && medias.length && medias[0].id === currentMedia.id && annotations && annotations.length ) {
       
   374                     var html = "";
       
   375                     annotations.forEach(function(_a) {
       
   376                         var pos = k * (_a.begin + _a.end) / 2,
       
   377                             corrpos = Math.max(145, Math.min(305, pos));
       
   378                         vizdata = {
       
   379                             annotation : _a,
       
   380                             currentleft : currentleft,
       
   381                             currentwidth : currentwidth,
       
   382                             popleft : corrpos,
       
   383                             left : k * _a.begin,
       
   384                             width : k * _a.getDuration(),
       
   385                             pointerpos : (pos - corrpos)
       
   386                         }
       
   387                         html += mediasegmenttemplate(vizdata);
       
   388                     });
       
   389                     $(".other-media-segments").show();
       
   390                     $(".other-media-segments .media-segments-list").html(html);
       
   391                 }
       
   392             });
       
   393         }
   414         }
   394         if (currentMedia.elementType === "mashup") {
   415         if (currentMedia.elementType === "mashup") {
   395             showPreview();
   416             showPreview();
   396         }
   417         }
   397     }
   418     }
   398         
   419     
       
   420     /* Show Related Segments */
       
   421     
       
   422     function showOtherSegments() {
       
   423         var annotations = mediasegmentscache[currentMedia.id]
       
   424         if (annotations && annotations.length) {
       
   425             var html = "",
       
   426                 k = $(".Ldt-Slider").width() / currentMedia.duration,
       
   427                 currentleft = k * currentSegment.begin,
       
   428                 currentwidth = k * currentSegment.getDuration();
       
   429             annotations.forEach(function(_a) {
       
   430                 var pos = k * (_a.begin + _a.end) / 2,
       
   431                     corrpos = Math.max(145, Math.min(305, pos));
       
   432                 vizdata = {
       
   433                     annotation : _a,
       
   434                     currentleft : currentleft,
       
   435                     currentwidth : currentwidth,
       
   436                     popleft : corrpos,
       
   437                     left : k * _a.begin,
       
   438                     width : k * _a.getDuration(),
       
   439                     pointerpos : (pos - corrpos),
       
   440                     color: currentMedia.color
       
   441                 }
       
   442                 html += mediasegmenttemplate(vizdata);
       
   443             });
       
   444             $(".other-media-segments").show();
       
   445             $(".other-media-segments .media-segments-list").html(html);
       
   446         }
       
   447         else {
       
   448             $(".other-media-segments").hide();
       
   449             $(".other-media-segments .media-segments-list").html("");
       
   450         }
       
   451      }
       
   452     /* Set In, Out */
       
   453    
       
   454     $(".Ldt-Ctrl-SetIn").click(function() {
       
   455         if (currentMedia && currentSegment) {
       
   456             currentSegment.setBegin(currentMedia.getCurrentTime());
       
   457         }
       
   458     });
       
   459     $(".Ldt-Ctrl-SetOut").click(function() {
       
   460         if (currentMedia && currentSegment) {
       
   461             currentSegment.setEnd(currentMedia.getCurrentTime());
       
   462         }
       
   463     });
       
   464        
   399     /* Segment Form interaction */
   465     /* Segment Form interaction */
   400    
   466    
   401     $("#segment-title").on("keyup change input paste", function() {
   467     $("#segment-title").on("keyup change input paste", function() {
   402         if (currentMedia && currentSegment) {
   468         if (currentMedia && currentSegment) {
   403             currentSegment.title = $(this).val();
   469             currentSegment.title = $(this).val();
   404             updateSegmentUI();
   470             updateSegmentUI();
   405             mashup.trigger("change");
   471             mashup.trigger("change");
   406         }
   472         }
   407     });
   473     });
       
   474     $("#segment-title").on("focus click", function() {
       
   475         if ($(this).val() === IriSP.hc_messages.segment_title_placeholder) {
       
   476             $(this).val("");
       
   477         }
       
   478     });
   408     $("#segment-description").on("keyup change input paste", function() {
   479     $("#segment-description").on("keyup change input paste", function() {
   409         if (currentMedia && currentSegment) {
   480         if (currentMedia && currentSegment) {
   410             currentSegment.description = $(this).val();
   481             currentSegment.description = $(this).val();
   411             mashup.trigger("change");
   482             mashup.trigger("change");
   412         }
   483         }
   480         var mediaid = annotation.getMedia().id;
   551         var mediaid = annotation.getMedia().id;
   481         $(".media").removeClass("active");
   552         $(".media").removeClass("active");
   482         $(".media[data-media-id='" + mediaid + "']").addClass("active");
   553         $(".media[data-media-id='" + mediaid + "']").addClass("active");
   483     });
   554     });
   484     
   555     
   485     project.on("mouseout-annotation", function(annotation) {
   556     project.on("mouseout-annotation", function() {
   486         $(".media").removeClass("active");
   557         $(".media").removeClass("active");
   487         var mediaid = undefined;
   558         var mediaid = undefined;
   488         if (currentMedia && currentMedia.elementType === "media") {
   559         if (currentMedia && currentMedia.elementType === "media") {
   489             mediaid = currentMedia.id;
   560             mediaid = currentMedia.id;
   490             if (currentSegment) {
   561             if (currentSegment) {
   602     });
   673     });
   603     
   674     
   604     /* Click on current segment in Preview */
   675     /* Click on current segment in Preview */
   605     
   676     
   606     $(".mashup-description .edit").click(function() {
   677     $(".mashup-description .edit").click(function() {
   607         if (mashupCurrentAnnotation) {
   678         if (mashup.currentAnnotation) {
   608             currentSegment = mashupCurrentAnnotation.annotation;
   679             currentSegment = mashup.currentAnnotation.annotation;
   609             setMedia(mashupCurrentAnnotation.getMedia());
   680             setMedia(mashup.currentAnnotation.getMedia());
   610         }
   681         }
       
   682         return false;
   611     });
   683     });
   612     
   684     
   613     /* Handling related segments */
   685     /* Handling related segments */
   614    
   686    
   615     $(".media-segments-list").on("mouseover", ".media-segment", function() {
   687     $(".media-segments-list").on("mouseover", ".media-segment", function() {
   617     }).on("mouseout", ".media-segment", function() {
   689     }).on("mouseout", ".media-segment", function() {
   618         $(this).find(".media-segment-popin").hide();
   690         $(this).find(".media-segment-popin").hide();
   619     }).on("click", ".reprendre-segment", function() {
   691     }).on("click", ".reprendre-segment", function() {
   620         var sid = $(this).attr("data-segment-id"),
   692         var sid = $(this).attr("data-segment-id"),
   621             s = directory.getElement(sid) || apidirectory.getElement(sid);
   693             s = directory.getElement(sid) || apidirectory.getElement(sid);
   622         currentSegment.title = s.title;
   694         currentSegment.title = IriSP.hc_messages.copy_of_ + s.title;
   623         currentSegment.description = s.description;
   695         currentSegment.description = s.description;
   624         $("#segment-title").val(s.title);
   696         $("#segment-title").val(IriSP.hc_messages.copy_of_ + s.title);
   625         $("#segment-description").val(s.description);
   697         $("#segment-description").val(s.description);
   626         currentSegment.setBegin(s.begin);
   698         currentSegment.setBegin(s.begin);
   627         currentSegment.setEnd(s.end);
   699         currentSegment.setEnd(s.end);
       
   700         //TODO: ET LES TAGS !
   628         return false;
   701         return false;
   629     });
   702     });
   630     
   703     
   631     /* Changing Hashcut Title and description */
   704     /* Changing Hashcut Title and description */
   632     
       
   633     $("#hashcut-tags").tagit({
       
   634         onTagRemoved: updateSegmentTags,
       
   635         onTagAdded: updateSegmentTags
       
   636     });
       
   637     
   705     
   638     mashup.title = IriSP.hc_messages.mashup_title_placeholder;
   706     mashup.title = IriSP.hc_messages.mashup_title_placeholder;
   639     $(".title-video-wrap a").text(mashup.title);
   707     $(".title-video-wrap a").text(mashup.title);
   640     $("#hashcut-title").val(mashup.title);
   708     $("#hashcut-title").val(mashup.title);
   641     
   709     
   642     $("#hashcut-title").on("keyup change input paste", function() {
   710     $("#hashcut-title").on("keyup change input paste", function() {
   643         mashup.title = $(this).val();
   711         mashup.title = $(this).val();
   644         $(".title-video-wrap a").text(mashup.title);
   712         $(".title-video-wrap a").text(mashup.title);
   645         mashup.trigger("change");
   713         mashup.trigger("change");
   646     });
   714     });
       
   715     $("#hashcut-title").on("focus click", function() {
       
   716         if ($(this).val() === IriSP.hc_messages.mashup_title_placeholder) {
       
   717             $(this).val("");
       
   718         }
       
   719     });
   647     
   720     
   648     $("#hashcut-description").on("keyup change input paste", function() {
   721     $("#hashcut-description").on("keyup change input paste", function() {
   649         mashup.description = $(this).val();
   722         mashup.description = $(this).val();
   650         mashup.trigger("change");
   723         mashup.trigger("change");
   651     });
   724     });
   652     
   725     
   653     function updateMashupTags() {
   726     $("#hashcut-form").submit(function() {
   654         window.setTimeout(function() {
   727         $(".update-title").hide();
   655             mashup.keywords = $("#segment-tags").tagit("assignedTags");
   728         return false;
   656         }, 0);
   729     })
   657     }
       
   658     
   730     
   659     /* Publication */
   731     /* Publication */
   660    
   732    
   661     $(".publier-button").click(function() {
   733     $(".publier-button").click(function() {
       
   734         if ($(this).hasClass("disable")) {
       
   735             alert("Le Mashup ne peut pas être publié pour les raisons suivantes :\n\n"+mashupstatus);
       
   736             return false;
       
   737         }
   662         var postproject = directory.newLocalSource(),
   738         var postproject = directory.newLocalSource(),
   663             anntype = new IriSP.Model.AnnotationType(false, postproject),
   739             medias = mashup.getMedias()
   664             annotations = mashup.getOriginalAnnotations();
   740             annotations = mashup.getOriginalAnnotations();
   665         anntype.title = "hashcut-segments";
   741         postproject.addList("annotationType");
       
   742         postproject.addList("tag");
       
   743         medias.forEach(function(_m) {
       
   744             var anntype = new IriSP.Model.AnnotationType(false, postproject);
       
   745             anntype.title = "Segments from " + _m.title;
       
   746             anntype.media = _m;
       
   747             postproject.getAnnotationTypes().push(anntype);
       
   748         });
   666         annotations.forEach(function(_a) {
   749         annotations.forEach(function(_a) {
   667             _a.setAnnotationType(anntype.id);
   750             _a.setAnnotationType(
   668         });
   751                 postproject.getAnnotationTypes().filter(
   669         postproject.addList("media",mashup.getMedias());
   752                     function(_at) { return _at.media === _a.getMedia() }
   670         postproject.addList("annotationType",[anntype]);
   753                 )[0].id);
       
   754             var tagids = [];
       
   755             _(_a.keywords).each(function(keyword) {
       
   756                 var tags = postproject.getTags().searchByTitle(keyword);
       
   757                 if (tags.length) {
       
   758                     tagids.push(tags[0].id);
       
   759                 } else {
       
   760                     var tag = new IriSP.Model.Tag(false, postproject);
       
   761                     tag.title = tag.description = keyword;
       
   762                     postproject.getTags().push(tag);
       
   763                     tagids.push(tag.id);
       
   764                 }
       
   765             });
       
   766             _a.setTags(tagids);
       
   767         });
   671         postproject.addList("annotation",annotations);
   768         postproject.addList("annotation",annotations);
       
   769         postproject.addList("media",medias);
   672         postproject.addList("mashup",[mashup]);
   770         postproject.addList("mashup",[mashup]);
   673         postproject.addList("tag");
   771         postproject.creator = "admin";
   674         postproject.creator = "IRI";
   772         postproject.created = new Date();
       
   773         postproject.modified = new Date();
   675         postproject.title = mashup.title;
   774         postproject.title = mashup.title;
   676         postproject.description = mashup.description;
   775         postproject.description = mashup.description;
   677         console.log(IriSP.serializers.ldt.serialize(postproject));
       
   678         $.ajax({
   776         $.ajax({
   679             type: "POST",
   777             type: "POST",
   680             url: options.project_api_endpoint,
   778             url: options.project_api_endpoint,
   681             data: IriSP.serializers.ldt.serialize(postproject),
   779             data: IriSP.serializers.ldt.serialize(postproject),
   682             contentType: "application/cinelab",
   780             contentType: "application/cinelab",
   683 //            headers: {"X-CSRFToken": "{{csrf_token}}"},
   781 //            headers: {"X-CSRFToken": "{{csrf_token}}"},
   684             success: function(data, status, request){
   782             success: function(data, status, request){
   685                     alert("api post success");
   783                 console.log(request.getResponseHeader("Location"));
   686             },
   784             },
   687             error: function(jqXHR, textStatus, errorThrown){
   785             error: function(jqXHR, textStatus, errorThrown){
   688                 alert(errorThrown);
   786                 alert(errorThrown);
   689             }
   787             }
   690         });
   788         });
       
   789         return false;
   691     });
   790     });
   692     
   791     
   693     mashup.trigger("change");
   792     mashup.trigger("change");
   694 }
   793 }