"use strict";document.write("<script type='text/javascript' src='data/gsea_report_group_data.js?callback=getGroupData&v="+Math.random()+"'><\/script>"),document.write("<script type='text/javascript' src='data/gsea_report_snapshot_details.js?callback=getSnapshotDetails&v="+Math.random()+"'><\/script>");var groupData={},detailData={},idList={};function getGroupData(a){groupData=a;for(var t=Object.keys(a),e=0;e<t.length;e++){idList[t[e]]=[];for(var l=0;l<groupData[t[e]].length;l++)idList[t[e]].push(groupData[t[e]][l].NAME);var i=groupData[t[e]].length?Object.keys(groupData[t[e]][0]):[],r='<table id="table'+e+'"><thead><tr>';i.splice(0,1,"");for(var o=0;o<i.length;o++)r+="<th>"+i[o]+"</th>";r+="</tr></thead><tbody></tbody></table>",$("#tableContainer"+e).append(r),$("#tableContainer"+e).children("#table"+e).dynatable({table:{columnValue:i},dataset:{records:groupData[t[e]],group:t[e]}})}}function getSnapshotDetails(a){detailData=a;for(var t=Object.keys(a),e=0;e<t.length;e++){var l='<table class="snapshotTable" cellspacing="0"><tr>',i=0,r=0,o=Object.keys(a[t[e]]).length;for(var d in a[t[e]]){var n=idList[t[e]].indexOf(d);detailData[t[e]][d].GeneSet=d,detailData[t[e]][d].group=t[e],detailData[t[e]][d].ES=-1===n?"":groupData[t[e]][n].ES,detailData[t[e]][d].NES=-1===n?"":groupData[t[e]][n].NES,detailData[t[e]][d]["NOM p-val"]=-1===n?"":groupData[t[e]][n]["NOM p-val"],detailData[t[e]][d]["FDR q-val"]=-1===n?"":groupData[t[e]][n]["FDR q-val"],detailData[t[e]][d]["FWER p-val"]=-1===n?"":groupData[t[e]][n]["FWER p-val"],l+="<td "+((o%4==0?o-5:o-(o%4+1))<r?'style="border-bottom:none"':"")+'><a><img data-type="neg" data-group="'+t[e]+'" data-id="'+d+'" class="snapshotImg" src="'+detailData[t[e]][d].enplotUrl+'"></a></td>',r++,l+=4==++i?"</tr><tr>":"",i=4==i?0:i}l+=i?"</tr><caption>Table: Snapshot of enrichment results "+t[e]+"</caption></table>":"<caption>Table: Snapshot of enrichment results "+t[e]+"</caption></table>",$("#snapshot"+e).append(l)}}function openDetailDialog(t,e){var l=["Dataset","Phenotype","group","GeneSet","ES","NES","NOM p-val","FDR q-val","FWER p-val"],a="<tr>"+$("#detailDialog .bottom table").children("tbody").children().eq(0).html()+"</tr>";$("#detailDialog #summaryTable tr").each(function(a){$(this).children("td").eq(1).text(detailData[e][t][l[a]]||detailData[e][t][l[a].toLocaleLowerCase()])}),$(".right img").attr("name","enplot_"+t),$(".right img").attr("src",detailData[e][t].enplotUrl),$(".middle .dialogTitle").eq(0).children("img").attr("name",t),$(".middle .dialogTitle").eq(0).children("img").attr("src",detailData[e][t].analyzedGeneSetUrl),$(".middle .dialogTitle").eq(1).children("img").attr("src",detailData[e][t].esDistributionUrl),$("#detailDialog .name").each(function(){$(this).text(t)});for(var i=0;i<detailData[e][t].tableData.data.length;i++){for(var r="<tr>",o=0;o<detailData[e][t].tableData.data[i].length;o++)0===o?r+='<td class="lessen">'+(i+1)+"</td>":3===o?r+="<td>"+detailData[e][t].tableData.data[i][o]+'<br><a target="_blank" href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=search&db=gene&term='+detailData[e][t].tableData.data[i][o]+'[sym]">Entrez</a></td>':o===detailData[e][t].tableData.data[i].length-1?r+='<td bgcolor="'+("Yes"==detailData[e][t].tableData.data[i][o]?"#CCFFCC":"#FFFFFF")+'">'+detailData[e][t].tableData.data[i][o]+"</td>":r+='<td class="lessen">'+detailData[e][t].tableData.data[i][o]+"</td>";a+=r+="</tr>"}$("#detailDialog .bottom table tbody").html(a),$("#detailDialog .bottom .tableTitle a").attr("href",t.replace(":","_")+".xls"),$("#detailDialog").fadeIn(),$("#detailDialog").css("display","flex"),$("body").css({overflow:"hidden"})}$(document).ready(function(){$(".snapshot").on("click",".snapshotImg",function(){openDetailDialog($(this).attr("data-id"),$(this).attr("data-group"))}),$("#detailDialog").on("click",".close",function(){$("#detailDialog").fadeOut(),$("body").css({overflow:"auto"})}),$("table").on("click",".detail",function(){openDetailDialog($(this).attr("data-id"),$(this).attr("data-group"))})});
