equal
deleted
inserted
replaced
3 window.shortenText = function(text, minlength, maxlength) { |
3 window.shortenText = function(text, minlength, maxlength) { |
4 var min = (typeof minlength === "undefined" ? 100 : minlength), |
4 var min = (typeof minlength === "undefined" ? 100 : minlength), |
5 max = (typeof maxlength === "undefined" ? min + 20 : maxlength), |
5 max = (typeof maxlength === "undefined" ? min + 20 : maxlength), |
6 rx = new RegExp("(^.{" + min + "," + max + "})[\s].+$"); |
6 rx = new RegExp("(^.{" + min + "," + max + "})[\s].+$"); |
7 return text.replace(/[\n\r\s]+/mg,' ').replace(rx,'$1…'); |
7 return text.replace(/[\n\r\s]+/mg,' ').replace(rx,'$1…'); |
8 } |
8 }; |
9 |
9 |
10 /* Load Media List */ |
10 /* Load Media List */ |
11 |
11 |
12 var directory = new IriSP.Model.Directory(), |
12 var directory = new IriSP.Model.Directory(), |
13 apidirectory = new IriSP.Model.Directory(), |
13 apidirectory = new IriSP.Model.Directory(), |
109 } |
109 } |
110 ]; |
110 ]; |
111 var mashupwarning = [ |
111 var mashupwarning = [ |
112 { |
112 { |
113 validate: function(_m) { |
113 validate: function(_m) { |
114 return !!_m.description |
114 return !!_m.description; |
115 }, |
115 }, |
116 message: gettext("A hashcut should have a description") |
116 message: gettext("A hashcut should have a description") |
117 } |
117 } |
118 ]; |
118 ]; |
119 |
119 |
188 _(annotations).each(function(_a, i) { |
188 _(annotations).each(function(_a, i) { |
189 var pos = k * (_a.begin + _a.end) / 2, |
189 var pos = k * (_a.begin + _a.end) / 2, |
190 corrpos = Math.max(76, Math.min(156, pos)), |
190 corrpos = Math.max(76, Math.min(156, pos)), |
191 line = IriSP._(lines).find(function(line) { |
191 line = IriSP._(lines).find(function(line) { |
192 return !IriSP._(line.annotations).find(function(ann) { |
192 return !IriSP._(line.annotations).find(function(ann) { |
193 return ann.begin < _a.end && ann.end > _a.begin |
193 return ann.begin < _a.end && ann.end > _a.begin; |
194 }); |
194 }); |
195 }); |
195 }); |
196 if (!line) { |
196 if (!line) { |
197 line = { index: lines.length, annotations: []}; |
197 line = { index: lines.length, annotations: []}; |
198 lines.push(line); |
198 lines.push(line); |
207 title: _a.title.replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'), |
207 title: _a.title.replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'), |
208 description: shortenText(_a.description).replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'), |
208 description: shortenText(_a.description).replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'), |
209 tags: _a.keywords.join(", ").replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'), |
209 tags: _a.keywords.join(", ").replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'), |
210 popleft : corrpos, |
210 popleft : corrpos, |
211 pointerpos : (pos - corrpos), |
211 pointerpos : (pos - corrpos), |
212 } |
212 }; |
213 html += mediafoundtemplate(vizdata); |
213 html += mediafoundtemplate(vizdata); |
214 }); |
214 }); |
215 html = mediafoundlisttemplate({ |
215 html = mediafoundlisttemplate({ |
216 height: 8 * lines.length, |
216 height: 8 * lines.length, |
217 segments: html |
217 segments: html |
220 li.show(); |
220 li.show(); |
221 } else { |
221 } else { |
222 li.hide(); |
222 li.hide(); |
223 } |
223 } |
224 } |
224 } |
225 }) |
225 }); |
226 }); |
226 }); |
227 |
227 |
228 /* Fill right column when mashup is updated */ |
228 /* Fill right column when mashup is updated */ |
229 |
229 |
230 function updateMashupUI() { |
230 function updateMashupUI() { |
356 messages.push(sc.message); |
356 messages.push(sc.message); |
357 } |
357 } |
358 }); |
358 }); |
359 currentSegment.status = critical ? "critical" : (warning ? "warning" : "valid"); |
359 currentSegment.status = critical ? "critical" : (warning ? "warning" : "valid"); |
360 if (!messages.length) { |
360 if (!messages.length) { |
361 messages.push(gettext("This segment is valid!")) |
361 messages.push(gettext("This segment is valid!")); |
362 } |
362 } |
363 currentSegment.status_messages = _(messages); |
363 currentSegment.status_messages = _(messages); |
364 |
364 |
365 $(".segmentation .validate").removeClass("critical warning valid").addClass(currentSegment.status); |
365 $(".segmentation .validate").removeClass("critical warning valid").addClass(currentSegment.status); |
366 $(".segmentation .validate-tooltip").html("<ul><li>" + currentSegment.status_messages.join("</li><li>")+"</li></ul>"); |
366 $(".segmentation .validate-tooltip").html("<ul><li>" + currentSegment.status_messages.join("</li><li>")+"</li></ul>"); |
444 _(_annotations).each(function(_a, i) { |
444 _(_annotations).each(function(_a, i) { |
445 var pos = k * (_a.begin + _a.end) / 2, |
445 var pos = k * (_a.begin + _a.end) / 2, |
446 corrpos = Math.max(145, Math.min(305, pos)), |
446 corrpos = Math.max(145, Math.min(305, pos)), |
447 line = IriSP._(lines).find(function(line) { |
447 line = IriSP._(lines).find(function(line) { |
448 return !IriSP._(line.annotations).find(function(ann) { |
448 return !IriSP._(line.annotations).find(function(ann) { |
449 return ann.begin < _a.end && ann.end > _a.begin |
449 return ann.begin < _a.end && ann.end > _a.begin; |
450 }); |
450 }); |
451 }); |
451 }); |
452 if (!line) { |
452 if (!line) { |
453 line = { index: lines.length, annotations: []}; |
453 line = { index: lines.length, annotations: []}; |
454 lines.push(line); |
454 lines.push(line); |
461 width : k * _a.getDuration(), |
461 width : k * _a.getDuration(), |
462 height: 8, |
462 height: 8, |
463 top: 8 * line.index, |
463 top: 8 * line.index, |
464 pointerpos : (pos - corrpos), |
464 pointerpos : (pos - corrpos), |
465 color: IriSP.vizcolors[i % IriSP.vizcolors.length] |
465 color: IriSP.vizcolors[i % IriSP.vizcolors.length] |
466 } |
466 }; |
467 html += mediasegmenttemplate(vizdata); |
467 html += mediasegmenttemplate(vizdata); |
468 }); |
468 }); |
469 return mediasegmentlisttemplate({ |
469 return mediasegmentlisttemplate({ |
470 height: 8 * lines.length, |
470 height: 8 * lines.length, |
471 left: k * currentSegment.begin, |
471 left: k * currentSegment.begin, |
591 }); |
591 }); |
592 |
592 |
593 /* Click on segments */ |
593 /* Click on segments */ |
594 |
594 |
595 function reorganizeMashup() { |
595 function reorganizeMashup() { |
596 var ids = $(".organize-segments .item-video").map(function(){return $(this).attr("data-segment-id")}); |
596 var ids = $(".organize-segments .item-video").map(function(){return $(this).attr("data-segment-id");}); |
597 mashup.setAnnotationsById(ids); |
597 mashup.setAnnotationsById(ids); |
598 } |
598 } |
599 |
599 |
600 project.on("mouseover-annotation", function(annotation) { |
600 project.on("mouseover-annotation", function(annotation) { |
601 var mediaid = annotation.getMedia().id; |
601 var mediaid = annotation.getMedia().id; |
612 $(".annotation").removeClass("active"); |
612 $(".annotation").removeClass("active"); |
613 $(".annotation[data-segment-id='" + currentSegment.id + "']").addClass("active"); |
613 $(".annotation[data-segment-id='" + currentSegment.id + "']").addClass("active"); |
614 } |
614 } |
615 } |
615 } |
616 if (currentMedia === mashup && mashup.currentMedia) { |
616 if (currentMedia === mashup && mashup.currentMedia) { |
617 mediaid = mashup.currentMedia.id |
617 mediaid = mashup.currentMedia.id; |
618 } |
618 } |
619 $(".media[data-media-id='" + mediaid + "']").addClass("active"); |
619 $(".media[data-media-id='" + mediaid + "']").addClass("active"); |
620 }); |
620 }); |
621 |
621 |
622 $(".organize-segments") |
622 $(".organize-segments") |
832 }); |
832 }); |
833 |
833 |
834 $("#hashcut-form").submit(function() { |
834 $("#hashcut-form").submit(function() { |
835 $(".update-title").hide(); |
835 $(".update-title").hide(); |
836 return false; |
836 return false; |
837 }) |
837 }); |
838 |
838 |
839 /* Publication */ |
839 /* Publication */ |
840 |
840 |
841 function onLeave() { |
841 function onLeave() { |
842 return gettext("You haven't published your hashcut yet.\nIf you leave this page, it will be lost."); |
842 return gettext("You haven't published your hashcut yet.\nIf you leave this page, it will be lost."); |
848 if ($(this).hasClass("disable")) { |
848 if ($(this).hasClass("disable")) { |
849 alert(gettext("The hashcut can't be published because:")+"\n\n"+mashupstatus); |
849 alert(gettext("The hashcut can't be published because:")+"\n\n"+mashupstatus); |
850 return false; |
850 return false; |
851 } |
851 } |
852 var postproject = directory.newLocalSource(), |
852 var postproject = directory.newLocalSource(), |
853 medias = mashup.getMedias() |
853 medias = mashup.getMedias(), |
854 annotations = mashup.getOriginalAnnotations(); |
854 annotations = mashup.getOriginalAnnotations(); |
855 postproject.addList("annotationType"); |
855 postproject.addList("annotationType"); |
856 postproject.addList("tag"); |
856 postproject.addList("tag"); |
857 medias.forEach(function(_m) { |
857 medias.forEach(function(_m) { |
858 var anntype = new IriSP.Model.AnnotationType(false, postproject); |
858 var anntype = new IriSP.Model.AnnotationType(false, postproject); |
861 postproject.getAnnotationTypes().push(anntype); |
861 postproject.getAnnotationTypes().push(anntype); |
862 }); |
862 }); |
863 annotations.forEach(function(_a) { |
863 annotations.forEach(function(_a) { |
864 _a.setAnnotationType( |
864 _a.setAnnotationType( |
865 postproject.getAnnotationTypes().filter( |
865 postproject.getAnnotationTypes().filter( |
866 function(_at) { return _at.media === _a.getMedia() } |
866 function(_at) { return _at.media === _a.getMedia(); } |
867 )[0].id); |
867 )[0].id); |
868 var tagids = []; |
868 var tagids = []; |
869 _(_a.keywords).each(function(keyword) { |
869 _(_a.keywords).each(function(keyword) { |
870 var tags = postproject.getTags().searchByTitle(keyword); |
870 var tags = postproject.getTags().searchByTitle(keyword); |
871 if (tags.length) { |
871 if (tags.length) { |
912 |
912 |
913 return false; |
913 return false; |
914 }); |
914 }); |
915 |
915 |
916 mashup.trigger("change"); |
916 mashup.trigger("change"); |
917 } |
917 }; |
918 |
918 |
919 /* END editor.js */ |
919 /* END editor.js */ |