Commit 68708f37 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Fix incompatibility to few olds firefox versions

parent 0b96dac6
......@@ -210,32 +210,6 @@ d3.boxplot.select_zone = function (x=null, y=null, x_zone=null, y_zone=null, for
let scale_x = d3.boxplot.scale / x_len_zone;
let scale_y = d3.boxplot.scale / y_len_zone;
//
// let lines_s = [];
//
// let my_x_zone = [d3.boxplot.x_zones[x_zone][0] / d3.boxplot.scale * d3.boxplot.x_len, d3.boxplot.x_zones[x_zone][1] / d3.boxplot.scale * d3.boxplot.x_len];
// let my_y_zone = [d3.boxplot.y_zones[y_zone][0] / d3.boxplot.scale * d3.boxplot.y_len, d3.boxplot.y_zones[y_zone][1] / d3.boxplot.scale * d3.boxplot.y_len];
//
// for (let l in d3.boxplot.lines) {
// let line = d3.boxplot.lines[l].slice(0);
// if (((line[0] >= my_x_zone[0] && line[0] < my_x_zone[1]) || (line[1] >= my_x_zone[0] && line[1] < my_x_zone[1]))
// && ((line[2] >= my_y_zone[0] && line[2] < my_y_zone[1]) ||
// (line[3] >= my_y_zone[0] && line[3] < my_y_zone[1]))) {
// //console.log(line);
// line[0] -= my_x_zone[0];
// line[1] -= my_x_zone[0];
// line[2] -= my_y_zone[0];
// line[3] -= my_y_zone[0];
// if (line[1] < 0)
// console.log("WARN!!!", line[0]);
// //console.log(line);
// lines_s.push(line);
// }
// }
//
// d3.selectAll("line.content-lines").remove();
// d3.boxplot.draw_lines(lines_s, my_x_zone[1] - my_x_zone[0], my_y_zone[1] - my_y_zone[0]);
//Zoom in:
d3.boxplot.container
.attr("transform", "scale(" + scale_x + "," + scale_y + ")" +
......
......@@ -13,8 +13,7 @@ dgenies.result.summary.show = function(percents) {
let percents_order = ["-1", "0", "1", "2", "3"];
let x = 0;
let percent_value = 0;
for (let i in percents_order) {
let percent = percents_order[i];
$.each(percents_order, function(o, percent) {
let label=dgenies.result.summary._get_label(percent);
x += percent_value;
percent_value = percent in percents ? percents[percent] : 0;
......@@ -45,7 +44,7 @@ dgenies.result.summary.show = function(percents) {
.attr("font-family", "sans-serif")
.attr("font-size", "12pt")
.text(percent_value.toFixed(2) + " %");
}
});
container.append("rect")
.attr("x", 0)
......
......@@ -116,15 +116,15 @@ dgenies.run.init_fileuploads = function () {
"queryidx": {"formats": ["fasta", "idx"], "position": 2},
"targetidx": {"formats": ["fasta", "idx"], "position": 3},
"alignfile": {"formats": ["map"], "position": 4},};
for (let ftype in ftypes) {
let formats = ftypes[ftype]["formats"];
let position = ftypes[ftype]["position"];
$.each(ftypes, function(ftype, data) {
let formats = data["formats"];
let position = data["position"];
dgenies.run._init_fileupload(ftype, formats, position);
//Trigger events on hidden file inputs:
$(`button#button-${ftype}`).click(function() {
$(`input.file-${ftype}`).trigger("click");
});
}
});
};
dgenies.run.get_file_size_str = function(size) {
......@@ -187,11 +187,10 @@ dgenies.run.show_tab = function(tab) {
dgenies.run.set_events = function() {
let ftypes = ["query", "target", "alignfile", "queryidx", "targetidx"];
for (let f in ftypes) {
let ftype = ftypes[f];
$.each(ftypes, function (i, ftype) {
dgenies.run._set_file_event(ftype);
dgenies.run._set_file_select_event(ftype);
}
});
$("button#submit").click(function () {
dgenies.run.submit();
......
if(!dgenies){throw"dgenies wasn't included!"}dgenies.run={};// Init global variables:
dgenies.run.s_id=null;dgenies.run.allowed_ext=[];dgenies.run.max_upload_file_size=-1;dgenies.run.files=[undefined,undefined,undefined,undefined,undefined];dgenies.run.allow_upload=false;dgenies.run.ping_interval=null;dgenies.run.target_example="";dgenies.run.query_example="";dgenies.run.tool_has_ava={};dgenies.run.enabled=true;dgenies.run.init=function(s_id,allowed_ext,max_upload_file_size=1073741824,target_example="",query_example="",tool_has_ava={}){dgenies.run.s_id=s_id;dgenies.run.allowed_ext=allowed_ext;dgenies.run.max_upload_file_size=max_upload_file_size;dgenies.run.target_example=target_example;dgenies.run.query_example=query_example;dgenies.run.tool_has_ava=tool_has_ava;dgenies.run.restore_form();dgenies.run.set_events();dgenies.run.init_fileuploads()};dgenies.run.restore_form=function(){let ftypes=["query","target","alignfile","queryidx","targetidx"];for(let f in ftypes){let ftype=ftypes[f];dgenies.run.change_fasta_type(ftype,$(`select.${ftype}`).find(":selected").text().toLowerCase(),true)}};dgenies.run.upload_next=function(){let next=dgenies.run.files.pop();while(next===undefined&&dgenies.run.files.length>0){next=dgenies.run.files.pop()}if(next!==undefined){next.submit();return true}dgenies.run.do_submit();return false};dgenies.run.__upload_server_error=function(fasta,data){dgenies.notify("message"in data?data["message"]:`An error has occured when uploading <b>${fasta}</b> file. Please contact us to report the bug!`,"danger");dgenies.run.enable_form()};dgenies.run.allowed_file=function(filename,formats){let allowed_ext=[];for(let f in formats){let format=formats[f];allowed_ext+=dgenies.run.allowed_ext[format]}return filename.indexOf(".")!==-1&&(allowed_ext.indexOf(filename.rsplit(".",1)[1].toLowerCase())!==-1||allowed_ext.indexOf(filename.rsplit(".",2).splice(1).join(".").toLowerCase())!==-1)};dgenies.run._init_fileupload=function(ftype,formats,position){$(`input.file-${ftype}`).fileupload({dataType:"json",formData:{"s_id":dgenies.run.s_id,"formats":formats},add:function(e,data){let filename=data.files[0].name;if(dgenies.run.allowed_file(filename,formats))dgenies.run.files[position]=data;else{$(`input.file-${ftype}`).trigger("change");// The value is null after fired
dgenies.notify(`File <b>${filename}</b> is not supported!`,"danger",3000)}},progressall:function(e,data){var progress=parseInt(data.loaded/data.total*100,10);$(`#progress-${ftype}`).find(".bar").css("width",progress+"%")},success:function(data,success){if(data["success"]!=="OK"){dgenies.run.__upload_server_error(ftype,data)}else if("error"in data["files"][0]){dgenies.run.add_error("Query file: "+data["files"][0]["error"],"error");dgenies.run.enable_form()}else{$(`input#ftype`).val(data["files"][0]["name"]);dgenies.run.hide_loading(ftype);dgenies.run.show_success(ftype);dgenies.run.upload_next()}},error:function(data,success){dgenies.run.__upload_server_error(ftype,data)}})};dgenies.run.init_fileuploads=function(){let ftypes={"query":{"formats":["fasta"],"position":0},"target":{"formats":["fasta"],"position":1},"queryidx":{"formats":["fasta","idx"],"position":2},"targetidx":{"formats":["fasta","idx"],"position":3},"alignfile":{"formats":["map"],"position":4}};for(let ftype in ftypes){let formats=ftypes[ftype]["formats"];let position=ftypes[ftype]["position"];dgenies.run._init_fileupload(ftype,formats,position);//Trigger events on hidden file inputs:
$(`button#button-${ftype}`).click(function(){$(`input.file-${ftype}`).trigger("click")})}};dgenies.run.get_file_size_str=function(size){if(size<1000){return size+" O"}else if(size<1000000){return Math.round(size/1024)+" Ko"}else if(size<1000000000){return Math.round(size/1048576)+" Mo"}return Math.round(size/1073741824)+" Go"};dgenies.run.fill_examples=function(){dgenies.run.show_tab("tab1");$("select.target").val("1").trigger("change");$("input#target").val("example://"+dgenies.run.target_example);if(dgenies.run.query_example!==""){$("select.query").val("1").trigger("change");$("input#query").val("example://"+dgenies.run.query_example)}};dgenies.run._set_file_event=function(ftype){let max_file_size_txt=dgenies.run.get_file_size_str(dgenies.run.max_upload_file_size);$(`input.file-${ftype}`).change(function(){let file_size=$(`div.file-size.${ftype}`);if(this.files.length>0){if(this.files[0].size<=dgenies.run.max_upload_file_size){file_size.html(dgenies.run.get_file_size_str(this.files[0].size));dgenies.run.set_filename(this.files[0].name,ftype)}else{$(this).val("");dgenies.run.set_filename("",ftype);dgenies.notify(`File exceed the size limit (${max_file_size_txt})`,"danger",2000);file_size.html("")}}else{dgenies.run.set_filename("",ftype);file_size.html("")}})};dgenies.run._set_file_select_event=function(ftype){$(`select.${ftype}`).change(function(){dgenies.run.change_fasta_type(ftype,$(`select.${ftype}`).find(":selected").text().toLowerCase())})};dgenies.run.show_tab=function(tab){$(`#tabs #${tab}`).addClass("active");$(`#tabs .tab:not(#${tab})`).removeClass("active");$(`.tabx:not(${tab})`).hide();$(`.tabx.${tab}`).show()};dgenies.run.set_events=function(){let ftypes=["query","target","alignfile","queryidx","targetidx"];for(let f in ftypes){let ftype=ftypes[f];dgenies.run._set_file_event(ftype);dgenies.run._set_file_select_event(ftype)}$("button#submit").click(function(){dgenies.run.submit()});$("button#example").click(function(){dgenies.run.fill_examples()});$("#tabs .tab").click(function(){dgenies.run.show_tab($(this).attr("id"))})};dgenies.run.change_fasta_type=function(fasta,type,keep_url=false){let button=$("button#button-"+fasta);let input=$("input#"+fasta);let container=$("div."+fasta+"-label");$("input.file-"+fasta).val("");if(type==="local"){button.show();input.prop("readonly",true);input.val("");container.width(300)}else{button.hide();input.prop("readonly",false);if(!keep_url)input.val("");container.width(348)}$("div.file-size."+fasta).html("")};dgenies.run.set_filename=function(name,fasta){$("input#"+fasta).val(name)};dgenies.run.disable_form=function(){dgenies.run.enabled=false;$("input, select, button").prop("disabled",true)};dgenies.run.enable_form=function(){$(".progress").find(".bar").css("width","0%");$("input, select, button").prop("disabled",false);$("div#uploading-loading").hide();$("button#submit").show();let ftypes=["query","target","alignfile","targetidx","queryidx"];for(let f in ftypes){let ftype=ftypes[f];dgenies.run.hide_loading(ftype);dgenies.run.hide_success(ftype)}dgenies.run.files=[undefined,undefined,undefined,undefined,undefined];dgenies.run.restore_form();dgenies.run.enabled=true};dgenies.run.reset_file_form=function(tab){let ftypes=[];let i=0;if(tab==="tab2"){ftypes=["alignfile","queryidx","targetidx"];i=2}else{ftypes=["query","target"];i=0}for(let f in ftypes){let ftype=ftypes[f];dgenies.run.change_fasta_type(ftype,$(`select.${ftype}`).find(":selected").text().toLowerCase(),true);dgenies.run.files[i]=undefined;i++}};dgenies.run.do_submit=function(){let data={"id_job":$("input#id_job").val(),"email":dgenies.mode==="webserver"?$("input#email").val():"","s_id":dgenies.run.s_id};let tab=$("#tabs .tab.active").attr("id");if(tab==="tab1"){data=Object.assign({},data,{"query":$("input#query").val(),"query_type":$("select.query").find(":selected").text().toLowerCase(),"target":$("input#target").val(),"target_type":$("select.target").find(":selected").text().toLowerCase(),"tool":$("input[name=tool]:checked").val()})}else{data=Object.assign({},data,{"alignfile":$("input#alignfile").val(),"alignfile_type":$("select.alignfile").find(":selected").text().toLowerCase(),"query":$("input#queryidx").val(),"query_type":$("select.queryidx").find(":selected").text().toLowerCase(),"target":$("input#targetidx").val(),"target_type":$("select.targetidx").find(":selected").text().toLowerCase()})}$("div#uploading-loading").html("Submitting form...");dgenies.post("/launch_analysis",data,function(data,status){if(data["success"]){window.location=data["redirect"]}else{if(dgenies.run.ping_interval!==null){clearInterval(dgenies.run.ping_interval);dgenies.run.ping_interval=null}if("errors"in data){for(let i=0;i<data["errors"].length;i++){dgenies.notify(data["errors"][i],"danger",3000)}}else{dgenies.notify("An error has occurred. Please contact the support","danger",3000)}dgenies.run.enable_form()}})};dgenies.run.add_error=function(error){$("div.errors-submit ul.flashes").append($("<li>").append(error))};dgenies.run.valid_form=function(){let has_errors=false;// Check name:
dgenies.notify(`File <b>${filename}</b> is not supported!`,"danger",3000)}},progressall:function(e,data){var progress=parseInt(data.loaded/data.total*100,10);$(`#progress-${ftype}`).find(".bar").css("width",progress+"%")},success:function(data,success){if(data["success"]!=="OK"){dgenies.run.__upload_server_error(ftype,data)}else if("error"in data["files"][0]){dgenies.run.add_error("Query file: "+data["files"][0]["error"],"error");dgenies.run.enable_form()}else{$(`input#ftype`).val(data["files"][0]["name"]);dgenies.run.hide_loading(ftype);dgenies.run.show_success(ftype);dgenies.run.upload_next()}},error:function(data,success){dgenies.run.__upload_server_error(ftype,data)}})};dgenies.run.init_fileuploads=function(){let ftypes={"query":{"formats":["fasta"],"position":0},"target":{"formats":["fasta"],"position":1},"queryidx":{"formats":["fasta","idx"],"position":2},"targetidx":{"formats":["fasta","idx"],"position":3},"alignfile":{"formats":["map"],"position":4}};$.each(ftypes,function(ftype,data){let formats=data["formats"];let position=data["position"];dgenies.run._init_fileupload(ftype,formats,position);//Trigger events on hidden file inputs:
$(`button#button-${ftype}`).click(function(){$(`input.file-${ftype}`).trigger("click")})})};dgenies.run.get_file_size_str=function(size){if(size<1000){return size+" O"}else if(size<1000000){return Math.round(size/1024)+" Ko"}else if(size<1000000000){return Math.round(size/1048576)+" Mo"}return Math.round(size/1073741824)+" Go"};dgenies.run.fill_examples=function(){dgenies.run.show_tab("tab1");$("select.target").val("1").trigger("change");$("input#target").val("example://"+dgenies.run.target_example);if(dgenies.run.query_example!==""){$("select.query").val("1").trigger("change");$("input#query").val("example://"+dgenies.run.query_example)}};dgenies.run._set_file_event=function(ftype){let max_file_size_txt=dgenies.run.get_file_size_str(dgenies.run.max_upload_file_size);$(`input.file-${ftype}`).change(function(){let file_size=$(`div.file-size.${ftype}`);if(this.files.length>0){if(this.files[0].size<=dgenies.run.max_upload_file_size){file_size.html(dgenies.run.get_file_size_str(this.files[0].size));dgenies.run.set_filename(this.files[0].name,ftype)}else{$(this).val("");dgenies.run.set_filename("",ftype);dgenies.notify(`File exceed the size limit (${max_file_size_txt})`,"danger",2000);file_size.html("")}}else{dgenies.run.set_filename("",ftype);file_size.html("")}})};dgenies.run._set_file_select_event=function(ftype){$(`select.${ftype}`).change(function(){dgenies.run.change_fasta_type(ftype,$(`select.${ftype}`).find(":selected").text().toLowerCase())})};dgenies.run.show_tab=function(tab){$(`#tabs #${tab}`).addClass("active");$(`#tabs .tab:not(#${tab})`).removeClass("active");$(`.tabx:not(${tab})`).hide();$(`.tabx.${tab}`).show()};dgenies.run.set_events=function(){let ftypes=["query","target","alignfile","queryidx","targetidx"];$.each(ftypes,function(i,ftype){dgenies.run._set_file_event(ftype);dgenies.run._set_file_select_event(ftype)});$("button#submit").click(function(){dgenies.run.submit()});$("button#example").click(function(){dgenies.run.fill_examples()});$("#tabs .tab").click(function(){dgenies.run.show_tab($(this).attr("id"))})};dgenies.run.change_fasta_type=function(fasta,type,keep_url=false){let button=$("button#button-"+fasta);let input=$("input#"+fasta);let container=$("div."+fasta+"-label");$("input.file-"+fasta).val("");if(type==="local"){button.show();input.prop("readonly",true);input.val("");container.width(300)}else{button.hide();input.prop("readonly",false);if(!keep_url)input.val("");container.width(348)}$("div.file-size."+fasta).html("")};dgenies.run.set_filename=function(name,fasta){$("input#"+fasta).val(name)};dgenies.run.disable_form=function(){dgenies.run.enabled=false;$("input, select, button").prop("disabled",true)};dgenies.run.enable_form=function(){$(".progress").find(".bar").css("width","0%");$("input, select, button").prop("disabled",false);$("div#uploading-loading").hide();$("button#submit").show();let ftypes=["query","target","alignfile","targetidx","queryidx"];for(let f in ftypes){let ftype=ftypes[f];dgenies.run.hide_loading(ftype);dgenies.run.hide_success(ftype)}dgenies.run.files=[undefined,undefined,undefined,undefined,undefined];dgenies.run.restore_form();dgenies.run.enabled=true};dgenies.run.reset_file_form=function(tab){let ftypes=[];let i=0;if(tab==="tab2"){ftypes=["alignfile","queryidx","targetidx"];i=2}else{ftypes=["query","target"];i=0}for(let f in ftypes){let ftype=ftypes[f];dgenies.run.change_fasta_type(ftype,$(`select.${ftype}`).find(":selected").text().toLowerCase(),true);dgenies.run.files[i]=undefined;i++}};dgenies.run.do_submit=function(){let data={"id_job":$("input#id_job").val(),"email":dgenies.mode==="webserver"?$("input#email").val():"","s_id":dgenies.run.s_id};let tab=$("#tabs .tab.active").attr("id");if(tab==="tab1"){data=Object.assign({},data,{"query":$("input#query").val(),"query_type":$("select.query").find(":selected").text().toLowerCase(),"target":$("input#target").val(),"target_type":$("select.target").find(":selected").text().toLowerCase(),"tool":$("input[name=tool]:checked").val()})}else{data=Object.assign({},data,{"alignfile":$("input#alignfile").val(),"alignfile_type":$("select.alignfile").find(":selected").text().toLowerCase(),"query":$("input#queryidx").val(),"query_type":$("select.queryidx").find(":selected").text().toLowerCase(),"target":$("input#targetidx").val(),"target_type":$("select.targetidx").find(":selected").text().toLowerCase()})}$("div#uploading-loading").html("Submitting form...");dgenies.post("/launch_analysis",data,function(data,status){if(data["success"]){window.location=data["redirect"]}else{if(dgenies.run.ping_interval!==null){clearInterval(dgenies.run.ping_interval);dgenies.run.ping_interval=null}if("errors"in data){for(let i=0;i<data["errors"].length;i++){dgenies.notify(data["errors"][i],"danger",3000)}}else{dgenies.notify("An error has occurred. Please contact the support","danger",3000)}dgenies.run.enable_form()}})};dgenies.run.add_error=function(error){$("div.errors-submit ul.flashes").append($("<li>").append(error))};dgenies.run.valid_form=function(){let has_errors=false;// Check name:
if($("input#id_job").val().length===0){$("label.id-job").addClass("error");dgenies.run.add_error("Name of your job is required!");has_errors=true}// Check mail:
if(dgenies.mode==="webserver"){let email=$("input#email").val();let mail_re=/^.+@.+\..+$/;if(email.match(mail_re)===null){$("label.email").addClass("error");if(email==="")dgenies.run.add_error("Email is required!");else dgenies.run.add_error("Email is not correct!");has_errors=true}}let tab=$("#tabs .tab.active").attr("id");/* TAB 1 */if(tab==="tab1"){//Check input target:
if($("input#target").val().length===0){$("label.file-target").addClass("error");dgenies.run.add_error("Target fasta is required!");has_errors=true}//Check input query:
......
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