Gitlab CSE Unil

Commit aa5d506f authored by M. Chardon's avatar M. Chardon
Browse files

- creation menu

- optimisation sonar
parent a4da6870
This diff is collapsed.
define(["jquery"],function(a){function b(a,c){return this.controler=a,this.assignpart=c,b.clickAnnotation=0,this}b.controler=null,b.assignpart=-1,b.clickAnnotation=0,b.delayBeforeAnnotation=2,b.options=null,b.prototype.drawAnnotation=function(b,c,d){if(b&&b.duration){var e=c.timeposition/b.duration*100,f=a(b).next(),g=c.displayDiv(e,d);f.find(".audio_annotations").append(g)}},b.prototype.goBeforeAnnotation=function(a,d){a&&(a.currentTime=Math.max(d.timeposition-b.delayBeforeAnnotation,0),c(a),b.clickAnnotation=1)},b.prototype.getWaveOpts=function(c){var d={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.options)&&a.extend(d,b.options),c.attr("width")&&(d.width=c.attr("width")),c.attr("height")&&(d.height=c.attr("height")),c.attr("poster")&&(d.poster=c.attr("poster"));var e=c.data();return Object.keys(e).map(function(a){d[a]=e[a]}),d},b.prototype.init=function(h,i){var j=a("#player_markup > div.justwave_wrapper").clone(),k=a("audio");null!==this.assignpart&&(k=a(".justwave"+this.assignpart.assignpartid).find("audio")),"string"==typeof h&&(i=h),"string"==typeof i&&(k=k.filter("."+i));var l=this.controler,m=this.assignpart,n=this.getWaveOpts;k.each(function(){var h=this,i=a(this);h.opts=n(i),h.opts.chained&&i.addClass("justwave_chained"),i.after(j),a(h).on("canplay",function(b){var c=b.target,d=a(c).next();c.xduration=c.duration,c.opts.showtimes&&c.opts.showtimes>0?d.find(".justwave_duration, .justwave_curpos").show():d.find(".justwave_duration, .justwave_curpos").hide()}).on("playing",function(b){var c=b.target,d=a(c).next();d.find(".justwave_playpause i.fa").addClass("fa-pause"),d.find(".justwave_playpause i.fa").removeClass("fa-play"),c.opts.chained&&a("audio.justwave_chained").each(function(){this!==c&&this.pause()}),l.notify("playing","player",c)}).on("pause",function(b){var c=a(b.target).next();c.find(".justwave_playpause i.fa").addClass("fa-play"),c.find(".justwave_playpause i.fa").removeClass("fa-pause")}).on("error",function(b){var c=b.target,d=a(c).next();f(c),d.find(".justwave_playpause").prop("disabled",!0),d.find(".justwave_playpause_before").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(),l.notify("error","player",c)}).on("timeupdate",function(){c(this)}).on("ended",function(){this.pause()}),f(h),g(h);var k=i.next();k.click(function(d){if(!b.clickAnnotation||0===b.clickAnnotation){d.preventDefault();var e=a(this).prev()[0],f=a(this).offset(),g=d.pageX-f.left;e.currentTime=g*e.xduration/this.offsetWidth,c(e),m.notify("click",e.currentTime)}b.clickAnnotation=0}).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),a(this).find(".justwave_playpause_before").fadeOut(1e3)}).mouseenter(function(){var b=a(this).prev()[0];a(this).find(".justwave_playpause").stop(!1,!0).fadeIn(500),a(this).find(".justwave_playpause_before").stop(!1,!0).fadeIn(500),b.opts.showtimes&&b.opts.showtimes>0&&a(this).find(".justwave_curfocus").show(),l.notify("mouseenter","player",b)}).dblclick(function(){b.clickAnnotation&&0!==b.clickAnnotation||(h.pause(),m.notify("dblclick")),b.clickAnnotation=0}),k.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(),m.notify("pause",d.currentTime)),l.notify("pause","player",d)}),k.find(".justwave_playpause_before").on("click touchstart",function(d){d.stopPropagation(),d.preventDefault();var e=a(this).parent(),f=e.prev()[0];f.ended&&(f.currentTime=0),f.currentTime=Math.max(f.currentTime-b.delayBeforeAnnotation,0),c(f)}).on("dblclick",function(a){a.stopPropagation(),a.preventDefault()}),k.find(".justwave_playpause_btn").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()});var o=k.parents('div[data-parent="#accordionAssignPart"]');o.attr("tabindex",0),o.on("keydown",function(a){32===a.which&&(a.preventDefault(),k.find("button.justwave_playpause").click()),66===a.which&&(a.preventDefault(),k.find("button.justwave_playpause_before").click()),78===a.which&&(a.preventDefault(),h.pause(),m.notify("pause",h.currentTime),m.notify("dblclick"))}),l.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=a(b).next();c.find(".justwave_playpause i.fa").addClass("fa-play"),c.find(".justwave_playpause i.fa").removeClass("fa-pause")};return b.prototype.drawWaveDisplay=function(b){var c=this.assignpart;b.opts=this.getWaveOpts(b);var h=new Audio;a(h).on("loadedmetadata",function(){var h=a(b).next();f(b),g(b),a(b).attr("src")?b.opts.audio=a(b).attr("src"):b.opts.audio=b.currentSrc;var i=h.find(".justwave_songname").css("font-size",b.opts.namesize+"px").text(decodeURIComponent(b.opts.audio.replace(/.+[\\\/]/,"")));b.opts.showname&&b.opts.showname>0&&e(i,!0),+b.opts.nowaves||a.ajax(b.opts.ajax,{dataType:"json",type:"POST",data:b.opts}).done(function(e){var f=a(b).next(),g=f.find(".justwave_wave"),h=f.find(".justwave_progress");"ok"===e.status&&(g.width(b.opts.width),h.width(b.opts.width),f.css("background",""),f.find(".justwave_playhead").css("background",""),b.opts.poster&&f.css("background-image","url("+b.opts.poster+")"),g.attr("src",e.waveurl),b.opts.wave_color===b.opts.prog_color?h.attr("src",e.waveurl):h.attr("src",e.progressurl)),b.xduration=parseFloat(e.duration),b.xduration||(b.xduration=b.duration),b.xduration&&!b.duration&&(b.duration=e.duration),f.find(".justwave_duration").text(d(b.xduration));var i=a(f).prev()[0];i.xduration=b.xduration,i.duration=b.duration,c&&c.notify("loadedmetadata",b)})}),h.src=a(b).attr("src")},b});
\ No newline at end of file
define(["jquery"],function(a){function b(a,c){return this.controler=a,this.assignpart=c,b.clickAnnotation=0,this}b.controler=null,b.assignpart=-1,b.clickAnnotation=0,b.delayBeforeAnnotation=2,b.options=null,b.prototype.PLAYPAUSEBUTTON=".justwave_playpause",b.prototype.PLAYPAUSEBUTTONBEFORE=".justwave_playpause_before",b.prototype.CURRENTFOCUS=".justwave_curfocus",b.prototype.drawAnnotation=function(b,c,d){if(b&&b.duration){var e=c.timeposition/b.duration*100,f=a(b).next(),g=c.displayDiv(e,d);f.find(".audio_annotations").append(g)}},b.prototype.goBeforeAnnotation=function(a,d){a&&(a.currentTime=Math.max(d.timeposition-b.delayBeforeAnnotation,0),c(a),b.clickAnnotation=1)},b.prototype.getWaveOpts=function(c){var d={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.options)&&a.extend(d,b.options),c.attr("width")&&(d.width=c.attr("width")),c.attr("height")&&(d.height=c.attr("height")),c.attr("poster")&&(d.poster=c.attr("poster"));var e=c.data();return Object.keys(e).map(function(a){return d[a]=e[a],d[a]}),d},b.prototype.init=function(h,i){var j=a("#player_markup > div.justwave_wrapper").clone(),k=a("audio");null!==this.assignpart&&(k=a(".justwave"+this.assignpart.assignpartid).find("audio")),"string"==typeof h&&(i=h),"string"==typeof i&&(k=k.filter("."+i));var l=this.controler,m=this.assignpart,n=this.getWaveOpts;k.each(function(){var h=this,i=a(this);h.opts=n(i),h.opts.chained&&i.addClass("justwave_chained"),i.after(j),a(h).on("canplay",function(b){var c=b.target,d=a(c).next();c.xduration=c.duration,c.opts.showtimes&&c.opts.showtimes>0?d.find(".justwave_duration, .justwave_curpos").show():d.find(".justwave_duration, .justwave_curpos").hide()}).on("playing",function(c){var d=c.target,e=a(d).next();e.find(b.prototype.PLAYPAUSEBUTTON+" i.fa").addClass("fa-pause"),e.find(b.prototype.PLAYPAUSEBUTTON+" i.fa").removeClass("fa-play"),d.opts.chained&&a("audio.justwave_chained").each(function(){this!==d&&this.pause()}),l.notify("playing","player",d)}).on("pause",function(c){var d=a(c.target).next();d.find(b.prototype.PLAYPAUSEBUTTON+" i.fa").addClass("fa-play"),d.find(b.prototype.PLAYPAUSEBUTTON+" i.fa").removeClass("fa-pause")}).on("error",function(c){var d=c.target,e=a(d).next();f(d),e.find(b.prototype.PLAYPAUSEBUTTON).prop("disabled",!0),e.find(b.prototype.PLAYPAUSEBUTTONBEFORE).prop("disabled",!0),e.find(".justwave_songname").text(a(d).attr("src").replace(/.+[\\\/]/,"")),e.find(".justwave_duration").text("00:00"),d.xduration=0,e.find(".justwave_duration, .justwave_curpos, "+b.prototype.CURRENTFOCUS).hide(),l.notify("error","player",d)}).on("timeupdate",function(){c(this)}).on("ended",function(){this.pause()}),f(h),g(h);var k=i.next();k.click(function(d){if(!b.clickAnnotation||0===b.clickAnnotation){d.preventDefault();var e=a(this).prev()[0],f=a(this).offset(),g=d.pageX-f.left;e.currentTime=g*e.xduration/this.offsetWidth,c(e),m.notify("click",e.currentTime)}b.clickAnnotation=0}).mousemove(function(c){var f=a(this).offset(),g=c.pageX-f.left,h=c.pageY-f.top,i=this,j=a(this).prev()[0];a(i).find(b.prototype.CURRENTFOCUS).text(d(g/this.offsetWidth*j.xduration)).css({top:h-5+"px",left:g+5+"px"}),j.opts.showname&&j.opts.showname>0&&e(a(i).find(".justwave_songname"))}).mouseleave(function(){a(this).find(b.prototype.CURRENTFOCUS).hide(),a(this).find(b.prototype.PLAYPAUSEBUTTON).fadeOut(1e3),a(this).find(b.prototype.PLAYPAUSEBUTTONBEFORE).fadeOut(1e3)}).mouseenter(function(){var c=a(this).prev()[0];a(this).find(b.prototype.PLAYPAUSEBUTTON).stop(!1,!0).fadeIn(500),a(this).find(b.prototype.PLAYPAUSEBUTTONBEFORE).stop(!1,!0).fadeIn(500),c.opts.showtimes&&c.opts.showtimes>0&&a(this).find(b.prototype.CURRENTFOCUS).show(),l.notify("mouseenter","player",c)}).dblclick(function(){b.clickAnnotation&&0!==b.clickAnnotation||(h.pause(),m.notify("dblclick")),b.clickAnnotation=0}),k.find(b.prototype.PLAYPAUSEBUTTON).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(),m.notify("pause",d.currentTime)),l.notify("pause","player",d)}),k.find(b.prototype.PLAYPAUSEBUTTONBEFORE).on("click touchstart",function(d){d.stopPropagation(),d.preventDefault();var e=a(this).parent(),f=e.prev()[0];f.ended&&(f.currentTime=0),f.currentTime=Math.max(f.currentTime-b.delayBeforeAnnotation,0),c(f)}).on("dblclick",function(a){a.stopPropagation(),a.preventDefault()}),k.find(".justwave_playpause_btn").mouseenter(function(){a(this).siblings(b.prototype.CURRENTFOCUS).hide()}).mouseleave(function(){var c=a(this).parent().prev()[0];c.opts.showtimes&&c.opts.showtimes>0&&a(this).siblings(b.prototype.CURRENTFOCUS).show()});var o=k.parents('div[data-parent="#accordionAssignPart"]');o.attr("tabindex",0),o.on("keydown",function(a){32===a.which&&(a.preventDefault(),k.find("button"+b.prototype.PLAYPAUSEBUTTON).click()),66===a.which&&(a.preventDefault(),k.find("button"+b.prototype.PLAYPAUSEBUTTONBEFORE).click()),78===a.which&&(a.preventDefault(),h.pause(),m.notify("pause",h.currentTime),m.notify("dblclick"))}),l.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(c){var d=a(c).next();d.find(b.prototype.PLAYPAUSEBUTTON+" i.fa").addClass("fa-play"),d.find(b.prototype.PLAYPAUSEBUTTON+" i.fa").removeClass("fa-pause")};return b.prototype.drawWaveDisplay=function(b){var c=this.assignpart;b.opts=this.getWaveOpts(b);var h=new Audio;a(h).on("loadedmetadata",function(){var h=a(b).next();f(b),g(b),a(b).attr("src")?b.opts.audio=a(b).attr("src"):b.opts.audio=b.currentSrc;var i=h.find(".justwave_songname").css("font-size",b.opts.namesize+"px").text(decodeURIComponent(b.opts.audio.replace(/.+[\\\/]/,"")));b.opts.showname&&b.opts.showname>0&&e(i,!0),+b.opts.nowaves||a.ajax(b.opts.ajax,{dataType:"json",type:"POST",data:b.opts}).done(function(e){var f=a(b).next(),g=f.find(".justwave_wave"),h=f.find(".justwave_progress");"ok"===e.status&&(g.width(b.opts.width),h.width(b.opts.width),f.css("background",""),f.find(".justwave_playhead").css("background",""),b.opts.poster&&f.css("background-image","url("+b.opts.poster+")"),g.attr("src",e.waveurl),b.opts.wave_color===b.opts.prog_color?h.attr("src",e.waveurl):h.attr("src",e.progressurl)),b.xduration=parseFloat(e.duration),b.xduration||(b.xduration=b.duration),b.xduration&&!b.duration&&(b.duration=e.duration),f.find(".justwave_duration").text(d(b.xduration));var i=a(f).prev()[0];i.xduration=b.xduration,i.duration=b.duration,c&&c.notify("loadedmetadata",b)})}),h.src=a(b).attr("src")},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(),this.initDisplay()}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.pauseTimestamp=0,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)}if(a("#audioworkspace").remove(),c.mediaSource=new MediaSource,c.mediaSource.addEventListener("sourceopen",e,!1),!navigator.mediaDevices||!window.MediaRecorder)return a(".webrtcsupport").show(),void a(".record-tool").hide();if(!navigator.mediaDevices.getUserMedia)return a(".webrtcsupport").show(),a(".record-tool").hide(),void window.console.log("getUserMedia is not supported by your browser");navigator.permissions.query({name:"microphone"}).then(function(a){window.console.log(a.state),window.stream&&window.stream.getTracks().forEach(function(a){a.stop()})})["catch"](function(a){window.console.log("Got error :",a)}),c.mediaRecorder&&"inactive"!==c.mediaRecorder.state&&c.mediaRecorder.stop(),window.stream&&window.stream.getTracks().forEach(function(a){"ended"!==a.readyState&&a.stop()});var h=null;navigator.mediaDevices.enumerateDevices().then(function(b){function e(a){window.console.log("Got stream, time diff :",Date.now()-l),d(a)}function f(a){m++;var b={audio:{deviceId:{exact:a}}};navigator.mediaDevices.getUserMedia(b).then(e)["catch"](g)}function g(b){i&&m<i.length?f(i[m]):(a(".microphone").show(),a(".record-tool").hide(),window.console.log("GUM failed with error, time diff: ",Date.now()-l),window.console.error("navigator.getUserMedia error:",b.name+": "+b.message),a(c.errorMsgElement).html("navigator.getUserMedia error:"+b.toString()))}var i=[];window.console.log(b);for(var j=0;j!==b.length;++j){var k=b[j];"audioinput"===k.kind&&(h=k.deviceId,window.console.log(h),i.push(h))}if(!h)return a(".microphone").show(),void a(".record-tool").hide();var l=Date.now(),m=0;navigator.mediaDevices.getUserMedia({audio:!0}).then(e)["catch"](g)})},c.prototype.initDisplay=function(){a.fn.justtext=function(){return a(this).clone().children().remove().end().text()},a(".audiofilepicker .form-filetypes-descriptions > ul").each(function(){var b=a(this).children("li");if(b&&!(b.length<2)){var c=a("<li></li>"),d=b[0],e=a(d).justtext();e=e.replace(/\ \((.*)\)/g,""),c.append(e);var f=a(d).children(),g="";f.each(function(){g=a(this).clone(),g.html("")}),b.each(function(){a(this).children().each(function(){g.append(a(this).text()+" ")}),a(this).remove()}),c.append(g),a(this).append(c)}})};var d=function(b){a(".btn-record").each(function(){a(this).prop("indice")>=0&&c.records[a(this).prop("indice")].initDisplayRecordButton(!0)}),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("off"!==c.statut)return!1;c.statut="on",c.recordedBlobs=[],c.initTimestamp=-1,c.pauseTimestamp=0;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(d){a("#audiotime"+b).text(""),c.timestampStop=0,window.console.log("Recorder stopped: ",d)},!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-c.pauseTimestamp,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&&(c.timestampStop&&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){a("#sending"+d).show(),a("input[type=submit]").addClass("disabled"),a("input[type=submit]").attr("disabled","disabled"),a("input[type=submit]").prop("disabled",!0);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){a("#sending"+d).hide(),a("input[type=submit]").removeClass("disabled"),a("input[type=submit]").attr("disabled","false"),a("input[type=submit]").prop("disabled",!1);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()}else this.readyState>200&&(a("#sending"+d).hide(),a("input[type=submit]").removeClass("disabled"),a("input[type=submit]").attr("disabled","false"),a("input[type=submit]").prop("disabled",!1),a("#sendko"+d).show())},!1),i.open("POST",h,!0),i.send(f)},c.prototype.pauseRecording=function(a){c.mediaRecorder&&(c.pauseBeginTimestamp=a.timeStamp,c.mediaRecorder.pause(),window.console.log("MediaRecorder paused",c.mediaRecorder))},c.prototype.resumeRecording=function(a){c.mediaRecorder&&(c.pauseTimestamp+=a.timeStamp-c.pauseBeginTimestamp,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
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(),this.initDisplay()}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.pauseTimestamp=0,c.prototype.RECORDINGTOOLS=".record-tool",c.prototype.VALIDATIONBUTTON="input[type=submit]",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)}if(a("#audioworkspace").remove(),c.mediaSource=new MediaSource,c.mediaSource.addEventListener("sourceopen",e,!1),!navigator.mediaDevices||!window.MediaRecorder)return a(".webrtcsupport").show(),void a(c.prototype.RECORDINGTOOLS).hide();if(!navigator.mediaDevices.getUserMedia)return a(".webrtcsupport").show(),a(c.prototype.RECORDINGTOOLS).hide(),void window.console.log("getUserMedia is not supported by your browser");navigator.permissions.query({name:"microphone"}).then(function(a){window.console.log(a.state),window.stream&&window.stream.getTracks().forEach(function(a){a.stop()})})["catch"](function(a){window.console.log("Got error :",a)}),c.mediaRecorder&&"inactive"!==c.mediaRecorder.state&&c.mediaRecorder.stop(),window.stream&&window.stream.getTracks().forEach(function(a){"ended"!==a.readyState&&a.stop()});var h=null;navigator.mediaDevices.enumerateDevices().then(function(b){function e(a){window.console.log("Got stream, time diff :",Date.now()-l),d(a)}function f(a){m++;var b={audio:{deviceId:{exact:a}}};navigator.mediaDevices.getUserMedia(b).then(e)["catch"](g)}function g(b){i&&m<i.length?f(i[m]):(a(".microphone").show(),a(c.prototype.RECORDINGTOOLS).hide(),window.console.log("GUM failed with error, time diff: ",Date.now()-l),window.console.error("navigator.getUserMedia error:",b.name+": "+b.message),a(c.errorMsgElement).html("navigator.getUserMedia error:"+b.toString()))}var i=[];window.console.log(b);for(var j=0;j!==b.length;++j){var k=b[j];"audioinput"===k.kind&&(h=k.deviceId,window.console.log(h),i.push(h))}if(!h)return a(".microphone").show(),void a(c.prototype.RECORDINGTOOLS).hide();var l=Date.now(),m=0;navigator.mediaDevices.getUserMedia({audio:!0}).then(e)["catch"](g)})},c.prototype.initDisplay=function(){a.fn.justtext=function(){return a(this).clone().children().remove().end().text()},a(".audiofilepicker .form-filetypes-descriptions > ul").each(function(){var b=a(this).children("li");if(b&&!(b.length<2)){var c=a("<li></li>"),d=b[0],e=a(d).justtext();e=e.replace(/\ \((.*)\)/g,""),c.append(e);var f=a(d).children(),g="";f.each(function(){g=a(this).clone(),g.html("")}),b.each(function(){a(this).children().each(function(){g.append(a(this).text()+" ")}),a(this).remove()}),c.append(g),a(this).append(c)}})};var d=function(b){a(".btn-record").each(function(){a(this).prop("indice")>=0&&c.records[a(this).prop("indice")].initDisplayRecordButton(!0)}),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("off"!==c.statut)return!1;c.statut="on",c.recordedBlobs=[],c.initTimestamp=-1,c.pauseTimestamp=0;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(d){a("#audiotime"+b).text(""),c.timestampStop=0,window.console.log("Recorder stopped: ",d)},!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-c.pauseTimestamp,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&&(c.timestampStop&&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){a("#sending"+d).show(),a(c.prototype.VALIDATIONBUTTON).addClass("disabled"),a(c.prototype.VALIDATIONBUTTON).attr("disabled","disabled"),a(c.prototype.VALIDATIONBUTTON).prop("disabled",!0);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){a("#sending"+d).hide(),a(c.prototype.VALIDATIONBUTTON).removeClass("disabled"),a(c.prototype.VALIDATIONBUTTON).attr("disabled","false"),a(c.prototype.VALIDATIONBUTTON).prop("disabled",!1);var b=i.response,e=JSON.parse(b);a("input[name='filerecord"+d+"']").val(e.file),a("input[name='file"+d+"']").parent().parent().addClass("disabled"),a("#sendok"+d).show()}else this.readyState>200&&(a("#sending"+d).hide(),a(c.prototype.VALIDATIONBUTTON).removeClass("disabled"),a(c.prototype.VALIDATIONBUTTON).attr("disabled","false"),a(c.prototype.VALIDATIONBUTTON).prop("disabled",!1),a("#sendko"+d).show())},!1),i.open("POST",h,!0),i.send(f)},c.prototype.pauseRecording=function(a){c.mediaRecorder&&(c.pauseBeginTimestamp=a.timeStamp,c.mediaRecorder.pause(),window.console.log("MediaRecorder paused",c.mediaRecorder))},c.prototype.resumeRecording=function(a){c.mediaRecorder&&(c.pauseTimestamp+=a.timeStamp-c.pauseBeginTimestamp,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
......@@ -106,6 +106,15 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
11: "#0084d1"
};
Editor.prototype.TAGDEFAULTCOLOR = "blue";
Editor.prototype.ADDANNOTATIONCLASS = ".annotation_add";
Editor.prototype.VIEWANNOTATIONCLASS = ".annotation_view";
Editor.prototype.ANNOTFORMBTNCANCEL = "#annot_form_btn_cancel";
Editor.prototype.ANNOTFORMBTNVALID = "#annot_form_btn_valid";
Editor.prototype.ANNOTATIONFORM = "form[name=mod_audioannotation_form_annotation_form]";
Editor.prototype.DIVANNOTATIONERROR = "#annotationError";
Editor.prototype.INPUTFILTERQUESTION = "[name='isquestion']";
Editor.prototype.ANNOTLABELQUESTION = "#annot_form_btn_question_label";
Editor.prototype.FILEINPUT = "#fileinput";
//error messages
Editor.messageErrorSave = "error";
......@@ -261,8 +270,8 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
* @param {Annotation} annotation
*/
var closeAddForm = function (annotation) {
$(".annotation_add").hide();
$(".annotation_add").html("");
$(Editor.prototype.ADDANNOTATIONCLASS).hide();
$(Editor.prototype.ADDANNOTATIONCLASS).html("");
if (annotation && annotation.id) {
//refresh annotation display on audio graph
annotation.refreshDiv();
......@@ -291,9 +300,9 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
* @param {Annotation} annotation
*/
var closeViewForm = function (annotation) {
$(".annotation_view").hide();
$(".annotation_view").html("");
$(".annotation_view").css('border', "none");
$(Editor.prototype.VIEWANNOTATIONCLASS).hide();
$(Editor.prototype.VIEWANNOTATIONCLASS).html("");
$(Editor.prototype.VIEWANNOTATIONCLASS).css('border', "none");
if (annotation) {
annotation.refreshDiv();
}
......@@ -331,11 +340,11 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
//notify controler
control.notify('viewannotation', "editor", null);
//cancel action
$("#annot_form_btn_cancel").on("click", function () {
$(Editor.prototype.ANNOTFORMBTNCANCEL).on("click", function () {
closeViewForm(annotation);
});
//edit action
$("#annot_form_btn_valid").on("click", function () {
$(Editor.prototype.ANNOTFORMBTNVALID).on("click", function () {
var form = $('form[name=mod_audioannotation_form_message_form]');
var data = form.serialize();
ajax.call([
......@@ -375,7 +384,7 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
opt.user = this.getCurrentUser();
annotation.init(opt);
this.waveplayer.drawAnnotation(this.lastP, annotation, 1);
$(".annotation_add").html("");
$(Editor.prototype.ADDANNOTATIONCLASS).html("");
var repoId = this.repo;
var assignpartid = this.assignpartid;
var annotations = this.annotations;
......@@ -401,12 +410,12 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
initAudioFeedback(repoId);
//cancel action
$("#annot_form_btn_cancel").on("click", function () {
$(Editor.prototype.ANNOTFORMBTNCANCEL).on("click", function () {
closeAddForm();
});
//valid action
$("#annot_form_btn_valid").on("click", function () {
var form = $('form[name=mod_audioannotation_form_annotation_form]');
$(Editor.prototype.ANNOTFORMBTNVALID).on("click", function () {
var form = $(Editor.prototype.ANNOTATIONFORM);
var data = form.serialize();
ajax.call([
{
......@@ -416,8 +425,8 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
])[0].done(function (reponse) {
if (reponse["message"] === "error") {
if (reponse["content"]) {
$("#annotationError").text(reponse["content"]);
$("#annotationError").addClass("alert-danger");
$(Editor.prototype.DIVANNOTATIONERROR).text(reponse["content"]);
$(Editor.prototype.DIVANNOTATIONERROR).addClass("alert-danger");
}
return;
}
......@@ -471,12 +480,12 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
initAudioFeedback(repoId);
//cancel action
$("#annot_form_btn_cancel").on("click", function () {
$(Editor.prototype.ANNOTFORMBTNCANCEL).on("click", function () {
closeEditForm(annotation);
});
//edit action
$("#annot_form_btn_valid").on("click", function () {
var form = $('form[name=mod_audioannotation_form_annotation_form]');
$(Editor.prototype.ANNOTFORMBTNVALID).on("click", function () {
var form = $(Editor.prototype.ANNOTATIONFORM);
var data = form.serialize();
ajax.call([
{
......@@ -485,8 +494,8 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
}
])[0].done(function (reponse) {
if (reponse["message"] === "error") {
$("#annotationError").text(Editor.messageErrorSave);
$("#annotationError").addClass("alert-danger");
$(Editor.prototype.DIVANNOTATIONERROR).text(Editor.messageErrorSave);
$(Editor.prototype.DIVANNOTATIONERROR).addClass("alert-danger");
return;
}
annotation.tag = $("#id_tag").val();
......@@ -500,7 +509,7 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
});
//delete pj action
$("#message_pj_btn_delete").on("click", function () {
var form = $('form[name=mod_audioannotation_form_annotation_form]');
var form = $(Editor.prototype.ANNOTATIONFORM);
var data = form.serialize();
ajax.call([
{
......@@ -509,8 +518,8 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
}
])[0].done(function (reponse) {
if (reponse["message"] === "error") {
$("#annotationError").text(Editor.messageErrorDelete);
$("#annotationError").addClass("alert-danger");
$(Editor.prototype.DIVANNOTATIONERROR).text(Editor.messageErrorDelete);
$(Editor.prototype.DIVANNOTATIONERROR).addClass("alert-danger");
return;
}
$("#fileuploadA").hide();
......@@ -529,8 +538,8 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
}
])[0].done(function (reponse) {
if (reponse["message"] === "error") {
$("#annotationError").text(Editor.messageErrorSave);
$("#annotationError").addClass("alert-danger");
$(Editor.prototype.DIVANNOTATIONERROR).text(Editor.messageErrorSave);
$(Editor.prototype.DIVANNOTATIONERROR).addClass("alert-danger");
return;
}
closeEditForm(annotation);
......@@ -574,7 +583,7 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
* @param {Annotation} annotation
*/
var deleteAnnotationAction = function (listAnnotations, annotation) {
var form = $('form[name=mod_audioannotation_form_annotation_form]');
var form = $(Editor.prototype.ANNOTATIONFORM);
var data = form.serialize();
ajax.call([
{
......@@ -583,8 +592,8 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
}
])[0].done(function (reponse) {
if (reponse["message"] === "error") {
$("#annotationError").text(Editor.messageErrorDelete);
$("#annotationError").addClass("alert-danger");
$(Editor.prototype.DIVANNOTATIONERROR).text(Editor.messageErrorDelete);
$(Editor.prototype.DIVANNOTATIONERROR).addClass("alert-danger");
return;
}
annotation.delDisplay();
......@@ -708,13 +717,13 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
* Initializse the display of the question button from input value
*/
var initQuestionButton = function () {
var val = parseInt($("[name='isquestion']").val());
var val = parseInt($(Editor.prototype.INPUTFILTERQUESTION).val());
if (val === 0) {
$("#annot_form_btn_question .fa-ban").show();
$("#annot_form_btn_question_label").text(Editor.messageFeedbackko);
$(Editor.prototype.ANNOTLABELQUESTION).text(Editor.messageFeedbackko);
} else {
$("#annot_form_btn_question .fa-ban").hide();
$("#annot_form_btn_question_label").text(Editor.messageFeedbackok);
$(Editor.prototype.ANNOTLABELQUESTION).text(Editor.messageFeedbackok);
}
};
......@@ -723,15 +732,15 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
*/
var initQuestionTrigger = function () {
$("#annot_form_btn_question").on("click", function () {
var val = parseInt($("[name='isquestion']").val());
var val = parseInt($(Editor.prototype.INPUTFILTERQUESTION).val());
if (val === 0) {
$("[name='isquestion']").val(1);
$(Editor.prototype.INPUTFILTERQUESTION).val(1);
$("#annot_form_btn_question .fa-ban").hide();
$("#annot_form_btn_question_label").text(Editor.messageFeedbackok);
$(Editor.prototype.ANNOTLABELQUESTION).text(Editor.messageFeedbackok);
} else {
$("[name='isquestion']").val(0);
$(Editor.prototype.INPUTFILTERQUESTION).val(0);
$("#annot_form_btn_question .fa-ban").show();
$("#annot_form_btn_question_label").text(Editor.messageFeedbackko);
$(Editor.prototype.ANNOTLABELQUESTION).text(Editor.messageFeedbackko);
}
});
};
......@@ -788,12 +797,12 @@ define(['jquery', 'mod_audioannotation/annotation', 'mod_audioannotation/records
* Move the moodle file form inside the main form, and adjust display
*/
var moveFileForm = function () {
$("#fileinput").append($('[data-fieldtype="filepicker"]'));
$(Editor.prototype.FILEINPUT).append($('[data-fieldtype="filepicker"]'));
$('[data-fieldtype="filepicker"]').removeClass("col-md-9");
$(".form-filetypes-descriptions").hide();
$("#fileinput").append($("input[name*='_qf__mod_audioannotation']"));
$("#fileinput").find("p").remove();
$("#fileinput").find(".femptylabel").css('margin-bottom', '0');
$(Editor.prototype.FILEINPUT).append($("input[name*='_qf__mod_audioannotation']"));
$(Editor.prototype.FILEINPUT).find("p").remove();
$(Editor.prototype.FILEINPUT).find(".femptylabel").css('margin-bottom', '0');
$("#mform1").remove();
};
......
......@@ -82,6 +82,10 @@ define(['jquery'],
JustWave.options = null;
JustWave.prototype.PLAYPAUSEBUTTON = ".justwave_playpause";
JustWave.prototype.PLAYPAUSEBUTTONBEFORE = ".justwave_playpause_before";
JustWave.prototype.CURRENTFOCUS = ".justwave_curfocus";
/********************************
* CONSTRUCTOR *
********************************/
......@@ -167,6 +171,7 @@ define(['jquery'],
var attrs = p.data();
Object.keys(attrs).map(function (key) {
opts[key] = attrs[key];
return opts[key];
});
return opts;
};
......@@ -226,8 +231,8 @@ define(['jquery'],
var p = e.target;
var song = $(p).next();
// play buttons
song.find('.justwave_playpause i.fa').addClass('fa-pause');
song.find('.justwave_playpause i.fa').removeClass('fa-play');
song.find(JustWave.prototype.PLAYPAUSEBUTTON + ' i.fa').addClass('fa-pause');
song.find(JustWave.prototype.PLAYPAUSEBUTTON + ' i.fa').removeClass('fa-play');
// chain players together
if (p.opts.chained) {
......@@ -242,8 +247,8 @@ define(['jquery'],
.on('pause', function (e) {
var song = $(e.target).next();
// play buttons
song.find('.justwave_playpause i.fa').addClass('fa-play');
song.find('.justwave_playpause i.fa').removeClass('fa-pause');
song.find(JustWave.prototype.PLAYPAUSEBUTTON + ' i.fa').addClass('fa-play');
song.find(JustWave.prototype.PLAYPAUSEBUTTON + ' i.fa').removeClass('fa-pause');
})
.on('error', function (e) {
var p = e.target;
......@@ -251,13 +256,13 @@ define(['jquery'],
clearWaves(p);
// disable play/pause buttons
song.find('.justwave_playpause').prop('disabled', true);
song.find('.justwave_playpause_before').prop('disabled', true);
song.find(JustWave.prototype.PLAYPAUSEBUTTON).prop('disabled', true);
song.find(JustWave.prototype.PLAYPAUSEBUTTONBEFORE).prop('disabled', true);
// display the base name of failed audio
song.find('.justwave_songname').text($(p).attr('src').replace(/.+[\\\/]/, ''));
song.find('.justwave_duration').text('00:00');
p.xduration = 0;
song.find('.justwave_duration, .justwave_curpos, .justwave_curfocus').hide();
song.find('.justwave_duration, .justwave_curpos, ' + JustWave.prototype.CURRENTFOCUS).hide();
controlerNot.notify("error", "player", p);
})
......@@ -297,7 +302,7 @@ define(['jquery'],
var mouseY = e.pageY - offset.top;
var song = this,
p = $(this).prev()[0];
$(song).find('.justwave_curfocus').text(toMinSec(mouseX / this.offsetWidth * p.xduration))
$(song).find(JustWave.prototype.CURRENTFOCUS).text(toMinSec(mouseX / this.offsetWidth * p.xduration))
.css({top: mouseY - 5 + 'px',
left: mouseX + 5 + 'px'});
// show song name for a while while moving cursor over player
......@@ -305,15 +310,15 @@ define(['jquery'],
songnameShow($(song).find('.justwave_songname'));
}
}).mouseleave(function () {
$(this).find('.justwave_curfocus').hide();
$(this).find('.justwave_playpause').fadeOut(1000);
$(this).find('.justwave_playpause_before').fadeOut(1000);
$(this).find(JustWave.prototype.CURRENTFOCUS).hide();
$(this).find(JustWave.prototype.PLAYPAUSEBUTTON).fadeOut(1000);
$(this).find(JustWave.prototype.PLAYPAUSEBUTTONBEFORE).fadeOut(1000);
}).mouseenter(function () {
var p = $(this).prev()[0];
$(this).find('.justwave_playpause').stop(false, true).fadeIn(500);
$(this).find('.justwave_playpause_before').stop(false, true).fadeIn(500);
$(this).find(JustWave.prototype.PLAYPAUSEBUTTON).stop(false, true).fadeIn(500);
$(this).find(JustWave.prototype.PLAYPAUSEBUTTONBEFORE).stop(false, true).fadeIn(500);
if (p.opts.showtimes && p.opts.showtimes > 0) {
$(this).find('.justwave_curfocus').show();
$(this).find(JustWave.prototype.CURRENTFOCUS).show();
}
controlerNot.notify('mouseenter', "player", p);
}).dblclick(function () {
......@@ -326,7 +331,7 @@ define(['jquery'],
});
// bind play/pause button
song.find('.justwave_playpause').on('click touchstart', function (e) {
song.find(JustWave.prototype.PLAYPAUSEBUTTON).on('click touchstart', function (e) {
e.stopPropagation();
e.preventDefault();
// target an audio element
......@@ -345,7 +350,7 @@ define(['jquery'],
}
controlerNot.notify('pause', "player", p);
});
song.find('.justwave_playpause_before').on('click touchstart', function (e) {
song.find(JustWave.prototype.PLAYPAUSEBUTTONBEFORE).on('click touchstart', function (e) {
e.stopPropagation();
e.preventDefault();
// target an audio element
......@@ -364,13 +369,13 @@ define(['jquery'],
e.preventDefault();
});
song.find('.justwave_playpause_btn').mouseenter(function () {
$(this).siblings('.justwave_curfocus').hide();
$(this).siblings(JustWave.prototype.CURRENTFOCUS).hide();
})
.mouseleave(function () {
// audio element
var p = $(this).parent().prev()[0];
if (p.opts.showtimes && p.opts.showtimes > 0) {
$(this).siblings('.justwave_curfocus').show();
$(this).siblings(JustWave.prototype.CURRENTFOCUS).show();
}
});
var divcard = song.parents('div[data-parent="#accordionAssignPart"]');
......@@ -379,12 +384,12 @@ define(['jquery'],
if (e.which === 32) { // touche espace
e.preventDefault();
//pause ou play
song.find('button.justwave_playpause').click();
song.find('button' + JustWave.prototype.PLAYPAUSEBUTTON).click();
}
if (e.which === 66) { // touche B
e.preventDefault();
//retour arriere
song.find('button.justwave_playpause_before').click();
song.find('button' + JustWave.prototype.PLAYPAUSEBUTTONBEFORE).click();
}
if (e.which === 78) { // touche N
e.preventDefault();
......@@ -479,8 +484,8 @@ define(['jquery'],
var song = $(p).next();
// we can start playing this audio
song.find('.justwave_playpause i.fa').addClass('fa-play');
song.find('.justwave_playpause i.fa').removeClass('fa-pause');
song.find(JustWave.prototype.PLAYPAUSEBUTTON + ' i.fa').addClass('fa-play');
song.find(JustWave.prototype.PLAYPAUSEBUTTON + ' i.fa').removeClass('fa-pause');
};
JustWave.prototype.drawWaveDisplay = function (p) {
......
......@@ -47,6 +47,9 @@ define(['jquery', 'mod_audioannotation/record'],
RecordsManager.prototype.mediaSource = null;
RecordsManager.pauseTimestamp = 0;
RecordsManager.prototype.RECORDINGTOOLS = ".record-tool";
RecordsManager.prototype.VALIDATIONBUTTON = "input[type=submit]";
/********************************
* CONSTRUCTOR *
********************************/
......@@ -91,7 +94,7 @@ define(['jquery', 'mod_audioannotation/record'],
// Older browsers might not implement mediaDevices at all
if (!(navigator.mediaDevices && window.MediaRecorder)) {
$('.webrtcsupport').show();
$('.record-tool').hide();
$(RecordsManager.prototype.RECORDINGTOOLS).hide();
return;
}
......@@ -139,7 +142,7 @@ define(['jquery', 'mod_audioannotation/record'],
//on verifie si on a au moins 1 micro dispo
if (!audiodeviceid) {
$('.microphone').show();
$('.record-tool').hide();
$(RecordsManager.prototype.RECORDINGTOOLS).hide();
return;
}
......@@ -165,7 +168,7 @@ define(['jquery', 'mod_audioannotation/record'],
tryGetUserMedia(listDevices[pointeur]);
} else {
$('.microphone').show();
$('.record-tool').hide();
$(RecordsManager.prototype.RECORDINGTOOLS).hide();
window.console.log('GUM failed with error, time diff: ', Date.now() - now);
window.console.error('navigator.getUserMedia error:', e.name + ": " + e.message);
$(RecordsManager.errorMsgElement)
......@@ -178,7 +181,7 @@ define(['jquery', 'mod_audioannotation/record'],
});
} else {
$('.webrtcsupport').show();
$('.record-tool').hide();
$(RecordsManager.prototype.RECORDINGTOOLS).hide();
window.console.log('getUserMedia is not supported by your browser');
return;
}
......@@ -318,9 +321,9 @@ define(['jquery', 'mod_audioannotation/record'],
RecordsManager.prototype.sendFile = function (blobRaw, indice) {
$("#sending" + indice).show();
//on empeche lenregistrement lors de lenvoi du fichier son
$("input[type=submit]").addClass('disabled');
$('input[type=submit]').attr('disabled', 'disabled');
$('input[type=submit]').prop('disabled', true);
$(RecordsManager.prototype.VALIDATIONBUTTON).addClass('disabled');
$(RecordsManager.prototype.VALIDATIONBUTTON).attr('disabled', 'disabled');
$(RecordsManager.prototype.VALIDATIONBUTTON).prop('disabled', true);
var blob = new Blob(blobRaw);