Gitlab CSE Unil

Commit 4b98b107 authored by M. Chardon's avatar M. Chardon
Browse files

mantis 211

parent 7cfe5f3f
define(["jquery","core/modal_factory","core/modal_events","core/str"],function(a,b,c,d){function e(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 e.mediaRecorder=null,e.recordedBlobs=null,e.errorMsgElement="#errorMsg",e.recordButton="#record",e.pauseRecordButton="#pauseRecord",e.removeButton="#remove",e.recordedVideo="#recorded",e.sending="#sending",e.repo=-1,e.initTimestamp=-1,e.timestampStop=0,e.limit=null,e.indice="",e.manager=null,e.prototype.init=function(){if(this.indice<0)return void window.console.error("audioanntation - record: indice init error");this.errorMsgElement="#errorMsg",this.recordButton="#record",this.pauseRecordButton="#pauseRecord",this.removeButton="#remove",this.recordedVideo="#recorded",this.sending="#sending";var b=this.indice;this.errorMsgElement+=this.indice,this.recordButton+=this.indice,this.pauseRecordButton+=this.indice,this.removeButton+=this.indice,this.recordedVideo+=this.indice,this.sending+=this.indice,a(this.recordButton).prop("indice",this.indice),1!=a("input[name='canrecord"+this.indice+"']").val()&&(a(this.removeButton).hide(),a(this.recordButton).parent().hide());var c=a("input[name='audio"+this.indice+"']").val();c&&(a(this.recordedVideo).attr("src",c),a("input[name='file"+b+"']").parent().parent().addClass("disabled")),this.initDisplayAudio(),a(this.recordButton).data("statut","stop")},e.prototype.initDisplayRecordButton=function(){"undefined"==typeof a(this.recordedVideo).attr("src")&&a(this.recordButton).attr("disabled",!1)},e.prototype.initDisplayAudio=function(){a(this.recordedVideo).attr("src")&&(a(this.removeButton).attr("disabled",!1),this.displayAudio());var b=this.indice;a("input[name='file"+b+"']").on("change",function(){a(this).val()&&a(this).val()>0&&a("input[name='filerecord"+b+"']").val(a(this).val())})},e.prototype.reset=function(){this.initDisplayAudio(),a(this.recordButton).data("statut","stop"),this.initDisplayRecordButton(),this.initTrigger()},e.prototype.initTrigger=function(){var e=this.pauseRecordButton,f=this.recordedVideo,g=this.removeButton,h=this.recordButton,i=this.manager,j=this.indice,k=this.errorMsgElement,l=this;a(this.recordButton).on("click",function(){if("stop"===a(this).data("statut")){var b=i.startRecording(j);b?(a(f).attr("src",null),a(this).data("statut","start"),a(e).attr("disabled",!1),a(e).data("statut","off"),a(e).find(".fa-ban").hide(),a(g).attr("disabled",!0),a(this).find("i.fa-square").show(),a(this).find("i.fa-square").parent().parent().attr("title","Stop")):a(k).text("Un enregistrement est déjà en cours :un seul enregistrement à la fois est possible!")}else i.stopRecording(j),a(this).data("statut","stop"),a(this).find("i.fa-square").hide(),a(this).find("i.fa-square").parent().parent().attr("title","Enregistrement"),a(this).attr("disabled",!0),l.displayAudio(),a(g).attr("disabled",!1),a(e).attr("disabled",!0)}),a(this.pauseRecordButton).on("click",function(b){"off"===a(this).data("statut")?(i.pauseRecording(b),a(this).data("statut","on"),a(this).find(".fa-ban").show()):(i.resumeRecording(b),a(this).data("statut","off"),a(this).find(".fa-ban").hide())}),b.create({type:b.types.SAVE_CANCEL,title:d.get_string("delete","audioannotation"),body:d.get_string("delete_record_question","audioannotation")},a(this.removeButton)).done(function(b){b.setSaveButtonText(d.get_string("delete","audioannotation")),b.getRoot().on(c.save,function(){a("input[name='filerecord"+j+"']").val(-1),a("input[name='file"+j+"']").parent().parent().removeClass("disabled"),a(g).attr("disabled",!0),a(f).hide(),a(f).attr("src",null),a(f).attr("srcObject",null),a(h).attr("disabled",!1)})})},e.prototype.displayAudio=function(){var b=this.recordedVideo;if(!a(b).attr("src")){var c=new Blob(e.recordedBlobs);a(b).show(),a(b).attr("src",null),a(b).attr("srcObject",null),a(b).attr("src",window.URL.createObjectURL(c))}a(b).attr("controls",!0),a(b).attr("autoplay",!1)},e.prototype.sendBlob=function(a){e.recordedBlobs=a},e.prototype.stopRecord=function(){a(this.recordButton).click()},e});
\ No newline at end of file
define(["jquery","core/modal_factory","core/modal_events","core/str"],function(a,b,c,d){function e(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 e.mediaRecorder=null,e.recordedBlobs=null,e.errorMsgElement="#errorMsg",e.recordButton="#record",e.pauseRecordButton="#pauseRecord",e.removeButton="#remove",e.recordedVideo="#recorded",e.sending="#sending",e.sendok="#sendok",e.repo=-1,e.initTimestamp=-1,e.timestampStop=0,e.limit=null,e.indice="",e.manager=null,e.prototype.init=function(){if(this.indice<0)return void window.console.error("audioanntation - record: indice init error");this.errorMsgElement="#errorMsg",this.recordButton="#record",this.pauseRecordButton="#pauseRecord",this.removeButton="#remove",this.recordedVideo="#recorded",this.sending="#sending";var b=this.indice;this.errorMsgElement+=this.indice,this.recordButton+=this.indice,this.pauseRecordButton+=this.indice,this.removeButton+=this.indice,this.recordedVideo+=this.indice,this.sending+=this.indice,this.sendok+=this.indice,a(this.recordButton).prop("indice",this.indice),1!=a("input[name='canrecord"+this.indice+"']").val()&&(a(this.removeButton).hide(),a(this.recordButton).parent().hide());var c=a("input[name='audio"+this.indice+"']").val();c&&(a(this.recordedVideo).attr("src",c),a("input[name='file"+b+"']").parent().parent().addClass("disabled")),this.initDisplayAudio(),a(this.recordButton).data("statut","stop")},e.prototype.initDisplayRecordButton=function(){"undefined"==typeof a(this.recordedVideo).attr("src")&&a(this.recordButton).attr("disabled",!1)},e.prototype.initDisplayAudio=function(){a(this.recordedVideo).attr("src")&&(a(this.removeButton).attr("disabled",!1),this.displayAudio());var b=this.indice;a("input[name='file"+b+"']").on("change",function(){a(this).val()&&a(this).val()>0&&a("input[name='filerecord"+b+"']").val(a(this).val())})},e.prototype.reset=function(){this.initDisplayAudio(),a(this.recordButton).data("statut","stop"),this.initDisplayRecordButton(),this.initTrigger()},e.prototype.initTrigger=function(){var e=this.pauseRecordButton,f=this.recordedVideo,g=this.removeButton,h=this.recordButton,i=this.sendok,j=this.manager,k=this.indice,l=this.errorMsgElement,m=this;a(this.recordButton).on("click",function(){if("stop"===a(this).data("statut")){var b=j.startRecording(k);b?(a(f).attr("src",null),a(this).data("statut","start"),a(e).attr("disabled",!1),a(e).data("statut","off"),a(e).find(".fa-ban").hide(),a(g).attr("disabled",!0),a(this).find("i.fa-square").show(),a(this).find("i.fa-square").parent().parent().attr("title","Stop")):a(l).text("Un enregistrement est déjà en cours :un seul enregistrement à la fois est possible!")}else j.stopRecording(k),a(this).data("statut","stop"),a(this).find("i.fa-square").hide(),a(this).find("i.fa-square").parent().parent().attr("title","Enregistrement"),a(this).attr("disabled",!0),m.displayAudio(),a(g).attr("disabled",!1),a(e).attr("disabled",!0)}),a(this.pauseRecordButton).on("click",function(b){"off"===a(this).data("statut")?(j.pauseRecording(b),a(this).data("statut","on"),a(this).find(".fa-ban").show()):(j.resumeRecording(b),a(this).data("statut","off"),a(this).find(".fa-ban").hide())}),b.create({type:b.types.SAVE_CANCEL,title:d.get_string("delete","audioannotation"),body:d.get_string("delete_record_question","audioannotation")},a(this.removeButton)).done(function(b){b.setSaveButtonText(d.get_string("delete","audioannotation")),b.getRoot().on(c.save,function(){a("input[name='filerecord"+k+"']").val(-1),a("input[name='file"+k+"']").parent().parent().removeClass("disabled"),a(g).attr("disabled",!0),a(f).hide(),a(f).attr("src",null),a(f).attr("srcObject",null),a(h).attr("disabled",!1),a(i).hide()})})},e.prototype.displayAudio=function(){var b=this.recordedVideo;if(!a(b).attr("src")){var c=new Blob(e.recordedBlobs);a(b).show(),a(b).attr("src",null),a(b).attr("srcObject",null),a(b).attr("src",window.URL.createObjectURL(c))}a(b).attr("controls",!0),a(b).attr("autoplay",!1)},e.prototype.sendBlob=function(a){e.recordedBlobs=a},e.prototype.stopRecord=function(){a(this.recordButton).click()},e});
\ 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 void alert("nowebrtc");if(!navigator.mediaDevices.getUserMedia)return void alert("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]):(alert("microphone no available"),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 void alert("not available microphone");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();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();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("#sending"+d).hide(),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.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 void alert("nowebrtc");if(!navigator.mediaDevices.getUserMedia)return void alert("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]):(alert("microphone no available"),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 void alert("not available microphone");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");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");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]").activate(),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
......@@ -42,6 +42,7 @@ define(['jquery', 'core/modal_factory', 'core/modal_events', 'core/str'],
Record.removeButton = '#remove';
Record.recordedVideo = '#recorded';
Record.sending = '#sending';
Record.sendok = '#sendok';
Record.repo = -1;
......@@ -102,6 +103,7 @@ define(['jquery', 'core/modal_factory', 'core/modal_events', 'core/str'],
this.removeButton += this.indice;
this.recordedVideo += this.indice;
this.sending += this.indice;
this.sendok += this.indice;
//set indice to record Button
$(this.recordButton).prop('indice', this.indice);
......@@ -162,6 +164,7 @@ define(['jquery', 'core/modal_factory', 'core/modal_events', 'core/str'],
var recordedVideo = this.recordedVideo;
var removeButton = this.removeButton;
var recordButton = this.recordButton;
var sendokButton = this.sendok;
var manager = this.manager;
var indice = this.indice;
var errorMsgElement = this.errorMsgElement;
......@@ -223,6 +226,7 @@ define(['jquery', 'core/modal_factory', 'core/modal_events', 'core/str'],
$(recordedVideo).attr('src', null);
$(recordedVideo).attr('srcObject', null);
$(recordButton).attr('disabled', false);
$(sendokButton).hide();
});
});
};
......
......@@ -311,6 +311,8 @@ 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');
var blob = new Blob(blobRaw);
// Create FormData to send to PHP filepicker-upload script.
var formData = new window.FormData();
......@@ -331,14 +333,16 @@ define(['jquery', 'mod_audioannotation/record'],
xhr.addEventListener('readystatechange', function () {
if (this.readyState === 4 && this.status === 200) {
$("#sending" + indice).hide();
$("input[type=submit]").removeClass('disabled');
// Typical action to be performed when the document is ready:
var response = xhr.response;
var responseO = JSON.parse(response);
$("input[name='filerecord" + indice + "']").val(responseO.file);
$("input[name='file" + indice + "']").parent().parent().addClass('disabled');
$("#sendok" + indice).show().fadeOut(3000);
$("#sendok" + indice).show();
} else if (this.readyState > 200) {
$("#sending" + indice).hide();
$("input[type=submit]").removeClass('disabled');
$("#sendko" + indice).show();
}
}, false);
......
......@@ -112,7 +112,7 @@ class assignaudio_form extends moodleform {
$mform->addElement('html', '<div class="btn-group m-l-1" role="group">');
$mform->addElement('html', '<button id="remove' . $i . '" disabled="disabled" class="btn" type="button"><i class="fa fa-trash"></i></button>');
$mform->addElement('html', '<button id="sending' . $i . '" disabled="disabled" class="btn" type="button" style="display: none;"><i class="fa fa-spinner fa-spin"></i></button>');
$mform->addElement('html', '<button id="sendok' . $i . '" disabled="disabled" class="btn btn-success" type="button" style="display: none;"><i class="fa fa-check"></i></button>');
$mform->addElement('html', '<button id="sendok' . $i . '" disabled="disabled" class="btn btn-success" type="button" style="display: none;"><i class="fa fa-check"></i> ' . get_string('success_sendfile', AUDIOANNOT_MODNAME) . '</button>');
$mform->addElement('html', '<button id="sendko' . $i . '" disabled="disabled" class="btn btn-danger" type="button" style="display: none;">' . get_string('error_sendfile', AUDIOANNOT_MODNAME) . '</button>');
$mform->addElement('html', '</div>');
......
......@@ -108,6 +108,7 @@ $string['add'] = 'Add';
$string['deadline_exceeded'] = 'Warning, deadline of delivery exceeded';
$string['recording'] = 'Recording';
$string['error_sendfile'] = 'Error sending file';
$string['success_sendfile'] = 'File sent successfully,<br/>don\'t forget to save your work';
$string['deadline_reached'] = 'Deadline for deposit reached';
$string['todo'] = 'to do';
$string['delivery_start_date'] = 'Delivery start date';
......
......@@ -108,6 +108,7 @@ $string['add'] = 'Ajouter';
$string['deadline_exceeded'] = 'Attention, date limite de remise dépassée ';
$string['recording'] = 'Enregistrement';
$string['error_sendfile'] = 'Erreur lors de l\'envoi du fichier';
$string['success_sendfile'] = 'Fichier envoyé avec success,<br/>n\'oubliez pas de sauvegarder votre travail';
$string['deadline_reached'] = 'Date limite de dépôt atteinte ';
$string['deadline_reached'] = 'Date limite de dépôt atteinte ';
$string['todo'] = 'à rendre';
......
......@@ -135,8 +135,8 @@
</div>
<div class="btn-group m-l-1" role="group">
<button id="remove0" disabled="disabled" class='btn' type="button"><i class="fa fa-trash"></i></button>
<button id="sending0" disabled="disabled" class='btn' type="button" style="display: none;"><i class="fa fa-spinner fa-spin"></i></button>
<button id="sendok0" disabled="disabled" class='btn btn-success' type="button" style="display: none;"><i class="fa fa-check"></i></button>
<button id="sending0" disabled="disabled" class='btn btn-secondary' type="button" style="display: none;"><i class="fa fa-spinner fa-spin"></i></button>
<button id="sendok0" disabled="disabled" class='btn btn-success' type="button" style="display: none;"><i class="fa fa-check"></i> {{# str }} success_sendfile, audioannotation {{/ str }}</button>
<button id="sendko0" disabled="disabled" class='btn btn-danger' type="button" style="display: none;">{{# str }} error_sendfile, audioannotation {{/ str }}</button>
</div>
<div class='m-l-1'>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment