text: $(window).resize(function(){resizeMainPanel()});setTimeout(function(){resizeMainPanel()},50);resizeMainPanel=function(){var c=230;var a=$(location).attr("search");try{if(a.indexOf("search")>=0){if(isCompoundEntityOpen){$("#search-results").height($(window).height()-c);$("#search-results").css("overflow","auto");var c=190;$("#entityBody").height($(window).height()-c);$("#entityBody").css("overflow","auto");$("#search-results").css("overflow","hidden");searchResultsHeight=$("#search-results").height();$("#search-results").removeAttr("style")}else{$("#search-results").height($(window).height()-c);$("#search-results").css("overflow","auto")}}else{if($(a).length==0){}}}catch(b){}};$(function(){$("head").append('<meta name="viewport" content="width=device-width, initial-scale=1" />');var a=$($(".progress")[0]);var b=$("#progress-value");a.on("sliderchange",function(d,c){b.val(c.value)});a.on("slidercomplete",function(d,c){console.log("slider completed!")});b.on("change",function(){var c=parseFloat(b.val());a.slider("option","now",c);return false})});$(document).ready(function(){$(".selectpicker").selectpicker()});$(document).ready(function(){$(".datepicker").datepicker()});function roundNumber(b,d){var a=1;for(var c=0;c<d;c++){a=a*10}return Math.round(b*a)/a}(function(){var a=window.alert;window.alert=function(c){try{if(typeof c==="string"){c=$.parseHTML(c)[0].data}if(console){console.log(c)}a(c)}catch(b){}}})();$(document).ready(function(){var a="";a+="@";$("#linkcontact").attr("href","mailto:contact"+a+"peakforest.org?subject=%5Babout%20peakforest%20webapp%5D");$(".pf-autofocus").focus(function(){$(this).select()})});function loadSpectrumNMRPro(e,d,a,b,c){a=encodeURI($($.parseHTML(a)[0]).text());jQuery=jQuery.noConflict();jQuery.when(jQuery.getScript(b+"d3.v3.min.js"),jQuery.getScript(b+"specdraw.js"),jQuery.Deferred(function(f){jQuery(f.resolve)})).done(function(){jQuery("#"+e).empty();var f=specdraw.App().data(c+"/"+d+"?label="+a);d3.select("#"+e).call(f);delete Array.prototype.rotate;delete Array.prototype.rotateTo;delete Array.prototype.whichMax;delete Array.prototype.cumsum});$=jQuery.noConflict()}function computeDisplayCpdInCartList(){$.each($(".btn-cpd-cart"),function(){var a=Number((($(this).attr("onclick")).replace("addRemoveCpdFromCart(","").replace(")","")));testIfCpdInCurrentCart(a)})}function addRemoveCpdFromCart(a){a=Number(a);if($(".addRemoveCpd"+a).hasClass("fa-plus-circle")){addCpdInCart(a)}else{removeCpdFromCart(a)}}function removeCpdFromCart(a){$.ajax({type:"POST",url:"remove-cpd-from-cart/"+a,dataType:"json",async:false,success:function(b){if(b){testIfCpdInCurrentCart(a)}else{$("#removeCpdFromCart").parent().hide()}},error:function(b){console.log(b)}})}function testIfCpdInCurrentCart(a){$.ajax({type:"GET",url:"is-cpd-in-cart/"+a,dataType:"json",async:false,success:function(b){if(b){$("#removeCpdFromCart").show();$("#removeCpdFromCart"+a).show();$("#addCpdInCart").hide();$("#addCpdInCart"+a).hide();$(".addRemoveCpd"+a).removeClass("fa-plus-circle").addClass("fa-times-circle");$(".addRemoveCpd"+a).parent().removeClass("btn-success");$(".addRemoveCpd"+a).parent().addClass("btn-danger")}else{$("#removeCpdFromCart").hide();$("#addCpdInCart").show();$("#removeCpdFromCart"+a).hide();$("#addCpdInCart"+a).show();$(".addRemoveCpd"+a).removeClass("fa-times-circle").addClass("fa-plus-circle");$(".addRemoveCpd"+a).parent().removeClass("btn-danger");$(".addRemoveCpd"+a).parent().addClass("btn-success")}},error:function(b){console.log(b)}})}function addCpdInCart(a){$.ajax({type:"POST",url:"add-cpd-in-cart/"+a,dataType:"json",async:false,success:function(b){if(b){testIfCpdInCurrentCart(a)}else{$("#removeCpdFromCart").parent().hide()}},error:function(b){console.log(b)}})}function updateCart(){$.ajax({type:"get",url:"get-cpd-from-cart",dataType:"json",async:false,success:function(a){console.log(a);if(a.length==0){$("#noCpdInCart").show();$("#cpdInCart").hide()}else{$("#compoundCartTableBody").empty();$("#noCpdInCart").hide();$("#cpdInCart").show();var b=[];$.each(a,function(){var c=this.mainName;var f=this.formula;var h=f+"";try{h=h.replace(/\d+/g,"<sub>$&</sub>")}catch(i){}var g="?";if(this.hasOwnProperty("parent")){g="chemical"}if(this.hasOwnProperty("children")){g="generic"}var j=this.containSpectra;var d={name:c,id:this.id,formula:h,exactMass:roundNumber(this.monoisotopicMass,7),molWeight:roundNumber(this.averageMass,7),inchikey:this.inChIKey,type:g,spectra:j,pfID:this.pfID};b.push(d)});$("#templateCompounds").tmpl(b).appendTo("#compoundCartTableBody");$.each($(".compoundFormula"),function(d,c){$(c).html($(c).text())})}},error:function(a){console.log(a)}})}function cleanCpdInCart(){$.ajax({type:"POST",url:"clear-cpd-in-cart",dataType:"json",async:false,success:function(a){updateCart()},error:function(a){console.log(a)}})}function saveCpdCartAsJsonFile(){$.ajax({type:"GET",url:"get-cpd-in-cart.json",dataType:"json",async:false,success:function(a){downloadJson("peakforest-compounds.json",a)},error:function(a){console.log(a)}})}function loadCpdCartFromJsonFile(a){$.ajax({type:"POST",url:"load-cpd-in-cart",contentType:"application/json",data:JSON.stringify(a),dataType:"json",async:false,success:function(b){updateCart()},error:function(b){console.log(b)}})}function downloadJson(b,g){var e=document.createElement("a");var d=JSON.stringify(g);var a=new Blob([d],{type:"application/json"});var c=URL.createObjectURL(a);e.setAttribute("href",c);e.setAttribute("download",b);if(document.createEvent){var f=document.createEvent("MouseEvents");f.initEvent("click",true,true);e.dispatchEvent(f)}else{e.click()}}$(document).ready(function(){if($("#MEViz__biosource").length===1){$.getJSON("json/metexplore-biosources-list.json",function(b){$("#MEViz__biosource").empty();$("#MEViz__biosource").append("<option disabled selected ></option>");$.each(b,function(){if(this.NomComplet!==undefined){$("#MEViz__biosource").append('<option value="'+this.id+'">'+this.NomComplet+" ("+this.type+")</option>")}});$("#MEViz__biosource").combobox()});$("#MEViz__biosource").on("change",function(){var b=getMEVizExtraParam(false);var d=[];if($("#MEViz__loadCart_Y").is(":checked")||MEViz__autoLoadCart){d=loadMEVizCart()}var c=Number($("input[name='MEViz__biosource']").val());if(c!=0){$.ajax({type:"GET",url:"get-pathways",data:"biosource="+c+b,dataType:"json",async:false,success:function(e){console.log(e);initSelectPathways(c,e,d)},error:function(e){console.log(e)}})}});$("#MEViz__run").on("click",function(){$("#MEViz__pathwaysTarget").attr("disabled",true);$("#MEViz__mainFrame").children().remove();$("#MEViz__mainFrame").css("height","600px");$("#MEViz__mainFrame").css("width","100%");$("#MEViz__mainFrame").css("min-width","700px");$("#MEViz__mainFrame").html("loading...");var b=getMEVizExtraParam(true);var c=Number($("input[name='MEViz__biosource']").val());$.ajax({type:"GET",url:"get-graph/"+c,data:"pathways="+$("#MEViz__pathways").val()+b,dataType:"json",async:false,success:function(d){$("#MEViz__mainFrame").html("");MetExploreViz.initFrame("MEViz__mainFrame");MetExploreViz.onloadMetExploreViz(function(){metExploreViz.GraphPanel.refreshPanel(JSON.stringify(d),function(){metExploreViz.onloadSession(function(){if(d.hasOwnProperty("mappingdata")){metExploreViz.GraphMapping.mapNodes("PeakForest_MappingInChIKey")}if(d.hasOwnProperty("mappingInChIKeys")){$.each(d.mappingInChIKeys,function(f,e){$.each(e,function(h,g){metExploreViz.GraphNode.selectNodeFromGrid(g)})})}})})});$("#MEViz__module input").attr("disabled",true);$("#MEViz__pathwaysTarget button").attr("disabled",true);$("#MEViz__run").attr("disabled",true)},error:function(d){console.log(d);$("#MEViz__mainFrame").html("Error: sorry, MetExplore Viz could not process a selected pathway");$("#MEViz__module input").attr("disabled",true);$("#MEViz__pathwaysTarget button").attr("disabled",true);$("#MEViz__run").attr("disabled",true)}})});$("#MEViz__loadCart").on("click",function(){loadMEVizCart()});var a=0;$("#MEViz__reset").on("click",function(){a++;if(a>2){if(confirm("Reload this browser page in order to reset MetExplore Viz old graphs?")){document.location.hash="#MEViz__module";document.location.reload()}}$("#MEViz__biosource").val("").attr("disabled",false);$("#MEViz__biosource").parent().find(".fa-remove").click();$("#MEViz__pathwaysTarget").html('<select id="MEViz__pathways" class="form-control " disabled></select>');$("#MEViz__mainFrame").children().remove();$("#MEViz__mainFrame").html("");$("#MEViz__mainFrame").css("height","0px");$("#MEViz__mainFrame").css("width","0%");$("#MEViz__mainFrame").css("min-width","0px");$("#MEViz__module input").attr("disabled",false);$("#MEViz__pathwaysTarget button").attr("disabled",false);$("#MEViz__run").attr("disabled",true);$("#MEViz__loadCart").attr("disabled",true);$("#MEViz__loadCart_Y").prop("checked",false);$("#MEViz__loadCart_N").prop("checked",true)})}});function getMEVizExtraParam(d){var b=[];var a="";try{if(currentMolInChIKey!==undefined&&currentMolInChIKey!==null&&currentMolInChIKey!=""){b.push(currentMolInChIKey)}}catch(c){}if(($("#MEViz__loadCart_Y").is(":checked")&&d)||MEViz__autoLoadCart){b.push.apply(b,loadMEVizCart())}if(b.lenght!=0){a+="&inchikeys="+b}return a}function loadMEVizCart(){var a=[];$.ajax({type:"get",url:"get-cpd-from-cart",dataType:"json",async:false,success:function(b){if(b.length==0){}else{$.each(b,function(){a.push(this.inChIKey)})}},error:function(b){console.log(b)}});return a}function initSelectPathways(c,a,b){$("#MEViz__biosource").attr("disabled",true);$("#MEViz__pathwaysTarget").html('<select id="MEViz__pathways" class="form-control " multiple=""></select>');$.each(a,function(){if(this.name!==undefined){var d="";if(this.hasOwnProperty("mappedMetabolite")){d+=" <small>(nb mapped:"+this.mappedMetabolite+")</small>"}$("#MEViz__pathways").append('<option value="'+this.id+'">'+this.name+d+"</option>")}});$("#MEViz__pathways").multiselect({enableFiltering:true,enableCaseInsensitiveFiltering:true,filterPlaceholder:"Enter pathway..."});$("#MEViz__pathways").on("change",function(){$("#MEViz__run").attr("disabled",false)});$(".multiselect-container.dropdown-menu").css("overflow-x","scroll");$(".multiselect-container.dropdown-menu").css("max-height","200px")}$(document).ready(function(){$(".clipboad-me").click(function(){$(this).select()}).keypress(function(a){a.preventDefault()}).bind("input",function(b){var a=$(this).data("val");$(this).val(a)})});function copyToClipboad(a){var b=document.getElementById(a);b.select();b.setSelectionRange(0,99999);document.execCommand("copy")};