Gitlab CSE Unil

Commit 6f21842a authored by M. Chardon's avatar M. Chardon
Browse files

Merge remote-tracking branch 'origin/V2'

# Conflicts:
#	.scannerwork/report-task.txt
parents 2e1b93ce 0bdbe8ce
define(["jquery"],function(a){function b(a){b.editor=a.editor,this.id=null,this.timeposition=null,this.isquestion=0,this.assignementpart=null,this.validation=0,this.statut=0,this.mainmessage=null,this.tag=-1}return b.id=null,b.timeposition=null,b.isquestion=0,b.assignementpart=null,b.validation=0,b.statut=0,b.mainmessage=null,b.tag=-1,b.editor=null,b.divDisplay=null,b.DEFAULTCOLOR="yellow",b.prototype.init=function(a){a.timeposition&&(this.timeposition=a.timeposition),a.id&&(this.id=a.id),a.isquestion&&(this.isquestion=a.isquestion),a.assignementpart&&(this.assignementpart=a.assignementpart),a.validation&&(this.validation=a.validation),a.statut&&(this.statut=a.statut),a.mainmessage&&(this.mainmessage=a.mainmessage),a.tag&&(this.tag=a.tag)},b.prototype.initListener=function(){if(this.divDisplay){var a=this;this.divDisplay.on("click",function(){1==b.editor.getEval()?b.editor.notify("edit",a):b.editor.notify("view",a)})}},b.prototype.serialize=function(a,b,c){return{courseid:a,action:b,audioannotation:c,timeposition:this.timeposition,id:this.id,isquestion:this.isquestion,assignementpart:this.assignementpart,validation:this.validation,statut:this.statut,mainmessage:this.mainmessage,tag:this.tag}},b.prototype.displayDiv=function(a,b,c){return this.divDisplay&&!c||this.buildDiv(a,b),this.divDisplay},b.prototype.buildDiv=function(c,d){var e=b.editor.getTagColor();d&&(e=b.DEFAULTCOLOR),this.tag>-1&&(e=b.editor.getTagColor(this.tag));var f="<div style='background-color:"+e+";";f+="margin-left:"+c+"%;' ",f+="class='audio_annotation' ",f+=d?"data-annotation='draft' ":"data-annotation='"+this.id+"' ",f+="></div>",this.divDisplay=a(f)},b.prototype.hide=function(){this.divDisplay.hide()},b.prototype.show=function(){this.divDisplay.show()},b.prototype.refreshDiv=function(a){a?this.divDisplay.css("background-color",b.DEFAULTCOLOR):this.divDisplay.css("background-color",b.editor.getTagColor(this.tag)),this.divDisplay.data("annotation",this.id)},b.prototype.delDisplay=function(){this.divDisplay&&this.divDisplay.remove()},b});
\ No newline at end of file
define(["jquery"],function(a){function b(a){this.editor=a.editor,this.id=null,this.timeposition=null,this.isquestion=0,this.assignementpart=null,this.validation=0,this.statut=0,this.mainmessage=null,this.tag=-1}return b.id=null,b.timeposition=null,b.isquestion=0,b.assignementpart=null,b.validation=0,b.statut=0,b.mainmessage=null,b.tag=-1,b.editor=null,b.divDisplay=null,b.DEFAULTCOLOR="yellow",b.prototype.init=function(a){a.timeposition&&(this.timeposition=a.timeposition),a.id&&(this.id=a.id),a.isquestion&&(this.isquestion=a.isquestion),a.assignementpart&&(this.assignementpart=a.assignementpart),a.validation&&(this.validation=a.validation),a.statut&&(this.statut=a.statut),a.mainmessage&&(this.mainmessage=a.mainmessage),a.tag&&(this.tag=a.tag)},b.prototype.initListener=function(){if(this.divDisplay){var a=this;this.divDisplay.on("click",function(){1==a.editor.getEval()?a.editor.notify("edit",a):a.editor.notify("view",a)})}},b.prototype.serialize=function(a,b,c){return{courseid:a,action:b,audioannotation:c,timeposition:this.timeposition,id:this.id,isquestion:this.isquestion,assignementpart:this.assignementpart,validation:this.validation,statut:this.statut,mainmessage:this.mainmessage,tag:this.tag}},b.prototype.displayDiv=function(a,b,c){return this.divDisplay&&!c||this.buildDiv(a,b),this.divDisplay},b.prototype.buildDiv=function(c,d){var e=this.editor.getTagColor();d&&(e=b.DEFAULTCOLOR),this.tag>-1&&(e=this.editor.getTagColor(this.tag));var f="<div style='background-color:"+e+";";f+="margin-left:"+c+"%;' ",f+="class='audio_annotation' ",f+=d?"data-annotation='draft' ":"data-annotation='"+this.id+"' ",f+="></div>",this.divDisplay=a(f)},b.prototype.hide=function(){this.divDisplay.hide()},b.prototype.show=function(){this.divDisplay.show()},b.prototype.refreshDiv=function(a){a?this.divDisplay.css("background-color",b.DEFAULTCOLOR):this.divDisplay.css("background-color",this.editor.getTagColor(this.tag)),this.divDisplay.data("annotation",this.id)},b.prototype.delDisplay=function(){this.divDisplay&&this.divDisplay.remove()},b});
\ No newline at end of file
define(["jquery","mod_audioannotation/justWave","mod_audioannotation/editor","mod_audioannotation/rightMenu"],function(a,b,c,d){function e(a){e.courseid="course"in a?a.course:null,e.assignpartid="assignpart"in a?a.assignpart:null,e.audioannotation="audioannotation"in a?a.audioannotation:null,e.eval="eval"in a?a.eval:0;var f="repo"in a?a.repo:null,g="annotations"in a?a.annotations:null,h=null;g&&(h=JSON.parse(g));var i="tags"in a?a.tags:null,j=null;i&&(j=JSON.parse(i)),e.wavePlayer=new b(this),e.editor=new c({controler:this,courseid:e.courseid,assignpartid:e.assignpartid,annotations:h,audioannotation:e.audioannotation,tags:j,repo:f}),this.initTrigger(),this.initWave("justwave"),e.rightMenu=new d({controler:this})}e.courseid=-1,e.assignpartid=-1,e.audioannotation=-1,e.wavePlayer=null,e.editor=null,e.rightMenu=null,e.lastP=null,e.eval=0,e.prototype.initTrigger=function(){1==e.eval&&a("#btn_add_annotation").on("click",function(){e.editor.notify("add",e.lastP)}),a("#select_tag").on("change",f),a("#select_question").on("change",f),a("#select_statut").on("change",f),a("li[data-annotation]").on("click",function(){var b=a(this).data("annotation");b&&e.editor.notify("view",{annotation:b})})};var f=function(){e.editor.notify("displaytqs",{tag:a("#select_tag").val(),question:a("#select_question").val(),statut:a("#select_statut").val()})};return e.prototype.initWave=function(b){e.wavePlayer.init(b),a(".justwave_playpause").click(),a(".justwave_playpause").click()},e.prototype.initAnnotations=function(){e.editor.initAnnotationsDisplay()},e.prototype.notify=function(a,b,c){switch("player"===b&&(e.lastP=c),a){case"loadedmetadata":this.initAnnotations();break;case"drawannotation_draft":e.wavePlayer.drawAnnotation(e.lastP,c,1);break;case"drawannotation":e.wavePlayer.drawAnnotation(e.lastP,c,0);break;case"addannotation":e.editor.setEditorStatus("add");break;case"editannotation":e.editor.setEditorStatus("edit");break;case"viewannotation":e.editor.setEditorStatus("view");break;case"deleteannotation":"rightMenu"===b?e.editor.notify("delete",c):e.editor.setEditorStatus("delete")}},e.prototype.getEval=function(){return e.eval},e});
\ No newline at end of file
define(["jquery","mod_audioannotation/justWave","mod_audioannotation/editor","mod_audioannotation/rightMenu"],function(a,b,c,d){function e(a){e.courseid="course"in a?a.course:null,e.audioannotation="audioannotation"in a?a.audioannotation:null,e.eval="eval"in a?a.eval:0;var f="repo"in a?a.repo:null,g="assignparts"in a?a.assignparts:null,h=null;g&&(h=JSON.parse(g));var i="tags"in a?a.tags:null,j=null;i&&(j=JSON.parse(i)),e.wavePlayer=new b(this),e.editors=[];for(var k=0;k<h.length;k++){e.editors[h[k].id]=new c({controler:this,courseid:e.courseid,assignpart:h[k],audioannotation:e.audioannotation,tags:j,repo:f});var l=new b(this,e.editors[h[k].id]);e.editors[h[k].id].setWavePlayer(l),this.initWave(l,"justwave",h[k].id)}this.initTrigger(),e.rightMenu=new d({controler:this})}return e.courseid=-1,e.audioannotation=-1,e.wavePlayer=null,e.prototype.editors=null,e.rightMenu=null,e.lastP=null,e.eval=0,e.prototype.initTrigger=function(){1==e.eval&&a(".btn_add_annotation").on("click",function(){e.editors[a(this).data("assignpart")].notify("add")}),a(".select_tqs").on("change",function(){var b=a(this).data("assignpart");e.editors[b].notify("displaytqs",{tag:a("#select_tag"+b).val(),question:a("#select_question"+b).val(),statut:a("#select_statut"+b).val()})}),a("li[data-annotation]").on("click",function(){var b=a(this).data("annotation"),c=a(this).parents(".annotationGroupAccordion").data("assignpart");b&&e.editors[c].notify("view",{annotation:b})})},e.prototype.initWave=function(b,c,d){b.init(c),a(".justwave"+d+" .justwave_playpause").click(),a(".justwave"+d+" .justwave_playpause").click()},e.prototype.initAnnotations=function(){for(var a=0;a<e.editors.length;a++)e.editors[a]&&e.editors[a].initAnnotationsDisplay()},e.prototype.notify=function(a,b,c){switch(a){case"loadedmetadata":this.initAnnotations();break;case"addannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("add");break;case"editannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("edit");break;case"viewannotation":for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("view");break;case"deleteannotation":if("rightMenu"===b)for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].notify("delete",c);else for(var d=0;d<e.editors.length;d++)e.editors[d]&&e.editors[d].setEditorStatus("delete")}},e.prototype.getEval=function(){return e.eval},e});
\ No newline at end of file
This diff is collapsed.
define(["jquery"],function(a){function b(a){return this.controler=a,this}b.controler=null,b.prototype.drawAnnotation=function(b,c,d){if(b){var e=c.timeposition/b.duration*100,f=a(b).next(),g=c.displayDiv(e,d);f.find(".audio_annotations").append(g)}},b.prototype.init=function(b,h){var i='<div class="justwave_wrapper">';i+='<img class="justwave_wave" src="" alt="" ondragstart="return false"/>',i+='<div class="justwave_playhead">',i+='<img class="justwave_progress" src="" alt="" ondragstart="return false"/>',i+='<span class="justwave_curpos">00:00</span>',i+="</div>",i+='<span class="justwave_duration">00:00</span>',i+='<span class="justwave_curfocus">00:00</span>',i+='<span class="justwave_songname"></span>',i+='<button class="justwave_playpause">',i+='<svg width="100%" height="100%" viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg">',i+='<circle r="21.5" cy="21.5" cx="21.5" stroke="#30C000" fill="#30C000"/>',i+='<path d="M31,21.5L17,33l2.5-11.5L17,10L31,21.5z" fill="#FFF" class="justwave_play"/>',i+='<g class="justwave_pause" fill="#FFF">',i+='<rect height="19" width="5" y="12" x="15"/><rect height="19" width="5" y="12" x="23"/>',i+="</g>",i+="</svg>",i+="</button>",i+='<div class="audio_annotations"></div>',i+="</div>";var j=a("audio");"string"==typeof b&&(h=b),"string"==typeof h&&(j=j.filter("."+h));var k=this.controler;j.each(function(){var h=this,j=a(this);h.opts={ajax:"justWave/justwave.ajax.php",width:900,height:100,wave_color:"#909296",prog_color:"#74cdd7",back_color:"#FFFFFF",buttoncolor:"#A47655",buttonsize:0,showname:1,namesize:15,showtimes:1,nowaves:0,nocache:!0},a.isPlainObject(b)&&a.extend(h.opts,b),j.attr("width")&&(h.opts.width=j.attr("width")),j.attr("height")&&(h.opts.height=j.attr("height")),j.attr("poster")&&(h.opts.poster=j.attr("poster"));for(var l,m=0,n=h.attributes,o=n.length;m<o;m++)l=n[m],"data-"===l.nodeName.substring(0,5)&&(h.opts[l.nodeName.substring(5)]=l.nodeValue);h.opts.chained&&j.addClass("justwave_chained"),j.after(i).on("loadedmetadata",function(b){var c=b.target,h=a(c).next();f(c),g(c),c.xduration=c.duration,h.find(".justwave_duration").text(d(c.xduration)),c.opts.showtimes&&c.opts.showtimes>0?h.find(".justwave_duration, .justwave_curpos").show():h.find(".justwave_duration, .justwave_curpos").hide(),a(c).attr("src")?c.opts.audio=a(c).attr("src"):c.opts.audio=c.currentSrc;var i=h.find(".justwave_songname").css("font-size",c.opts.namesize+"px").text(decodeURIComponent(c.opts.audio.replace(/.+[\\\/]/,"")));c.opts.showname&&c.opts.showname>0&&e(i,!0),+c.opts.nowaves||a.ajax(c.opts.ajax,{dataType:"json",type:"POST",data:c.opts}).done(function(b){var e=a(c).next(),f=e.find(".justwave_wave"),g=e.find(".justwave_progress");"ok"===b.status&&(f.width(c.opts.width),g.width(c.opts.width),e.css("background",""),e.find(".justwave_playhead").css("background",""),c.opts.poster&&e.css("background-image","url("+c.opts.poster+")"),f.attr("src",b.waveurl),c.opts.wave_color===c.opts.prog_color?g.attr("src",b.waveurl):g.attr("src",b.progressurl)),c.xduration=parseFloat(b.duration),c.xduration||(c.xduration=c.duration),e.find(".justwave_duration").text(d(c.xduration))}),k.notify("loadedmetadata","player",c)}).on("playing",function(b){var c=b.target,d=a(c).next();d.find(".justwave_pause").show(),d.find(".justwave_play").hide(),c.opts.chained&&a("audio.justwave_chained").each(function(){this!==c&&this.pause()}),k.notify("playing","player",c)}).on("pause",function(b){var c=a(b.target).next();c.find(".justwave_pause").hide(),c.find(".justwave_play").show()}).on("error",function(b){var c=b.target,d=a(c).next();f(c),d.find(".justwave_pause, .justwave_play").hide(),d.find(".justwave_playpause").prop("disabled",!0),d.find(".justwave_songname").text(a(c).attr("src").replace(/.+[\\\/]/,"")),d.find(".justwave_duration").text("00:00"),c.xduration=0,d.find(".justwave_duration, .justwave_curpos, .justwave_curfocus").hide(),k.notify("error","player",c)}).on("timeupdate",function(){c(this)}).on("ended",function(){this.pause()}),f(h),g(h);var p=j.next();p.click(function(b){b.preventDefault();var d=a(this).prev()[0],e=a(this).offset(),f=b.pageX-e.left;d.currentTime=f*d.xduration/this.offsetWidth,c(d),k.notify("click","player",d)}).mousemove(function(b){var c=a(this).offset(),f=b.pageX-c.left,g=b.pageY-c.top,h=this,i=a(this).prev()[0];a(h).find(".justwave_curfocus").text(d(f/this.offsetWidth*i.xduration)).css({top:g-5+"px",left:f+5+"px"}),i.opts.showname&&i.opts.showname>0&&e(a(h).find(".justwave_songname"))}).mouseleave(function(){a(this).find(".justwave_curfocus").hide(),a(this).find(".justwave_playpause").fadeOut(1e3)}).mouseenter(function(){var b=a(this).prev()[0];a(this).find(".justwave_playpause").stop(!1,!0).fadeIn(500),b.opts.showtimes&&b.opts.showtimes>0&&a(this).find(".justwave_curfocus").show(),k.notify("mouseenter","player",b)}),p.find(".justwave_playpause").on("click touchstart",function(b){b.stopPropagation(),b.preventDefault();var c=a(this).parent(),d=c.prev()[0];d.ended&&(d.currentTime=0),d.paused?d.play():d.pause(),k.notify("pause","player",d)}).mouseenter(function(){a(this).siblings(".justwave_curfocus").hide()}).mouseleave(function(){var b=a(this).parent().prev()[0];b.opts.showtimes&&b.opts.showtimes>0&&a(this).siblings(".justwave_curfocus").show(),k.notify("mouseleave","player",b)}),k.notify("initeach","player",h)})};var c=function(b){var c=b.currentTime/b.xduration*100,e=a(b).next();c<=100.1&&e.find(".justwave_playhead").width(c+"%"),e.find(".justwave_curpos").text(d(b.currentTime))},d=function(a){var b=Math.floor(a/60),c=Math.floor(a%60);return isNaN(a)?"00:00":(b<10?"0":"")+b+":"+(c<10?"0":"")+c},e=function(a,b){b&&a.stop(!0,!0).hide(),a.is(":visible")||a.fadeIn(300,function(){a.fadeOut(7e3,"swing")})},f=function(b){var c=a(b).next();c.find(".justwave_wave").width(0).attr("src",""),c.find(".justwave_progress").width(0).attr("src",""),c.width(b.opts.width).height(b.opts.height).css("background",b.opts.wave_color),b.opts.poster&&c.css("background-image","url("+b.opts.poster+")"),c.find(".justwave_playhead").css("background",b.opts.prog_color)},g=function(b){var c,d=a(b).next();b.opts.buttonsize?c=b.opts.buttonsize:(c=parseInt(.5*b.opts.height),c>88&&(c=88),c<33&&(c=b.opts.height-1)),d.find(".justwave_playpause").width(c).height(c).prop("disabled",!1).find("circle").attr({stroke:b.opts.buttoncolor,fill:b.opts.buttoncolor}),d.find(".justwave_pause").hide(),d.find(".justwave_play").show()};return b});
\ No newline at end of file
define(["jquery"],function(a){function b(a,b){return this.controler=a,this.assignpart=b,this}b.controler=null,b.assignpart=-1,b.prototype.drawAnnotation=function(b,c,d){if(b){var e=c.timeposition/b.duration*100,f=a(b).next(),g=c.displayDiv(e,d);f.find(".audio_annotations").append(g)}},b.prototype.init=function(b,h){var i='<div class="justwave_wrapper">';i+='<img class="justwave_wave" src="" alt="" ondragstart="return false"/>',i+='<div class="justwave_playhead">',i+='<img class="justwave_progress" src="" alt="" ondragstart="return false"/>',i+='<span class="justwave_curpos">00:00</span>',i+="</div>",i+='<span class="justwave_duration">00:00</span>',i+='<span class="justwave_curfocus">00:00</span>',i+='<span class="justwave_songname"></span>',i+='<button class="justwave_playpause">',i+='<svg width="100%" height="100%" viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg">',i+='<circle r="21.5" cy="21.5" cx="21.5" stroke="#30C000" fill="#30C000"/>',i+='<path d="M31,21.5L17,33l2.5-11.5L17,10L31,21.5z" fill="#FFF" class="justwave_play"/>',i+='<g class="justwave_pause" fill="#FFF">',i+='<rect height="19" width="5" y="12" x="15"/><rect height="19" width="5" y="12" x="23"/>',i+="</g>",i+="</svg>",i+="</button>",i+='<div class="audio_annotations"></div>',i+="</div>";var j=a("audio");null!==this.assignpart&&(j=a(".justwave"+this.assignpart.assignpartid).find("audio")),"string"==typeof b&&(h=b),"string"==typeof h&&(j=j.filter("."+h));var k=this.controler,l=this.assignpart;j.each(function(){var h=this,j=a(this);h.opts={ajax:"justWave/justwave.ajax.php",width:900,height:100,wave_color:"#909296",prog_color:"#74cdd7",back_color:"#FFFFFF",buttoncolor:"#A47655",buttonsize:0,showname:1,namesize:15,showtimes:1,nowaves:0,nocache:!0},a.isPlainObject(b)&&a.extend(h.opts,b),j.attr("width")&&(h.opts.width=j.attr("width")),j.attr("height")&&(h.opts.height=j.attr("height")),j.attr("poster")&&(h.opts.poster=j.attr("poster"));for(var m,n=0,o=h.attributes,p=o.length;n<p;n++)m=o[n],"data-"===m.nodeName.substring(0,5)&&(h.opts[m.nodeName.substring(5)]=m.nodeValue);h.opts.chained&&j.addClass("justwave_chained"),j.after(i).on("loadedmetadata",function(b){var c=b.target,h=a(c).next();f(c),g(c),c.xduration=c.duration,h.find(".justwave_duration").text(d(c.xduration)),c.opts.showtimes&&c.opts.showtimes>0?h.find(".justwave_duration, .justwave_curpos").show():h.find(".justwave_duration, .justwave_curpos").hide(),a(c).attr("src")?c.opts.audio=a(c).attr("src"):c.opts.audio=c.currentSrc;var i=h.find(".justwave_songname").css("font-size",c.opts.namesize+"px").text(decodeURIComponent(c.opts.audio.replace(/.+[\\\/]/,"")));c.opts.showname&&c.opts.showname>0&&e(i,!0),+c.opts.nowaves||a.ajax(c.opts.ajax,{dataType:"json",type:"POST",data:c.opts}).done(function(b){var e=a(c).next(),f=e.find(".justwave_wave"),g=e.find(".justwave_progress");"ok"===b.status&&(f.width(c.opts.width),g.width(c.opts.width),e.css("background",""),e.find(".justwave_playhead").css("background",""),c.opts.poster&&e.css("background-image","url("+c.opts.poster+")"),f.attr("src",b.waveurl),c.opts.wave_color===c.opts.prog_color?g.attr("src",b.waveurl):g.attr("src",b.progressurl)),c.xduration=parseFloat(b.duration),c.xduration||(c.xduration=c.duration),e.find(".justwave_duration").text(d(c.xduration))}),l&&l.notify("loadedmetadata",c)}).on("playing",function(b){var c=b.target,d=a(c).next();d.find(".justwave_pause").show(),d.find(".justwave_play").hide(),c.opts.chained&&a("audio.justwave_chained").each(function(){this!==c&&this.pause()}),k.notify("playing","player",c)}).on("pause",function(b){var c=a(b.target).next();c.find(".justwave_pause").hide(),c.find(".justwave_play").show()}).on("error",function(b){var c=b.target,d=a(c).next();f(c),d.find(".justwave_pause, .justwave_play").hide(),d.find(".justwave_playpause").prop("disabled",!0),d.find(".justwave_songname").text(a(c).attr("src").replace(/.+[\\\/]/,"")),d.find(".justwave_duration").text("00:00"),c.xduration=0,d.find(".justwave_duration, .justwave_curpos, .justwave_curfocus").hide(),k.notify("error","player",c)}).on("timeupdate",function(){c(this)}).on("ended",function(){this.pause()}),f(h),g(h);var q=j.next();q.click(function(b){b.preventDefault();var d=a(this).prev()[0],e=a(this).offset(),f=b.pageX-e.left;d.currentTime=f*d.xduration/this.offsetWidth,c(d),k.notify("click","player",d)}).mousemove(function(b){var c=a(this).offset(),f=b.pageX-c.left,g=b.pageY-c.top,h=this,i=a(this).prev()[0];a(h).find(".justwave_curfocus").text(d(f/this.offsetWidth*i.xduration)).css({top:g-5+"px",left:f+5+"px"}),i.opts.showname&&i.opts.showname>0&&e(a(h).find(".justwave_songname"))}).mouseleave(function(){a(this).find(".justwave_curfocus").hide(),a(this).find(".justwave_playpause").fadeOut(1e3)}).mouseenter(function(){var b=a(this).prev()[0];a(this).find(".justwave_playpause").stop(!1,!0).fadeIn(500),b.opts.showtimes&&b.opts.showtimes>0&&a(this).find(".justwave_curfocus").show(),k.notify("mouseenter","player",b)}),q.find(".justwave_playpause").on("click touchstart",function(b){b.stopPropagation(),b.preventDefault();var c=a(this).parent(),d=c.prev()[0];d.ended&&(d.currentTime=0),d.paused?d.play():d.pause(),k.notify("pause","player",d)}).mouseenter(function(){a(this).siblings(".justwave_curfocus").hide()}).mouseleave(function(){var b=a(this).parent().prev()[0];b.opts.showtimes&&b.opts.showtimes>0&&a(this).siblings(".justwave_curfocus").show(),k.notify("mouseleave","player",b)}),k.notify("initeach","player",h)})};var c=function(b){var c=b.currentTime/b.xduration*100,e=a(b).next();c<=100.1&&e.find(".justwave_playhead").width(c+"%"),e.find(".justwave_curpos").text(d(b.currentTime))},d=function(a){var b=Math.floor(a/60),c=Math.floor(a%60);return isNaN(a)?"00:00":(b<10?"0":"")+b+":"+(c<10?"0":"")+c},e=function(a,b){b&&a.stop(!0,!0).hide(),a.is(":visible")||a.fadeIn(300,function(){a.fadeOut(7e3,"swing")})},f=function(b){var c=a(b).next();c.find(".justwave_wave").width(0).attr("src",""),c.find(".justwave_progress").width(0).attr("src",""),c.width(b.opts.width).height(b.opts.height).css("background",b.opts.wave_color),b.opts.poster&&c.css("background-image","url("+b.opts.poster+")"),c.find(".justwave_playhead").css("background",b.opts.prog_color)},g=function(b){var c,d=a(b).next();b.opts.buttonsize?c=b.opts.buttonsize:(c=parseInt(.5*b.opts.height),c>88&&(c=88),c<33&&(c=b.opts.height-1)),d.find(".justwave_playpause").width(c).height(c).prop("disabled",!1).find("circle").attr({stroke:b.opts.buttoncolor,fill:b.opts.buttoncolor}),d.find(".justwave_pause").hide(),d.find(".justwave_play").show()};return b});
\ No newline at end of file
define(["jquery"],function(a){function b(a){b.repo="repo"in a?a.repo:null,b.limit="limit"in a&&a.limit>0?1e3*a.limit:null,this.init(),this.initTrigger()}b.mediaSource=null,b.constraints={audio:!0},b.sourceBuffer=null,b.mediaRecorder=null,b.recordedBlobs=null,b.errorMsgElement="#errorMsg",b.recordButton="#record",b.pauseRecordButton="#pauseRecord",b.playButton="#play",b.removeButton="#remove",b.recordedVideo="#recorded",b.repo=-1,b.initTimestamp=-1,b.timestampStop=0,b.limit=null;var c=function(){window.console.log("MediaSource opened"),b.sourceBuffer=b.mediaSource.addSourceBuffer("audio/ogg"),window.console.log("Source buffer: ",b.sourceBuffer)},d=function(c){a(b.recordButton).attr("disabled",!1),window.console.log("getUserMedia() got stream:",c),window.stream=c};b.prototype.init=function(){a("#audio").html(a("#audioworkspace").html()),a("#audioworkspace").remove(),a(b.recordedVideo).attr("src")&&(a(b.playButton).attr("disabled",!1),a(b.removeButton).attr("disabled",!1),a("input[name='file']").parent().parent().addClass("disabled")),b.mediaSource=new MediaSource,b.mediaSource.addEventListener("sourceopen",c,!1);try{navigator.mediaDevices.getUserMedia(b.constraints).then(function(a){d(a)})}catch(e){window.console.error("navigator.getUserMedia error:",e),a(b.errorMsgElement).html("navigator.getUserMedia error:"+e.toString())}},b.prototype.reset=function(){a(b.recordButton).attr("disabled",!1),a(b.recordedVideo).attr("src")&&(a(b.playButton).attr("disabled",!1),a(b.removeButton).attr("disabled",!1)),this.initTrigger()},b.prototype.initTrigger=function(){a(b.recordButton).on("click",function(){"stop"===a(b.recordButton).data("statut")?(a(b.recordedVideo).attr("src",null),h(),a(b.recordButton).data("statut","start"),a(b.pauseRecordButton).attr("disabled",!1),a(b.pauseRecordButton).data("statut","off"),a(b.pauseRecordButton).find(".fa-ban").hide()):(g(),a(b.recordButton).data("statut","stop"),a(b.recordButton).find("i").addClass("fa-microphone"),a(b.recordButton).find("i").removeClass("fa-microphone-slash"),a(b.recordButton).addClass("btn-primary"),a(b.recordButton).removeClass("btn-danger"),a(b.playButton).attr("disabled",!1),a(b.removeButton).attr("disabled",!1),a(b.pauseRecordButton).attr("disabled",!0),e())}),a(b.pauseRecordButton).on("click",function(){window.console.log(a(b.pauseRecordButton).data("statut")),"off"===a(b.pauseRecordButton).data("statut")?(i(),a(b.pauseRecordButton).data("statut","on"),a(b.pauseRecordButton).find(".fa-ban").show()):(j(),a(b.pauseRecordButton).data("statut","off"),a(b.pauseRecordButton).find(".fa-ban").hide())}),a(b.playButton).on("click",function(){if(!a(b.recordedVideo).attr("src")){var c=new Blob(b.recordedBlobs);a(b.recordedVideo).show(),a(b.recordedVideo).attr("src",null),a(b.recordedVideo).attr("srcObject",null),a(b.recordedVideo).attr("src",window.URL.createObjectURL(c))}a(b.recordedVideo).attr("controls",!0),a(b.recordedVideo).attr("autoplay",!0)}),a(b.removeButton).on("click",function(){a("input[name='filerecord']").val(-1),a("input[name='file']").parent().parent().removeClass("disabled"),a(b.playButton).attr("disabled",!0),a(b.removeButton).attr("disabled",!0),a(b.recordedVideo).hide(),a(b.recordedVideo).attr("src",null),a(b.recordedVideo).attr("srcObject",null)})};var e=function(){var c=new Blob(b.recordedBlobs),d=new window.FormData,e=(1e3*Math.random()).toString().replace(".","");d.append("repo_upload_file",c,e),d.append("itemid",e),d.append("title",e),d.append("repo_id",b.repo),d.append("env","editor"),d.append("sesskey",M.cfg.sesskey),d.append("savepath","/"),d.append("ctx_id",M.cfg.contextid);var f=M.cfg.wwwroot+"/repository/repository_ajax.php?action=upload",g=new XMLHttpRequest;g.onreadystatechange=function(){if(4===this.readyState&&200===this.status){var b=g.response,c=JSON.parse(b);a("input[name='filerecord']").val(c.file),a("input[name='file']").parent().parent().addClass("disabled"),a("#sendok").show().fadeOut(3e3)}else this.readyState>200&&a("#sendko").show()},g.open("POST",f,!0),g.send(d)},f=function(c){if(c.data&&c.data.size>0){b.initTimestamp<0&&(b.initTimestamp=c.timeStamp);var d=c.timeStamp-b.initTimestamp,e=new Date(d);e.setHours(e.getHours()-1);var f=e.getHours()<10?"0"+e.getHours():e.getHours(),g=e.getMinutes()<10?"0"+e.getMinutes():e.getMinutes(),h=e.getSeconds()<10?"0"+e.getSeconds():e.getSeconds(),i=f+":"+g+":"+h;a("#audiotime").text(i),b.limit&&d>b.limit&&0===b.timestampStop&&(b.timestampStop=1,a(b.recordButton).click()),b.recordedBlobs.push(c.data)}},g=function(){b.mediaRecorder.stop(),window.console.log("Recorded Blobs: ",b.recordedBlobs)},h=function(){b.recordedBlobs=[],b.initTimestamp=-1;var c=null;try{b.mediaRecorder=new MediaRecorder(window.stream,c)}catch(d){return window.console.error("Exception while creating MediaRecorder:",d),void a(b.errorMsgElement).html("Exception while creating MediaRecorder: "+JSON.stringify(d))}window.console.log("Created MediaRecorder",b.mediaRecorder,"with options",c),a(b.playButton).attr("disabled",!0),a(b.removeButton).attr("disabled",!0),a(b.recordButton).find("i").removeClass("fa-microphone"),a(b.recordButton).find("i").addClass("fa-microphone-slash"),a(b.recordButton).removeClass("btn-primary"),a(b.recordButton).addClass("btn-danger"),b.mediaRecorder.onstop=function(c){a("#audiotime").text(""),b.timestampStop=0,window.console.log("Recorder stopped: ",c)},b.mediaRecorder.ondataavailable=f,b.mediaRecorder.start(10),window.console.log("MediaRecorder started",b.mediaRecorder)},i=function(){b.mediaRecorder&&(b.mediaRecorder.pause(),window.console.log("MediaRecorder paused",b.mediaRecorder))},j=function(){b.mediaRecorder&&(a(b.playButton).attr("disabled",!0),a(b.removeButton).attr("disabled",!0),a(b.recordButton).find("i").removeClass("fa-microphone"),a(b.recordButton).find("i").addClass("fa-microphone-slash"),a(b.recordButton).removeClass("btn-primary"),a(b.recordButton).addClass("btn-danger"),b.mediaRecorder.resume(),window.console.log("MediaRecorder resumed",b.mediaRecorder))};return b});
\ No newline at end of file
define(["jquery"],function(a){function b(a){this.repo="repo"in a?a.repo:null,this.limit="limit"in a&&a.limit>0?1e3*a.limit:null,this.indice="indice"in a?a.indice:"",this.manager="manager"in a?a.manager:null,this.init(),this.initTrigger()}return b.mediaRecorder=null,b.recordedBlobs=null,b.errorMsgElement="#errorMsg",b.recordButton="#record",b.pauseRecordButton="#pauseRecord",b.playButton="#play",b.removeButton="#remove",b.recordedVideo="#recorded",b.repo=-1,b.initTimestamp=-1,b.timestampStop=0,b.limit=null,b.indice="",b.manager=null,b.prototype.init=function(){if(this.errorMsgElement="#errorMsg",this.recordButton="#record",this.pauseRecordButton="#pauseRecord",this.playButton="#play",this.removeButton="#remove",this.recordedVideo="#recorded",this.indice>=0){var b=this.indice,c=a("#audioworkspace").clone();c.find("[id]").each(function(){this.id+=b}),c.children().each(function(){a("#audio"+b).append(this)}),this.errorMsgElement+=this.indice,this.recordButton+=this.indice,this.pauseRecordButton+=this.indice,this.playButton+=this.indice,this.removeButton+=this.indice,this.recordedVideo+=this.indice}else a("#audio").html(a("#audioworkspace").html()),a("#audioworkspace").remove();var d=a("input[name='audio"+this.indice+"']").val();d&&(a(this.recordedVideo).attr("src",d),a(this.playButton).attr("disabled",!1),a(this.removeButton).attr("disabled",!1),a("input[name='file"+b+"']").parent().parent().addClass("disabled")),a(this.recordButton).data("statut","stop")},b.prototype.reset=function(){a(this.recordButton).attr("disabled",!1),a(this.recordedVideo).attr("src")&&(a(this.playButton).attr("disabled",!1),a(this.removeButton).attr("disabled",!1)),this.initTrigger()},b.prototype.initTrigger=function(){var c=this.pauseRecordButton,d=this.recordedVideo,e=this.playButton,f=this.removeButton,g=this.manager,h=this.indice,i=this.errorMsgElement;a(this.recordButton).on("click",function(){if("stop"===a(this).data("statut")){var b=g.startRecording(h);b?(a(d).attr("src",null),a(this).data("statut","start"),a(c).attr("disabled",!1),a(c).data("statut","off"),a(c).find(".fa-ban").hide(),a(e).attr("disabled",!0),a(f).attr("disabled",!0),a(this).find("i").removeClass("fa-microphone"),a(this).find("i").addClass("fa-microphone-slash"),a(this).removeClass("btn-primary"),a(this).addClass("btn-danger")):a(i).text("Un enregistrement est déjà en cours :un seul enregistrement à la fois est possible!")}else g.stopRecording(h),a(this).data("statut","stop"),a(this).find("i").addClass("fa-microphone"),a(this).find("i").removeClass("fa-microphone-slash"),a(this).addClass("btn-primary"),a(this).removeClass("btn-danger"),a(e).attr("disabled",!1),a(f).attr("disabled",!1),a(c).attr("disabled",!0)}),a(this.pauseRecordButton).on("click",function(){"off"===a(this).data("statut")?(g.pauseRecording(),a(this).data("statut","on"),a(this).find(".fa-ban").show()):(g.resumeRecording(),a(this).data("statut","off"),a(this).find(".fa-ban").hide())}),a(this.playButton).on("click",function(){if(!a(d).attr("src")){var c=new Blob(b.recordedBlobs);a(d).show(),a(d).attr("src",null),a(d).attr("srcObject",null),a(d).attr("src",window.URL.createObjectURL(c))}a(d).attr("controls",!0),a(d).attr("autoplay",!0)}),a(this.removeButton).on("click",function(){a("input[name='filerecord"+h+"']").val(-1),a("input[name='file"+h+"']").parent().parent().removeClass("disabled"),a(e).attr("disabled",!0),a(this).attr("disabled",!0),a(d).hide(),a(d).attr("src",null),a(d).attr("srcObject",null)})},b.prototype.sendBlob=function(a){b.recordedBlobs=a},b.prototype.stopRecord=function(){a(this.recordButton).click()},b});
\ No newline at end of file
define(["jquery","mod_audioannotation/record"],function(a,b){function c(a){c.repo="repo"in a?a.repo:null,c.limit="limit"in a&&a.limit>0?1e3*a.limit:null,c.nbRendu="nbRendu"in a&&a.nbRendu>0?a.nbRendu:1,this.init()}c.constraints={audio:!0},c.sourceBuffer=null,c.mediaRecorder=null,c.recordedBlobs=null,c.repo=-1,c.limit=null,c.nbRendu=1,c.records=null,c.statut="off",c.prototype.mediaSource=null,c.prototype.init=function(){c.records=[];for(var f=0;f<c.nbRendu;f++){var g=[];g.manager=this,g.limit=c.limit,g.repo=c.repo,g.indice=f,c.records[f]=new b(g)}a("#audioworkspace").remove(),c.mediaSource=new MediaSource,c.mediaSource.addEventListener("sourceopen",e,!1);try{navigator.mediaDevices.getUserMedia(c.constraints).then(function(a){d(a)})}catch(h){window.console.error("navigator.getUserMedia error:",h),a(c.errorMsgElement).html("navigator.getUserMedia error:"+h.toString())}};var d=function(b){a(".btn-record").attr("disabled",!1),window.console.log("getUserMedia() got stream:",b),window.stream=b},e=function(){window.console.log("MediaSource opened"),c.sourceBuffer=c.mediaSource.addSourceBuffer("audio/ogg"),window.console.log("Source buffer: ",c.sourceBuffer)};c.prototype.startRecording=function(b){if(window.console.log(c.statut),"off"!==c.statut)return!1;c.statut="on",c.recordedBlobs=[],c.initTimestamp=-1;var d=null;try{c.mediaRecorder=new MediaRecorder(window.stream,d)}catch(e){return window.console.error("Exception while creating MediaRecorder:",e),void a(this.errorMsgElement).html("Exception while creating MediaRecorder: "+JSON.stringify(e))}return window.console.log("Created MediaRecorder",c.mediaRecorder,"with options",d),c.mediaRecorder.addEventListener("stop",function(c){a("#audiotime"+b).text(""),this.timestampStop=0,window.console.log("Recorder stopped: ",c)},!1),c.mediaRecorder.addEventListener("dataavailable",function(a){f(a,b)},!1),c.mediaRecorder.start(10),window.console.log("MediaRecorder started",c.mediaRecorder),!0};var f=function(b,d){if(b.data&&b.data.size>0){c.initTimestamp<0&&(c.initTimestamp=b.timeStamp);var e=b.timeStamp-c.initTimestamp,f=new Date(e);f.setHours(f.getHours()-1);var g=f.getHours()<10?"0"+f.getHours():f.getHours(),h=f.getMinutes()<10?"0"+f.getMinutes():f.getMinutes(),i=f.getSeconds()<10?"0"+f.getSeconds():f.getSeconds(),j=g+":"+h+":"+i;a("#audiotime"+d).text(j),c.limit&&e>c.limit&&0===c.timestampStop&&(c.timestampStop=1,c.records[d].stopRecord()),c.recordedBlobs.push(b.data)}};return c.prototype.stopRecording=function(a){c.statut="off",c.mediaRecorder.stop(),window.console.log("Recorded Blobs: ",c.recordedBlobs);var b=c.recordedBlobs;c.records[a].sendBlob(b),this.sendFile(b,a)},c.prototype.sendFile=function(b,d){var e=new Blob(b),f=new window.FormData,g=(1e3*Math.random()).toString().replace(".","");f.append("repo_upload_file",e,g),f.append("itemid",g),f.append("title",g),f.append("repo_id",c.repo),f.append("env","editor"),f.append("sesskey",M.cfg.sesskey),f.append("savepath","/"),f.append("ctx_id",M.cfg.contextid);var h=M.cfg.wwwroot+"/repository/repository_ajax.php?action=upload",i=new XMLHttpRequest;i.addEventListener("readystatechange",function(){if(4===this.readyState&&200===this.status){var b=i.response,c=JSON.parse(b);a("input[name='filerecord"+d+"']").val(c.file),a("input[name='file"+d+"']").parent().parent().addClass("disabled"),a("#sendok"+d).show().fadeOut(3e3)}else this.readyState>200&&a("#sendko"+d).show()},!1),i.open("POST",h,!0),i.send(f)},c.prototype.pauseRecording=function(){c.mediaRecorder&&(c.mediaRecorder.pause(),window.console.log("MediaRecorder paused",c.mediaRecorder))},c.prototype.resumeRecording=function(){c.mediaRecorder&&(c.mediaRecorder.resume(),window.console.log("MediaRecorder resumed",c.mediaRecorder))},c.prototype.reset=function(){for(var a=0;a<c.records.length;a++)c.records[a].reset()},c});
\ No newline at end of file
......@@ -72,7 +72,7 @@ define(['jquery'],
* @param {object} data initial parameters
*/
function Annotation(data) {
Annotation.editor = data.editor;
this.editor = data.editor;
this.id = null;
this.timeposition = null;
this.isquestion = 0;
......@@ -127,10 +127,10 @@ define(['jquery'],
}
var annotation = this;
this.divDisplay.on('click', function () {
if (Annotation.editor.getEval() == 1) {
Annotation.editor.notify('edit', annotation);
if (annotation.editor.getEval() == 1) {
annotation.editor.notify('edit', annotation);
} else {
Annotation.editor.notify('view', annotation);
annotation.editor.notify('view', annotation);
}
});
};
......@@ -170,12 +170,12 @@ define(['jquery'],
* @returns {Jquery} the Jquery div object
*/
Annotation.prototype.buildDiv = function (annotWidth, draft) {
var color = Annotation.editor.getTagColor();
var color = this.editor.getTagColor();
if (draft) {
color = Annotation.DEFAULTCOLOR;
}
if (this.tag > -1) {
color = Annotation.editor.getTagColor(this.tag);
color = this.editor.getTagColor(this.tag);
}
var html = "<div style='background-color:" + color + ";";
html += "margin-left:" + annotWidth + "%;' ";
......@@ -211,7 +211,7 @@ define(['jquery'],
if (select) {
this.divDisplay.css('background-color', Annotation.DEFAULTCOLOR);
} else {
this.divDisplay.css('background-color', Annotation.editor.getTagColor(this.tag));
this.divDisplay.css('background-color', this.editor.getTagColor(this.tag));
}
this.divDisplay.data('annotation', this.id);
};
......
......@@ -36,10 +36,9 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
*************/
Controler.courseid = -1;
Controler.assignpartid = -1;
Controler.audioannotation = -1;
Controler.wavePlayer = null;
Controler.editor = null;
Controler.prototype.editors = null;
Controler.rightMenu = null;
Controler.lastP = null;
Controler.eval = 0;
......@@ -57,15 +56,14 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
function Controler(data) {
//get data
Controler.courseid = 'course' in data ? data['course'] : null;
Controler.assignpartid = 'assignpart' in data ? data['assignpart'] : null;
Controler.audioannotation = 'audioannotation' in data ? data['audioannotation'] : null;
Controler.eval = 'eval' in data ? data['eval'] : 0;
var repoid = 'repo' in data ? data['repo'] : null;
//parse elements
var annotationsRaw = 'annotations' in data ? data['annotations'] : null;
var annotations = null;
if (annotationsRaw) {
annotations = JSON.parse(annotationsRaw);
var assignPartsRaw = 'assignparts' in data ? data['assignparts'] : null;
var assignParts = null;
if (assignPartsRaw) {
assignParts = JSON.parse(assignPartsRaw);
}
var tagsRaw = 'tags' in data ? data['tags'] : null;
var tags = null;
......@@ -74,13 +72,18 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
}
//init composants
Controler.wavePlayer = new JustwavePlayer(this);
Controler.editor = new Editor({'controler': this,
'courseid': Controler.courseid, 'assignpartid': Controler.assignpartid,
'annotations': annotations, 'audioannotation': Controler.audioannotation,
'tags': tags, 'repo': repoid});
Controler.editors = [];
for (var i = 0; i < assignParts.length; i++) {
Controler.editors[assignParts[i].id] = new Editor({'controler': this,
'courseid': Controler.courseid, 'assignpart': assignParts[i],
'audioannotation': Controler.audioannotation,
'tags': tags, 'repo': repoid});
var wavePlayerEditor = new JustwavePlayer(this, Controler.editors[assignParts[i].id]);
Controler.editors[assignParts[i].id].setWavePlayer(wavePlayerEditor);
this.initWave(wavePlayerEditor, 'justwave', assignParts[i].id);
}
//init listener and object
this.initTrigger();
this.initWave('justwave');
//init right context menu
Controler.rightMenu = new RightMenu({'controler': this});
}
......@@ -95,50 +98,51 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
*/
Controler.prototype.initTrigger = function () {
if (Controler.eval == 1) {
$("#btn_add_annotation").on('click', function () {
Controler.editor.notify("add", Controler.lastP);
$(".btn_add_annotation").on('click', function () {
//alert($(this).data('assignpart'));
Controler.editors[$(this).data('assignpart')].notify("add");
});
}
$("#select_tag").on('change', displayTQS);
$("#select_question").on('change', displayTQS);
$("#select_statut").on('change', displayTQS);
$(".select_tqs").on('change', function () {
var assignpartid = $(this).data('assignpart');
Controler.editors[assignpartid].notify("displaytqs",
{'tag': $("#select_tag" + assignpartid).val(),
'question': $("#select_question" + assignpartid).val(),
'statut': $("#select_statut" + assignpartid).val()}
);
});
$("li[data-annotation]").on('click', function () {
var annotationid = $(this).data('annotation');
var assignpartid = $(this).parents(".annotationGroupAccordion").data('assignpart');
if (annotationid) {
Controler.editor.notify("view",
Controler.editors[assignpartid].notify("view",
{'annotation': annotationid}
);
}
});
};
/**
* Refresh display when filter by tag or question or statut is set
*/
var displayTQS = function () {
Controler.editor.notify("displaytqs",
{'tag': $("#select_tag").val(),
'question': $("#select_question").val(),
'statut': $("#select_statut").val()}
);
};
/**
* Init waveplayer picture and web player with waveform
* @param {array} opt Array with init parameters
*/
Controler.prototype.initWave = function (opt) {
Controler.wavePlayer.init(opt);
Controler.prototype.initWave = function (playerwave, opt, assignpartid) {
playerwave.init(opt);
//load waveform (event conflict, click to start and click to stop to force loading)
$('.justwave_playpause').click(); //start
$('.justwave_playpause').click(); //stop
$('.justwave' + assignpartid + ' .justwave_playpause').click(); //start
$('.justwave' + assignpartid + ' .justwave_playpause').click(); //stop
};
/**
* Init dispay's annotations
*/
Controler.prototype.initAnnotations = function () {
Controler.editor.initAnnotationsDisplay();
for (var i = 0; i < Controler.editors.length; i++) {
if (!Controler.editors[i]) {
continue;
}
Controler.editors[i].initAnnotationsDisplay();
}
};
/**
......@@ -148,33 +152,60 @@ define(['jquery', 'mod_audioannotation/justWave', 'mod_audioannotation/editor',
* @param {object} object Element to proceed
*/
Controler.prototype.notify = function (event, agent, object) {
if (agent === "player") {
Controler.lastP = object;
}
/*if (agent === "player") {
console.log(Controler.editors);
Controler.editors[object.assignpartid].setWavePlayer(object);
//Controler.lastP = object;
}*/
switch (event) {
case "loadedmetadata" :
this.initAnnotations();
break;
case "drawannotation_draft":
Controler.wavePlayer.drawAnnotation(Controler.lastP, object, 1);
break;
case "drawannotation":
Controler.wavePlayer.drawAnnotation(Controler.lastP, object, 0);
break;
/*case "drawannotation_draft":
Controler.wavePlayer.drawAnnotation(Controler.lastP, object, 1);
break;*/
/*case "drawannotation":
Controler.wavePlayer.drawAnnotation(Controler.lastP, object, 0);
break;*/
case "addannotation":
Controler.editor.setEditorStatus('add');
for (var i = 0; i < Controler.editors.length; i++) {
if (!Controler.editors[i]) {
continue;
}
Controler.editors[i].setEditorStatus('add');
}
break;
case "editannotation":
Controler.editor.setEditorStatus('edit');
for (var i = 0; i < Controler.editors.length; i++) {
if (!Controler.editors[i]) {
continue;
}
Controler.editors[i].setEditorStatus('edit');
}
break;
case "viewannotation":
Controler.editor.setEditorStatus('view');
for (var i = 0; i < Controler.editors.length; i++) {
if (!Controler.editors[i]) {
continue;
}
Controler.editors[i].setEditorStatus('view');
}
break;
case "deleteannotation":
if (agent === "rightMenu") {
Controler.editor.notify("delete", object);
for (var i = 0; i < Controler.editors.length; i++) {
if (!Controler.editors[i]) {
continue;
}
Controler.editors[i].notify("delete", object);
}
} else {
Controler.editor.setEditorStatus('delete');
for (var i = 0; i < Controler.editors.length; i++) {
if (!Controler.editors[i]) {
continue;
}
Controler.editors[i].setEditorStatus('delete');
}
}
break;
default:
......
This diff is collapsed.
......@@ -75,6 +75,7 @@ define(['jquery'],
*************/
JustWave.controler = null;
JustWave.assignpart = -1;
/********************************
* CONSTRUCTOR *
......@@ -89,8 +90,9 @@ define(['jquery'],
* @param {Controler} controler Master class of the class
* @param {string} tmpdir Path to tmp dir
*/
function JustWave(controler) {
function JustWave(controler, assignpart) {
this.controler = controler;
this.assignpart = assignpart;
// Return this object reference.
return(this);
}
......@@ -140,6 +142,9 @@ define(['jquery'],
html += '</div>';
var els = $('audio');
if (this.assignpart !== null) {
els = $('.justwave' + this.assignpart.assignpartid).find('audio');
}
// reduce elements' set if classOnly is defined and is a string
if (typeof options === 'string') {
classOnly = options;
......@@ -150,6 +155,7 @@ define(['jquery'],
}
var controlerNot = this.controler;
var assignpartNot = this.assignpart;
els.each(function () {
var p = this; // audio DOM element
var $p = $(this); // jquery element
......@@ -276,7 +282,10 @@ define(['jquery'],
}); // done
}
controlerNot.notify("loadedmetadata", "player", p);
if (assignpartNot) {
assignpartNot.notify("loadedmetadata", p);
//controlerNot.notify("loadedmetadata", "player", p);
}
}) // loadedmetadata
.on('playing', function (e) {
var p = e.target;
......
This diff is collapsed.
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/*
* @package mod_audioannotation
* @copyright 2018 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/* global M, MediaRecorder */
/**
* Record class, record sound on web page, and send file restult to Moodle, with Moodle API
*
* @module mod_audioannotation/RecordsManager
* @param {Jquery} $
* inspired by https://github.com/webrtc/samples/blob/gh-pages/src/content/getusermedia/record/js/main.js
*/
define(['jquery', 'mod_audioannotation/record'],
function ($, Record) {
/*************
* CONSTANTES *
*************/
RecordsManager.constraints = {
audio: true
};
RecordsManager.sourceBuffer = null;
RecordsManager.mediaRecorder = null;
RecordsManager.recordedBlobs = null;
RecordsManager.repo = -1;
RecordsManager.limit = null;
RecordsManager.nbRendu = 1;
RecordsManager.records = null;
RecordsManager.statut = 'off';
RecordsManager.prototype.mediaSource = null;
/********************************
* CONSTRUCTOR *
********************************/
/**
* Record class.
*
* @class RecordsManager
*
* @param {array} data array with parameters for initializing the class
*/
function RecordsManager(data) {
//get data
RecordsManager.repo = 'repo' in data ? data['repo'] : null;
RecordsManager.limit = 'limit' in data && data['limit'] > 0 ? data['limit'] * 1000 : null;
RecordsManager.nbRendu = 'nbRendu' in data && data['nbRendu'] > 0 ? data['nbRendu'] : 1;
//initialize
this.init();
}