integration/js/edition.js
changeset 84 9f481f896e60
parent 83 8f954a0d6031
child 86 e61b3adf46f2
equal deleted inserted replaced
83:8f954a0d6031 84:9f481f896e60
     1 var myMedia = undefined,
     1 var myMedia = undefined,
     2     currentChapter = undefined,
     2     currentChapter = undefined,
     3     currentAnnotation = undefined,
     3     currentAnnotation = undefined;
     4     chapters = [],
       
     5     annotations = [];
       
     6 
     4 
     7 $(function(){
     5 $(function(){
     8 
     6 
     9 var global = {
     7 var global = {
    10     colorsIndex : 0,
     8     colorsIndex : 0,
    36     $(".project-title").text(myProject.title);
    34     $(".project-title").text(myProject.title);
    37     $('.project-title-nav').text(myProject.title);
    35     $('.project-title-nav').text(myProject.title);
    38 
    36 
    39     myMedia = myProject.getCurrentMedia();
    37     myMedia = myProject.getCurrentMedia();
    40 
    38 
       
    39     var anntypes = myProject.getAnnotationTypes().searchByTitle("chapitrage");
       
    40     if (!anntypes.length) {
       
    41         chapterAnnType = new IriSP.AnnotationType(false, myProject);
       
    42         chapterAnnType.title = "chapitrage";
       
    43     } else {
       
    44         chapterAnnType = anntypes[0];
       
    45     }
       
    46 
    41 //load Chapitre
    47 //load Chapitre
    42 var _chapters = myProject.getAnnotationsByTypeTitle("chapitrage");
    48 
    43 if(_chapters.length){
    49     chapters = chapterAnnType.getAnnotations();
    44     $.each(_chapters, function(k, v){
    50     $.each(chapters, function(k, v){
    45         v.color = getRandomColor();
    51         v.color = getRandomColor();
    46         chapters.push(v);
    52     });
    47         if((k+1) == _chapters.length){
    53     renderChapter();
    48             renderChapter();
       
    49         }
       
    50     });
       
    51 }
       
    52 
    54 
    53 //load Annotations
    55 //load Annotations
    54 var _annotations = myProject.getAnnotationsByTypeTitle("annotations");
    56     var anntypes = myProject.getAnnotationTypes().searchByTitle("annotations");
    55 if(_annotations.length){
    57     if (!anntypes.length) {
    56     $.each(_annotations, function(k, v){
    58         annotationsAnnType = new IriSP.AnnotationType(false, myProject);
    57 
    59         annotationsAnnType.title = "annotations";
    58         v.color = getRandomColor();
    60     } else {
       
    61         annotationsAnnType = anntypes[0];
       
    62     }
       
    63 
       
    64     annotations = annotationsAnnType.getAnnotations();
       
    65     $.each(annotations, function(k, v){
    59         var type = v.content.mimetype.split('-');
    66         var type = v.content.mimetype.split('-');
    60         type = type[type.length-1]
    67         type = type[type.length-1]
    61         v.type = type;
    68         v.type = type;
    62 
    69         v.color = getRandomColor();
    63         annotations.push(v);
    70     });
    64         if((k+1) == _annotations.length){
    71     renderAnnotation();
    65             renderAnnotation();
    72 
    66         }
       
    67 
       
    68     });
       
    69 }
       
    70 
    73 
    71     IriSP.htmlPlayer(
    74     IriSP.htmlPlayer(
    72         myMedia,
    75         myMedia,
    73         $(".main-video"),
    76         $(".main-video"),
    74         {
    77         {
   313     function newChapter(dataChapter, render){
   316     function newChapter(dataChapter, render){
   314         var chapter = new IriSP.Model.Annotation(false, myProject);
   317         var chapter = new IriSP.Model.Annotation(false, myProject);
   315             chapter.setMedia(myMedia.id);
   318             chapter.setMedia(myMedia.id);
   316             chapter.setBegin(dataChapter.begin);
   319             chapter.setBegin(dataChapter.begin);
   317             chapter.setEnd(dataChapter.end);
   320             chapter.setEnd(dataChapter.end);
       
   321             chapter.setAnnotationType(chapterAnnType.id);
   318             chapter.title = dataChapter.title;
   322             chapter.title = dataChapter.title;
   319             chapter.description = dataChapter.description;
   323             chapter.description = dataChapter.description;
   320             chapter.keywords = dataChapter.keywords;
   324             chapter.keywords = dataChapter.keywords;
   321             chapter.color = getRandomColor();
   325             chapter.color = getRandomColor();
   322     
   326     
   395 //######################## annotation
   399 //######################## annotation
   396     
   400     
   397 
   401 
   398     function newAnnotation(dataAnnotation){
   402     function newAnnotation(dataAnnotation){
   399         var annotation = new IriSP.Model.Annotation(false, myProject);
   403         var annotation = new IriSP.Model.Annotation(false, myProject);
       
   404             annotation.setAnnotationType(annotationsAnnType.id);
   400             annotation.setMedia(myMedia.id);
   405             annotation.setMedia(myMedia.id);
   401             annotation.setBegin(dataAnnotation.begin);
   406             annotation.setBegin(dataAnnotation.begin);
   402             annotation.setEnd(dataAnnotation.end);
   407             annotation.setEnd(dataAnnotation.end);
   403             annotation.title = dataAnnotation.title;
   408             annotation.title = dataAnnotation.title;
   404             annotation.description = dataAnnotation.description;
   409             annotation.description = dataAnnotation.description;
   883 });
   888 });
   884 
   889 
   885 //save project
   890 //save project
   886 $('.btn-save-project').bind('click', function(e){
   891 $('.btn-save-project').bind('click', function(e){
   887     $('.btn-apercu-projet').removeClass('disabled');
   892     $('.btn-apercu-projet').removeClass('disabled');
       
   893 
       
   894     console.log(myProject.serialize().length);
       
   895 /*
       
   896     $.ajax({
       
   897         type: "POST",
       
   898         url: urlSaveProject,
       
   899         data: myProject.serialize(),
       
   900         contentType: "application/cinelab",
       
   901         headers: {
       
   902             //"X-CSRFToken": options.csrf_token
       
   903         },
       
   904         success: function(data, status, request){
       
   905             console.log('data : ', data);
       
   906             console.log('status : ', status);
       
   907             console.log('request : ', request);
       
   908 
       
   909         },
       
   910         error: function(jqXHR, textStatus, errorThrown){
       
   911             alert(gettext("Server error\nYour hashcut couldn't be published"));
       
   912         }
       
   913     });
       
   914 */
   888 
   915 
   889 });
   916 });
   890 
   917 
   891 function disabledPreview(){
   918 function disabledPreview(){
   892     if(!$('.btn-apercu-projet').hasClass('disabled'))$('.btn-apercu-projet').addClass('disabled');
   919     if(!$('.btn-apercu-projet').hasClass('disabled'))$('.btn-apercu-projet').addClass('disabled');