<commit_before>availableTemplates=null;var model={},baseUrl="http://squirrel.flymine.org/intermine-test",flyMineBase="http://preview.flymine.org/preview";
$(function(){IMBedding.setBaseUrl(baseUrl);Syntax.root="http://squirrel.flymine.org/imbedding/lib/jquery-syntax/";$(".js-snippet").syntax({brush:"javascript",layout:"list",replace:true,tabWidth:4,root:"lib/jquery-syntax/"});$(".html-snippet").syntax({brush:"html",layout:"list",replace:true,tabWidth:4,root:"lib/jquery-syntax/"});$("#showGraphAreaContainer").hide();loadTable1();loadTable3a();loadTable3b();loadTable4a();loadTable4b();loadTable4c();loadTable4d();loadTable4();loadTable5();$("#faq").accordion({collapsible:true,
autoHeight:false})});function setActiveStyleSheet(a){var b,e;for(b=0;e=document.getElementsByTagName("link")[b];b++)if(e.getAttribute("rel").indexOf("style")!=-1&&e.getAttribute("title")){e.disabled=true;if(e.getAttribute("title")==a)e.disabled=false}}function loadTable1(){IMBedding.loadTemplate({name:"Gene_Identifiers",constraint1:"Gene.secondaryIdentifier",op1:"<",value1:"CG1046",code1:"A"},"#placeholderEx2",{openOnLoad:true,baseUrl:flyMineBase})}
function loadTable2(){IMBedding.loadTemplate({name:"Gene_upstreamRegulatoryRegions",constraint1:"Gene",op1:"LOOKUP",value1:"eve",code1:"A"},"#positionExample",{baseUrl:flyMineBase})}function loadTable3a(){IMBedding.loadTemplate({name:"Gene_allGOTerms2",constraint1:"Gene",op1:"LOOKUP",value1:"CG11348",code1:"A"},"#placeholderEx3a",{onTitleClick:"mine",baseUrl:flyMineBase})}
function loadTable3b(){IMBedding.loadTemplate({name:"Gene_allGOTerms2",size:10,constraint1:"Gene",op1:"LOOKUP",value1:"CG11348",code1:"A"},"#placeholderEx3b",{onTitleClick:"none",baseUrl:flyMineBase})}
function loadTable4a(){IMBedding.loadTemplate({name:"Organism_GeneDomain_new",size:10,constraint1:"ProteinDomain.proteins.genes.organism.name",op1:"=",value1:"Drosophila melanogaster",code1:"A",constraint2:"ProteinDomain.shortName",op2:"=",value2:"*homeo*",code2:"B"},"#placeholderEx4a",{showExportLinks:false,baseUrl:flyMineBase})}
function loadTable4b(){IMBedding.loadTemplate({name:"Organism_GeneDomain_new",size:10,constraint1:"ProteinDomain.proteins.genes.organism.name",op1:"=",value1:"Drosophila melanogaster",code1:"A",constraint2:"ProteinDomain.shortName",op2:"=",value2:"*homeo*",code2:"B"},"#placeholderEx4b",{showCount:false,baseUrl:flyMineBase})}
function loadTable4c(){IMBedding.loadTemplate({name:"Organism_GeneDomain_new",size:10,constraint1:"ProteinDomain.proteins.genes.organism.name",op1:"=",value1:"Drosophila melanogaster",code1:"A",constraint2:"ProteinDomain.shortName",op2:"=",value2:"*homeo*",code2:"B"},"#placeholderEx4c",{showMineLink:false,baseUrl:flyMineBase})}
function loadTable4d(){IMBedding.loadTemplate({name:"Organism_GeneDomain_new",size:15,constraint1:"ProteinDomain.proteins.genes.organism.name",op1:"=",value1:"Drosophila melanogaster",code1:"A",constraint2:"ProteinDomain.shortName",op2:"=",value2:"*homeo*",code2:"B"},"#placeholderEx4d",{baseUrl:flyMineBase})}
function loadTable4(){IMBedding.loadTemplate({name:"Chromosome_Gene",constraint1:"Gene.chromosome.primaryIdentifier",op1:"=",value1:"2L",code1:"A",constraint2:"Gene.organism.name",op2:"=",value2:"Drosophila melanogaster",code2:"B"},"#placeholder1",{baseUrl:flyMineBase})}
function loadTable5(){IMBedding.loadTemplate({name:"Chromosome_Gene",constraint1:"Gene.chromosome.primaryIdentifier",op1:"=",value1:"2L",code1:"A",constraint2:"Gene.organism.name",op2:"=",value2:"Drosophila melanogaster",code2:"B"},"#styleDemo",{baseUrl:flyMineBase})}
function loadGraph1(){IMBedding.loadQuery({select:["Employee.age","Employee.department.company.name"],from:"testmodel"},{size:1E3,format:"jsonpobjects"},function(a){var b=[],e=0,c={};for(i in a.results){var d=a.results[i],f=d.age,g=d.department.company.name;e+=f;c[g]||(c[g]={});if(c[g][f])c[g][f]+=1;else c[g][f]=1}for(name in c){g=c[name];var h=0,j=0;d={data:[]};for(f in g){h+=g[f];j+=f*g[f];d.data.push([f,g[f]])}g=parseInt(j/h);d.label=name+" [av: "+g+"]";b.push(d)}$.plot("#graph",b,{series:{stack:true,
lines:{show:false},bars:{show:true,barWidth:0.9}},legend:{position:"nw"}});a=parseInt(e/a.results.length);$("<span></span>").html("Age (average:"+a+")").addClass("axis-label").appendTo("#graph")})}
function showTooltip(a,b,e){$('<div id="tooltip"></div>').html(e).addClass("tooltip").css({position:"absolute",display:"none",top:b+10,left:a+10,border:"2px solid #FF0084",padding:"5px","border-radius":"5px","-moz-border-radius":"5px","background-color":"#FE45A5",color:"white",opacity:0.7}).appendTo("body").fadeIn(200)}
function findLineByLeastSquares(a){var b=0,e=0,c=0,d=0,f=0,g=0,h=0,j=a.length;if(j===0)return[];for(var k=0;k<j;k++){g=a[k][0];h=a[k][1];b+=g;e+=h;d+=g*g;c+=g*h;f++}c=(f*c-b*e)/(f*d-b*b);b=e/f-c*b/f;e=[];for(k=0;k<j;k++){g=a[k][0];h=g*c+b;e.push([g,h])}return e}
function loadGraph2(){IMBedding.loadQuery({select:["Manager.age","Manager.seniority","Manager.name"],where:[{path:"Manager.age",op:">",value:30}],from:"testmodel"},{size:1E3,format:"jsonpobjects"},function(a){var b=[],e={},c={label:"Seniority by Age",color:"rgb(0, 115, 234)",points:{show:true},data:[]},d={label:"Trend Line",color:"rgb(255, 0, 132)",lines:{show:true}};for(i in a.results){var f=a.results[i],g=f.seniority,h=f.age;c.data.push([h,g]);e[h+"-"+g]=f}d.data=findLineByLeastSquares(c.data);
b.push(c);b.push(d);$.plot("#graph",b,{grid:{hoverable:true,clickable:true},legend:{position:"nw"}});$("#graph").bind("plothover",function(j,k,l){if(l){$("#tooltip").remove();j=l.datapoint[0].toFixed(2);k=l.datapoint[1].toFixed(2);j=parseInt(j)+"-"+parseInt(k);showTooltip(l.pageX,l.pageY,e[j].name)}else{$("#tooltip").remove();previousPoint=null}}).bind("plotclick",function(j,k,l){if(l){j=l.datapoint[0].toFixed(2);l=l.datapoint[1].toFixed(2);l=parseInt(j)+"-"+parseInt(l);window.location.replace(baseUrl+
"/objectDetails.do?id="+e[l].objectId)}});$("<span></span>").html("Age").addClass("axis-label").appendTo("#graph")})}
function loadDepartmentSummary(a){a=a||"Sales";IMBedding.loadQuery({select:["Department.name","Department.company.name","Department.employees.name","Department.employees.age","Department.employees.address.address","Department.manager.name","Department.company.departments.name"],where:[{path:"Department.name",op:"=",value:a},{path:"Department.company.name",op:"=",value:"Wernham-Hogg"}],from:"testmodel"},{size:1E3,format:"jsonpobjects"},function(b){b=b.results[0];var e=$("<div></div>").addClass("department-summary"),
c=document.createElement("h2");c.appendChild(document.createTextNode(b.company.name+": "));var d=document.createElement("select");$(d).button();for(var f=b.company.departments.length,g=0;g<f;g++){var h=b.company.departments[g],j=document.createElement("option");if(h.objectId==b.objectId)j.selected=true;j.innerHTML=h.name;d.appendChild(j)}c.appendChild(d);$(d).change(function(){loadDepartmentSummary($(d).val())});e.append(c);g=document.createElement("h3");g.innerHTML="Manager: "+b.manager.name;e.append(g);
c=b.employees.length;f=document.createElement("ul");for(g=0;g<c;g++){h=b.employees[g];if(h.objectId!=b.manager.objectId){j=document.createElement("li");var k=document.createElement("a");k.href=baseUrl+"/objectDetails.do?id="+h.objectId;k.innerHTML=h.name;j.appendChild(k);$(k).hover(getEmployeeTooltipper(h),function(){$(".tooltip").remove()});f.appendChild(j)}}e.append(f);$("#graph").empty().append(e)})}
var getEmployeeTooltipper=function(a){return function(b){var e=document.createElement("div"),c=document.createElement("h3");c.innerHTML=a.name;e.appendChild(c);c=document.createElement("table");c.className="employee-details";var d=document.createElement("tr"),f=document.createElement("td");f.innerHTML="Age:";f.className="summary-cell";var g=document.createElement("td");g.innerHTML=a.age;g.align="right";g.className="summary-cell";d.appendChild(f);d.appendChild(g);c.appendChild(d);d=document.createElement("tr");
f=document.createElement("td");f.innerHTML="Address:";f.className="summary-cell";g=document.createElement("td");g.innerHTML=a.address.address;g.className="summary-cell";d.appendChild(f);d.appendChild(g);c.appendChild(d);e.appendChild(c);showTooltip(b.pageX,b.pageY,e)}},toggleExample=function(){$("#exampleCode").slideToggle("fast",function(){});$("#querybuilder").slideToggle("fast",function(){})},firstline="/* Below is the Javascript to load this table using ajax:\nYou can cut and paste this into a page to get started.\nDon't forget you need to include the imbedding.js library in your head */\n\n/* You only need to do the following once */\n",
JSON=JSON||{};JSON.stringify=JSON.stringify||function(a){var b=typeof a;if(b!="object"||a===null){if(b=="string")a='"'+a+'"';return String(a)}else{var e,c,d=[],f=a&&a.constructor==Array;for(e in a){c=a[e];b=typeof c;if(b=="string")c='"'+c+'"';else if(b=="object"&&c!==null)c=JSON.stringify(c);d.push((f?"":'"'+e+'":')+String(c))}return(f?"[":"{")+String(d)+(f?"]":"}")}};
var getQueryFromForm=function(){for(var a=$("#root-class").val(),b=[],e=$("#views-form").serializeArray(),c=0;c<e.length;c++){var d=e[c];b.push(a+"."+d.value)}var f={};e=$("#constraints-form").serializeArray();var g={};for(c=0;c<e.length;c++){d=e[c];var h=d.name.match(/\d+/)[0];f[h]||(f[h]={code:letters.charAt(parseInt(h)-1)});var j=d.name.match(/[a-z]+/)[0];if(j=="constraint")f[h].path=a+"."+d.value;else if(j=="op")if(d.value=="ISA")g[h]=true;else f[h].op=d.value;else if(j=="value")if(g[h])f[h].type=
d.value;else f[h].value=d.value;else throw"Unexpected constraint property: "+j;}e=[];for(key in f)e.push(f[key]);g=$("#joins-form").serializeArray();f={};for(c=0;c<g.length;c++){d=g[c];h=d.name.match(/\d+/)[0];f[h]||(f[h]={});j=d.name.match(/[a-z]+/)[0];if(j=="join")f[h].path=a+"."+d.value;else if(j=="style")f[h].style=d.value;else throw"Unexpected join property: "+j;}a=[];for(key in f)a.push(f[key]);d=$("#sortOrderSelector").val()+" "+$("input:radio[name=sortDirection]:checked").val();c=$("#logic").val();
b={select:b,where:e,joins:a,sortOrder:d,from:model.name};if(c.length>0)b.constraintLogic=c;return b},getQueryFromBox=function(){var a=$("#boxselector").val();if(a=="xml")return $("#xmlarea").val();else if(a=="json"){a=$("#jsonarea").val();var b;try{b=eval("("+a+")")}catch(e){alert("Something is wrong with your json\n"+e)}return b}else return null},makeQueryDisplayStrings=function(a){if(!jQuery.isPlainObject(a)){a=a.replace(/&gt;/g,"&amp;gt;").replace(/&lt;/g,"&amp;lt;").replace(/</g,"&lt;").replace(/>/g,
"&gt;");return[null,a]}var b=JSON.stringify(a),e=b.match(/"\w+":/g);if(e)for(var c=0;c<e.length;c++){var d=e[c],f=d.replace(/"/g,"").replace(":",": ");b=b.replace(d,f)}b=b.replace(/\}\],/g,"}\n\t],").replace(/\},\{/g,"},\n\t{").replace(/\],/g,"],\n\t").replace(/^\{/,"{\n\t").replace(/\[\{/g,"[\n\t{").replace(/\}$/,"\n}").replace(/",/g,'", ').replace(/\t\{/g,"\t\t{");a=IMBedding.makeQueryXML(a).replace(/&gt;/g,"&amp;gt;").replace(/&lt;/g,"&amp;lt;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return[b,
a]};
function loadUserQuery(){var a;a=$("input:radio[name=query]:checked").val()=="querybuilder"?getQueryFromForm():getQueryFromBox();if(!a)return false;var b=makeQueryDisplayStrings(a);if(!b)return false;var e={size:10},c=firstline+"IMBedding.setBaseUrl('",d=flyMineBase;c+=d+"');\n\n";d={baseUrl:d};if(b[0])c+="/*You can define the query as a regular javascript object*/\nvar query = "+b[0]+";\n";if(b[1])c+="\n/*A query can be defined as XML*/\nvar query = '"+b[1]+"';\n\n";c+="/*Execution is the same in either case*/\nIMBedding.loadQuery(query, {size: 10}, '#placeholder');";b=
$("#codeContainer");b.empty();var f=document.createElement("textarea");f.id="codeDisplay";f.className="coder";f.cols=80;f.innerHTML=c;b.append(f);Syntax.root="http://squirrel.flymine.org/imbedding/lib/jquery-syntax/";$(f).syntax({brush:"javascript",layout:"list",replace:true,tabWidth:4,root:"lib/jquery-syntax/"});try{IMBedding.loadQuery(a,e,"#placeholder2",d)}catch(g){alert("There was something wrong with your query:\n"+g)}}
function complainAboutName(a){tempSpec=$("#templateSpecific");var b=document.createElement("p");b.className="ui-state-error ui-corner-all";var e=document.createElement("span");e.className="ui-icon ui-icon-alert";e.style["float"]="left";e.style["margin-right"]=".3em";b.appendChild(e);e=document.createElement("strong");e.innerHTML="Um, excuse me:";b.appendChild(e);b.appendChild(document.createTextNode(" "+a));tempSpec.prepend(b)}
function loadUserTemplate(){var a=$("#template-form").serializeArray();if(a[0].value)if(a[0].value in window.availableTemplates){var b={size:10},e=firstline+"IMBedding.setBaseUrl('",c;c=flyMineBase;e+=c+"');\n\n";c={baseUrl:c};e+="IMBedding.loadTemplate(\n\t{\n\t";for(x in a){name=a[x].name;value=a[x].value;b[name]=value;if(name.match("constraint"))e+="\n\t";e+="\t"+name+":\t";name.match(/constraint/)||(e+="\t\t");e+='"'+value+'",\n\t'}e+="},\n\t'#placeholder'\n);";a=$("#templateCodeContainer");a.empty();
var d=document.createElement("textarea");d.id="templateCodeDisplay";d.className="coder";d.cols=80;d.innerHTML=e;a.append(d);Syntax.root="http://squirrel.flymine.org/imbedding/lib/jquery-syntax/";$(d).syntax({brush:"javascript",layout:"list",replace:true,tabWidth:4,root:"lib/jquery-syntax/"});IMBedding.loadTemplate(b,"#placeholder3",c)}else complainAboutName("Check the name - "+a[0].value+" is not one of the available templates");else complainAboutName("Please enter a template name first")}$(function(){$("#tabs").tabs()});
var oldRootClass="Employee";
$(function(){$("input:button").button();$("button").button();$("#positionExButton").click(function(){loadTable2();$(this).hide()});$("#librHeadButton").click(function(){$("#librariesHead").slideToggle()});$("#query-loader").click(function(){loadUserQuery()});$("#view-adder").click(function(){var a=$("#root-class").val();addViewLine(a)});$("#constraint-adder").click(function(){var a=$("#root-class").val();addConstraintLine(a,true)});$("#join-adder").click(function(){var a=$("#root-class").val();addJoinLine(a)});
$("#root-class").change(function(){$("#dialog-confirm").dialog({modal:true,width:400,position:"center",buttons:{"Change root class":function(){$("#querybuilder-views").empty();$("#querybuilder-constraints").empty();$("#querybuilder-joins").empty();$("#sortOrderSelector").empty();$("#sortOrderDiv").hide();$("#logic-box").hide();oldRootClass=$("#root-class").val();$(this).dialog("close")},Cancel:function(){$("#root-class").val(oldRootClass);$(this).dialog("close")}}})});$("#source-radios-t").buttonset();
$(".sourcer").click(function(){if(this.value=="testmodel")loadTemplateInfo("http://squirrel.flymine.org/intermine-test/service/templates");else this.value=="flymine"&&loadTemplateInfo("http://preview.flymine.org/preview/service/templates")});$("#source-radios-q").buttonset();$(".model-sourcer").click(function(){if(this.value=="testmodel")loadModel("http://squirrel.flymine.org/intermine-test/service/model");else this.value=="flymine"&&loadModel("http://preview.flymine.org/preview/service/model")});
$("#sortOrderSelector").button();$("#sortDirectionDiv").buttonset();$("#boxselector").change(function(){document.getElementById("jsonarea").disabled=$(this).val()=="xml";document.getElementById("xmlarea").disabled=$(this).val()=="json"});$("input:checkbox").button();$("#radio").buttonset();$("#graph-radios").buttonset();$("#query-radios").buttonset();$(".styles").buttonset();$("#querybuilder-opt").click(function(){$("#querybuilder").slideDown("fast",function(){});$("#cutandpaste").slideUp("fast",
function(){})});$("#cutandpaste-opt").click(function(){$("#querybuilder").slideUp("fast",function(){});$("#cutandpaste").slideDown("fast",function(){})});$("#showMe").click(function(){$("#showMeAreaContainer").slideToggle("fast",function(){})});$("#showMeGraphCode").click(function(){$("#showGraphAreaContainer").slideToggle("fast",function(){})});$("#showTemplateCode").click(function(){$("#templateCodeContainer").slideToggle("fast",function(){})});$("#showQueryCode").click(function(){$("#codeContainer").slideToggle("fast",
function(){})});$("input.styler").click(function(){setActiveStyleSheet(this.value)});$("input.templater").click(function(){if(this.id.match(/1/))loadTable1();else if(this.id.match(/2/))loadTable2();else this.id.match(/3/)&&loadTable3()});$("input.grapher").click(function(){if(this.id.match(/1/))loadGraph1();else if(this.id.match(/2/))loadGraph2();else this.id.match(/3/)&&loadDepartmentSummary()})});
var operators={"=":"is","!=":"isn't",">":"is greater than/sorts after","<":"is less than/sorts before",">=":"is greater than or equal to","<=":"is less than or equal to",LIKE:"matches",LOOKUP:"any field matches",ISA:"is a","IS NOT NULL":"exists","IS NULL":"doesn't exist"},isAttributeOp={"=":true,"!=":true,">":true,"<":true,">=":true,"<=":true,LIKE:true,LOOKUP:false,ISA:false,"IS NOT NULL":true,"IS NULL":true},getViewCount=function(){return $("#querybuilder-views").children().length},getConstraintCount=
function(){return $("#querybuilder-constraints > tbody").children("tr").length},getJoinCount=function(){return $("#querybuilder-joins").children().length},getViewPathSuggester=function(a){return function(b,e){var c=b.term,d=getPossibleViewPathsFor(a),f=[];for(i in d)d[i].value.substring(0,c.length)==c&&f.push(d[i]);e(f)}},getConsPathSuggester=function(a){return function(b,e){var c=b.term,d=getPossibleConsPathsFor(a),f=[];for(i in d)d[i].value.substring(0,c.length)==c&&f.push(d[i]);e(f)}},getJoinPathSuggester=
function(a){return function(b,e){var c=b.term,d=getPossibleConsPathsFor(a),f=[];for(i in d)d[i].type=="reference"&&d[i].value.substring(0,c.length)==c&&f.push(d[i]);e(f)}},addToSortOrders=function(a){$("#sortOrderDiv").show();var b=document.createElement("option");b.value=a;b.innerHTML=a;$("#sortOrderSelector").append(b)},removeSortOrder=function(a){$("#sortOrderSelector").children("option").each(function(){this.value==a&&$(this).detach()});$("#sortOrderSelector").children("option").length<1&&$("#sortOrderDiv").hide()},
addViewLine=function(a){var b=document.createElement("tr"),e=document.createElement("td"),c=document.createElement("code");c.innerHTML=a+".";e.appendChild(c);var d=document.createElement("input");d.className="text-input";d.type="text";d.size=80;d.name="view"+(getViewCount()+1);$(d).autocomplete({source:getViewPathSuggester(a),minLength:2,change:function(){addToSortOrders(a+"."+$(d).val())}});e.appendChild(d);b.appendChild(e);e=document.createElement("td");c=document.createElement("button");c.appendChild(document.createTextNode("delete"));
$(c).click(function(){$(b).detach();removeSortOrder(a+"."+$(d).val())});$(c).button();e.appendChild(c);b.appendChild(e);$("#querybuilder-views").append(b)},viewPathsFor={},getPossibleViewPathsFor=function(a){if(viewPathsFor[a])return viewPathsFor[a];var b=getPathsFor(a);return viewPathsFor[a]=b},consPathsFor={},getPossibleConsPathsFor=function(a){if(consPathsFor[a])return consPathsFor[a];var b=getPathsFor(a,null,0,true);return consPathsFor[a]=b},getPathsFor=function(a,b,e,c){e=e||0;if(e>3)return[];
e++;var d=[],f=model.classes[a],g=f.attributes;for(a=0;a<g.length;a++)g[a].name!=b&&d.push({value:g[a].name,type:"attribute"});g=f.references;for(a=0;a<g.length;a++){c&&d.push({value:g[a].name,type:"reference"});var h=getPathsFor(g[a].referencedType,g[a].reverseReference,e,c);for(b=0;b<h.length;b++)d.push({value:g[a].name+"."+h[b].value,type:h[b].type})}f=f.collections;for(a=0;a<f.length;a++){c&&d.push({value:f[a].name,type:"reference"});g=getPathsFor(f[a].referencedType,f[a].reverseReference,e,c);
for(b=0;b<g.length;b++)d.push({value:f[a].name+"."+g[b].value,type:g[b].type})}return d},letters="ABCDEFGHIJKMNOPQRSTUVWXYZ",addConstraintLine=function(a,b){var e=getConstraintCount()+1;e>1&&$("#logic-box").show();var c=document.createElement("tr"),d=document.createElement("td");d.appendChild(document.createTextNode(a+"."));var f=document.createElement("input");f.className="text-input";f.type="text";f.size=40;f.name="constraint"+e;d.appendChild(f);c.appendChild(d);d=document.createElement("td");var g=
getOpInput(e,null,b);d.appendChild(g);c.appendChild(d);d=document.createElement("td");var h=document.createElement("input");h.type="text";h.name="value"+e;d.appendChild(h);c.appendChild(d);$(g).change(function(){h.disabled=$(this).val().match(/NULL/)?true:false});$(f).autocomplete({source:getConsPathSuggester(a),minLength:2,select:function(j,k){k.item.type=="attribute"?enableAttributeOptions(g):enableClassOptions(g)}});e=document.createElement("td");f=document.createElement("button");f.innerHTML=
"delete";$(f).click(function(){$(c).detach();$("#querybuilder-constraints > tbody").children().length<2&&$("#logic-box").hide()});$(f).button();e.appendChild(f);c.appendChild(e);$("#querybuilder-constraints").append(c)},addJoinLine=function(a){var b=getJoinCount()+1,e=document.createElement("tr"),c=document.createElement("td");c.appendChild(document.createTextNode(a+"."));var d=document.createElement("input");d.className="text-input";d.type="text";d.size=40;d.name="join"+b;c.appendChild(d);e.appendChild(c);
c=document.createElement("td");var f=document.createElement("div"),g=document.createElement("input");g.type="radio";g.id="inner"+b;g.value="INNER";g.name="style"+b;g.checked=true;f.appendChild(g);g=document.createElement("label");g.setAttribute("for","inner"+b);g.innerHTML="INNER";f.appendChild(g);g=document.createElement("input");g.type="radio";g.id="outer"+b;g.value="OUTER";g.name="style"+b;f.appendChild(g);g=document.createElement("label");g.setAttribute("for","outer"+b);g.innerHTML="OUTER";f.appendChild(g);
c.appendChild(f);e.appendChild(c);$(f).buttonset();$(d).autocomplete({source:getJoinPathSuggester(a),minLength:2});a=document.createElement("td");b=document.createElement("button");b.innerHTML="delete";$(b).click(function(){$(e).detach()});$(b).button();a.appendChild(b);e.appendChild(a);$("#querybuilder-joins").append(e)};function enableAttributeOptions(a){$(a).children("option").each(function(){this.disabled=!isAttributeOp[this.value];if(this.selected&&this.disabled)this.selected=false})}
function enableClassOptions(a){$(a).children("option").each(function(){this.disabled=isAttributeOp[this.value];if(this.selected&&this.disabled)this.selected=false})}function getOpInput(a,b,e){var c=document.createElement("select");c.name="op"+a;for(op in operators)if(!(op=="ISA"&&!e)){a=document.createElement("option");a.value=op;a.innerHTML=operators[op];if(b&&op==b.op)a.selected="selected";c.appendChild(a)}return c}
getSelectHandler=function(a){return function(b,e){if(e.item){var c=e.item.value;tempSpec=$("#templateSpecific");tempSpec.empty();c=a[c];var d=document.createElement("h3");d.innerHTML=c.title;tempSpec.append(d);d=document.createElement("table");for(var f=0;f<c.constraints.length;f++){var g=document.createElement("tr");d.appendChild(g);cons=c.constraints[f];counter=f+1;var h=document.createElement("td"),j=document.createElement("input");j.type="hidden";j.name="constraint"+counter;j.value=cons.path;
h.appendChild(j);j=document.createElement("label");j.className="text-input";j["for"]="op"+counter;j.innerHTML=cons.path+": ";h.appendChild(j);g.appendChild(h);j=document.createElement("td");h=getOpInput(counter,cons,false);j.appendChild(h);g.appendChild(j);j=document.createElement("td");var k=document.createElement("input");k.type="text";k.className="text-input";k.name="value"+counter;k.value=cons.value;j.appendChild(k);$(h).change(function(){k.disabled=$(this).val().match(/NULL/)?true:false});h=
document.createElement("input");h.type="hidden";h.name="code"+counter;h.value=cons.code;j.appendChild(h);g.appendChild(j)}tempSpec.append(d)}}};
var loadTemplateInfo=function(a){$.jsonp({url:a,callbackParameter:"callback",data:{format:"jsonp"},success:function(b){window.availableTemplates=b;var e=[];for(name in b)e.push({value:name,label:b[name].title});$("#templateName").autocomplete({source:e,minLength:0,delay:0,focus:function(c,d){$("#templateName").val(d.item.value);return false},select:getSelectHandler(availableTemplates)}).focus(function(){$(this).autocomplete("search","")}).data("autocomplete")._renderItem=function(c,d){return $("<li></li>").data("item.autocomplete",
d).append("<a><strong>"+d.value+"</strong><br/><em>"+d.label+"</em></a>").appendTo(c)}}})},loadModel=function(a){$.jsonp({url:a,callbackParameter:"callback",data:{format:"jsonp"},success:function(b){model=b;$("#root-class").children("option").remove();var e=[];for(c in b.classes)e.push(c);e=e.sort();for(b=0;b<e.length;b++){var c=e[b],d=document.createElement("option");c=d.value=c;if(c.match(/s$/))c+="e";c+="s";d.innerHTML=c;$("#root-class").append(d)}}})};
$(function(){loadTemplateInfo("http://preview.flymine.org/preview/service/templates");loadModel("http://preview.flymine.org/preview/service/model")});<commit_msg>A minified version of the tutorial scripts<commit_after>availableTemplates=null;var model={};var baseUrl="http://squirrel.flymine.org/intermine-test";var flyMineBase="http://preview.flymine.org/preview";$(function(){IMBedding.setBaseUrl(baseUrl);Syntax.root="http://squirrel.flymine.org/imbedding/lib/jquery-syntax/";$(".js-snippet").syntax({brush:"javascript",layout:"list",replace:true,tabWidth:4,root:"lib/jquery-syntax/"});$(".html-snippet").syntax({brush:"html",layout:"list",replace:true,tabWidth:4,root:"lib/jquery-syntax/"});$("#showGraphAreaContainer").hide();loadTable1();loadTable3a();loadTable3b();loadTable3c();loadTable3d();loadTable4a();loadTable4b();loadTable4c();loadTable4d();loadTable4e();loadTable4();loadTable5();$("#faq").accordion({collapsible:true,autoHeight:false})});function setActiveStyleSheet(e){var d,c,b;for(d=0;(c=document.getElementsByTagName("link")[d]);d++){if(c.getAttribute("rel").indexOf("style")!=-1&&c.getAttribute("title")){c.disabled=true;if(c.getAttribute("title")==e){c.disabled=false}}}}function loadTable1(){IMBedding.loadTemplate({name:"AnatomyTerm_Alleles",constraint1:"Gene.alleles.alleleClass",op1:"=",value1:"*loss of function*",constraint2:"Gene.alleles.phenotypeAnnotations.description",op2:"=",value2:"*eye disc*"},"#placeholderEx2",{openOnLoad:true,baseUrl:flyMineBase})}function loadTable2(){IMBedding.loadTemplate({name:"Gene_upstreamRegulatoryRegions",constraint1:"Gene",op1:"LOOKUP",value1:"eve",code1:"A"},"#positionExample",{baseUrl:flyMineBase})}function loadTable3a(){IMBedding.loadTemplate({name:"Gene_allGOTerms2",constraint1:"Gene",op1:"LOOKUP",value1:"CG11348",code1:"A"},"#placeholderEx3a",{onTitleClick:"mine",baseUrl:flyMineBase})}function loadTable3b(){IMBedding.loadTemplate({name:"Gene_allGOTerms2",size:10,constraint1:"Gene",op1:"LOOKUP",value1:"CG11348",code1:"A"},"#placeholderEx3b",{onTitleClick:"none",baseUrl:flyMineBase})}function loadTable3c(){var a=function(){alert("You clicked on:\n"+$(this).text())};IMBedding.loadTemplate({name:"Gene_allGOTerms2",size:10,constraint1:"Gene",op1:"LOOKUP",value1:"CG11348",code1:"A"},"#placeholderEx3c",{onTitleClick:a,titleHoverCursor:"help",baseUrl:flyMineBase})}function loadTable3d(){IMBedding.loadTemplate({name:"Gene_allGOTerms2",size:10,constraint1:"Gene",op1:"LOOKUP",value1:"CG11348",code1:"A"},"#placeholderEx3d",{baseUrl:flyMineBase})}function loadTable4a(){IMBedding.loadTemplate({name:"Organism_GeneDomain_new",size:10,constraint1:"ProteinDomain.proteins.genes.organism.name",op1:"=",value1:"Drosophila melanogaster",code1:"A",constraint2:"ProteinDomain.shortName",op2:"=",value2:"*homeo*",code2:"B"},"#placeholderEx4a",{showExportLinks:false,baseUrl:flyMineBase})}function loadTable4b(){IMBedding.loadTemplate({name:"Organism_GeneDomain_new",size:10,constraint1:"ProteinDomain.proteins.genes.organism.name",op1:"=",value1:"Drosophila melanogaster",code1:"A",constraint2:"ProteinDomain.shortName",op2:"=",value2:"*homeo*",code2:"B"},"#placeholderEx4b",{showCount:false,baseUrl:flyMineBase})}function loadTable4c(){IMBedding.loadTemplate({name:"Organism_GeneDomain_new",size:10,constraint1:"ProteinDomain.proteins.genes.organism.name",op1:"=",value1:"Drosophila melanogaster",code1:"A",constraint2:"ProteinDomain.shortName",op2:"=",value2:"*homeo*",code2:"B"},"#placeholderEx4c",{showMineLink:false,baseUrl:flyMineBase})}function loadTable4d(){IMBedding.loadTemplate({name:"Organism_GeneDomain_new",size:15,constraint1:"ProteinDomain.proteins.genes.organism.name",op1:"=",value1:"Drosophila melanogaster",code1:"A",constraint2:"ProteinDomain.shortName",op2:"=",value2:"*homeo*",code2:"B"},"#placeholderEx4d",{baseUrl:flyMineBase})}function loadTable4e(){var a={baseUrl:flyMineBase,nextText:"avanti",previousText:"indietro",additionText:"carica altre x righe",allRowsText:"carica tutte righe",emptyCellText:"[NIENTE]",collapseHelpText:"chiudi tabella",expandHelpText:"mostra tabella",exportCSVText:"Esporta il risultato in formato CSV",exportTSVText:"Esporta il risultato in formato TSV",mineLinkText:"Guarda in Mine"};IMBedding.loadTemplate({name:"Organism_GeneDomain_new",size:15,constraint1:"ProteinDomain.proteins.genes.organism.name",op1:"=",value1:"Drosophila melanogaster",code1:"A",constraint2:"ProteinDomain.shortName",op2:"=",value2:"*homeo*",code2:"B"},"#placeholderEx4e",a)}function loadTable4(){IMBedding.loadTemplate({name:"Chromosome_Gene",constraint1:"Gene.chromosome.primaryIdentifier",op1:"=",value1:"2L",code1:"A",constraint2:"Gene.organism.name",op2:"=",value2:"Drosophila melanogaster",code2:"B"},"#placeholder1",{baseUrl:flyMineBase})}function loadTable5(){IMBedding.loadTemplate({name:"Chromosome_Gene",constraint1:"Gene.chromosome.primaryIdentifier",op1:"=",value1:"2L",code1:"A",constraint2:"Gene.organism.name",op2:"=",value2:"Drosophila melanogaster",code2:"B"},"#styleDemo",{baseUrl:flyMineBase})}function loadGraph1(){IMBedding.loadQuery({select:["Employee.age","Employee.department.company.name"],from:"testmodel"},{size:1000,format:"jsonpobjects"},function(j){var l=[];var b=0;var o={};for(i in j.results){var k=j.results[i];var m=k.age;var h=k.department.company.name;b+=m;if(!o[h]){o[h]={}}if(!o[h][m]){o[h][m]=1}else{o[h][m]=o[h][m]+1}}for(name in o){var h=o[name];var f=0;var e=0;var d={data:[]};for(m in h){f+=h[m];e+=m*h[m];d.data.push([m,h[m]])}var c=parseInt(e/f);d.label=name+" [av: "+c+"]";l.push(d)}var n={series:{stack:true,lines:{show:false},bars:{show:true,barWidth:0.9}},legend:{position:"nw"}};var g=$.plot("#graph",l,n);var a=parseInt(b/j.results.length);$("<span></span>").html("Age (average:"+a+")").addClass("axis-label").appendTo("#graph")})}function showTooltip(a,c,b){$('<div id="tooltip"></div>').html(b).addClass("tooltip").css({position:"absolute",display:"none",top:c+10,left:a+10,border:"2px solid #FF0084",padding:"5px","border-radius":"5px","-moz-border-radius":"5px","background-color":"#FE45A5",color:"white",opacity:0.7}).appendTo("body").fadeIn(200)}function findLineByLeastSquares(j){var p=0;var o=0;var c=0;var d=0;var g=0;var n=0;var l=0;var h=j.length;if(h===0){return[]}for(var f=0;f<h;f++){n=j[f][0];l=j[f][1];p+=n;o+=l;d+=n*n;c+=n*l;g++}var a=(g*c-p*o)/(g*d-p*p);var k=(o/g)-(a*p)/g;var e=[];for(var f=0;f<h;f++){n=j[f][0];l=n*a+k;e.push([n,l])}return e}function loadGraph2(){IMBedding.loadQuery({select:["Manager.age","Manager.seniority","Manager.name"],where:[{path:"Manager.age",op:">",value:30}],from:"testmodel"},{size:1000,format:"jsonpobjects"},function(e){var f=[];var h={};var a={label:"Seniority by Age",color:"rgb(0, 115, 234)",points:{show:true},data:[]};var k={label:"Trend Line",color:"rgb(255, 0, 132)",lines:{show:true}};for(i in e.results){var b=e.results[i];var c=b.seniority;var g=b.age;a.data.push([g,c]);h[g+"-"+c]=b}k.data=findLineByLeastSquares(a.data);f.push(a);f.push(k);var j={grid:{hoverable:true,clickable:true},legend:{position:"nw"}};var d=$.plot("#graph",f,j);$("#graph").bind("plothover",function(p,r,o){if(o){$("#tooltip").remove();var l=o.datapoint[0].toFixed(2),q=o.datapoint[1].toFixed(2);var n=parseInt(l)+"-"+parseInt(q);var m=h[n];showTooltip(o.pageX,o.pageY,m.name)}else{$("#tooltip").remove();previousPoint=null}}).bind("plotclick",function(q,s,p){if(p){var l=p.datapoint[0].toFixed(2),r=p.datapoint[1].toFixed(2);var o=parseInt(l)+"-"+parseInt(r);var n=h[o];var m=baseUrl+"/objectDetails.do?id="+n.objectId;window.location.replace(m)}});$("<span></span>").html("Age").addClass("axis-label").appendTo("#graph")})}function loadDepartmentSummary(a){a=a||"Sales";IMBedding.loadQuery({select:["Department.name","Department.company.name","Department.employees.name","Department.employees.age","Department.employees.address.address","Department.manager.name","Department.company.departments.name"],where:[{path:"Department.name",op:"=",value:a},{path:"Department.company.name",op:"=",value:"Wernham-Hogg"}],from:"testmodel"},{size:1000,format:"jsonpobjects"},function(o){var d=o.results[0];var g=$("<div></div>").addClass("department-summary");var n=document.createElement("h2");n.appendChild(document.createTextNode(d.company.name+": "));var p=document.createElement("select");$(p).button();var b=d.company.departments.length;for(var c=0;c<b;c++){var j=d.company.departments[c];var f=document.createElement("option");if(j.objectId==d.objectId){f.selected=true}f.innerHTML=j.name;p.appendChild(f)}n.appendChild(p);$(p).change(function(){loadDepartmentSummary($(p).val())});g.append(n);var m=document.createElement("h3");m.innerHTML="Manager: "+d.manager.name;g.append(m);var l=d.employees.length;var e=document.createElement("ul");for(var c=0;c<l;c++){var k=d.employees[c];if(k.objectId==d.manager.objectId){continue}var q=document.createElement("li");var h=document.createElement("a");h.href=baseUrl+"/objectDetails.do?id="+k.objectId;h.innerHTML=k.name;q.appendChild(h);$(h).hover(getEmployeeTooltipper(k),function(r){$(".tooltip").remove()});e.appendChild(q)}g.append(e);$("#graph").empty().append(g)})}var getEmployeeTooltipper=function(a){return function(c){var n=document.createElement("div");var b=document.createElement("h3");b.innerHTML=a.name;n.appendChild(b);var m=document.createElement("table");m.className="employee-details";var g=document.createElement("tr");var f=document.createElement("td");f.innerHTML="Age:";f.className="summary-cell";var d=document.createElement("td");d.innerHTML=a.age;d.align="right";d.className="summary-cell";g.appendChild(f);g.appendChild(d);m.appendChild(g);var e=document.createElement("tr");var l=document.createElement("td");l.innerHTML="Address:";l.className="summary-cell";var k=document.createElement("td");k.innerHTML=a.address.address;k.className="summary-cell";e.appendChild(l);e.appendChild(k);m.appendChild(e);n.appendChild(m);var j=c.pageX;var h=c.pageY;showTooltip(j,h,n)}};var toggleExample=function(){$("#exampleCode").slideToggle("fast",function(){});$("#querybuilder").slideToggle("fast",function(){})};var firstline="/* Below is the Javascript to load this table using ajax:\nYou can cut and paste this into a page to get started.\nDon't forget you need to include the imbedding.js library in your head */\n\n/* You only need to do the following once */\n";var JSON=JSON||{};JSON.stringify=JSON.stringify||function(e){var d=typeof(e);if(d!="object"||e===null){if(d=="string"){e='"'+e+'"'}return String(e)}else{var f,b,c=[],a=(e&&e.constructor==Array);for(f in e){b=e[f];d=typeof(b);if(d=="string"){b='"'+b+'"'}else{if(d=="object"&&b!==null){b=JSON.stringify(b)}}c.push((a?"":'"'+f+'":')+String(b))}return(a?"[":"{")+String(c)+(a?"]":"}")}};var getQueryFromForm=function(){var l=$("#root-class").val();var g=[];var r=$("#views-form").serializeArray();for(var o=0;o<r.length;o++){var t=r[o];g.push(l+"."+t.value)}var n={};var e=$("#constraints-form").serializeArray();var c={};for(var o=0;o<e.length;o++){var t=e[o];var p=t.name.match(/\d+/)[0];if(!n[p]){n[p]={code:letters.charAt(parseInt(p)-1)}}var k=t.name.match(/[a-z]+/)[0];if(k=="constraint"){n[p].path=l+"."+t.value}else{if(k=="op"){if(t.value=="ISA"){c[p]=true}else{n[p].op=t.value}}else{if(k=="value"){if(c[p]){n[p].type=t.value}else{n[p].value=t.value}}else{throw ("Unexpected constraint property: "+k)}}}}var f=[];for(key in n){f.push(n[key])}var h=$("#joins-form").serializeArray();var a={};for(var o=0;o<h.length;o++){var t=h[o];var b=t.name.match(/\d+/)[0];if(!a[b]){a[b]={}}var s=t.name.match(/[a-z]+/)[0];if(s=="join"){a[b].path=l+"."+t.value}else{if(s=="style"){a[b].style=t.value}else{throw ("Unexpected join property: "+s)}}}var j=[];for(key in a){j.push(a[key])}var m=$("#sortOrderSelector").val()+" "+$("input:radio[name=sortDirection]:checked").val();var q=$("#logic").val();var d={select:g,where:f,joins:j,sortOrder:m,from:model.name};if(q.length>0){d.constraintLogic=q}return d};var getQueryFromBox=function(){var format=$("#boxselector").val();if(format=="xml"){return $("#xmlarea").val()}else{if(format=="json"){var jsonString=$("#jsonarea").val();var parsedQuery;try{parsedQuery=eval("("+jsonString+")")}catch(e){alert("Something is wrong with your json\n"+e)}return parsedQuery}else{return null}}};var makeQueryDisplayStrings=function(e){if(!jQuery.isPlainObject(e)){var f=e.replace(/&gt;/g,"&amp;gt;").replace(/&lt;/g,"&amp;lt;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return[null,f]}var c=JSON.stringify(e);var d=c.match(/"\w+":/g);if(d){for(var b=0;b<d.length;b++){var a=d[b];var g=a.replace(/"/g,"").replace(":",": ");c=c.replace(a,g)}}c=c.replace(/\}\],/g,"}\n\t],").replace(/\},\{/g,"},\n\t{").replace(/\],/g,"],\n\t").replace(/^\{/,"{\n\t").replace(/\[\{/g,"[\n\t{").replace(/\}$/,"\n}").replace(/",/g,'", ').replace(/\t\{/g,"\t\t{");var f=IMBedding.makeQueryXML(e).replace(/&gt;/g,"&amp;gt;").replace(/&lt;/g,"&amp;lt;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return[c,f]};function loadUserQuery(){var a=$("input:radio[name=query]:checked").val();var j;if(a=="querybuilder"){j=getQueryFromForm()}else{j=getQueryFromBox()}if(!j){return false}var k=makeQueryDisplayStrings(j);if(!k){return false}var g={size:10};var c=firstline+"IMBedding.setBaseUrl('";var d=flyMineBase;c+=d+"');\n\n";var b={baseUrl:d};if(k[0]){c+="/*You can define the query as a regular javascript object*/\nvar query = "+k[0]+";\n"}if(k[1]){c+="\n/*A query can be defined as XML*/\nvar query = '"+k[1]+"';\n\n"}c+="/*Execution is the same in either case*/\nIMBedding.loadQuery(query, {size: 10}, '#placeholder');";var h=$("#codeContainer");h.empty();var e=document.createElement("textarea");e.id="codeDisplay";e.className="coder";e.cols=80;e.innerHTML=c;h.append(e);Syntax.root="http://squirrel.flymine.org/imbedding/lib/jquery-syntax/";$(e).syntax({brush:"javascript",layout:"list",replace:true,tabWidth:4,root:"lib/jquery-syntax/"});try{IMBedding.loadQuery(j,g,"#placeholder2",b)}catch(f){alert("There was something wrong with your query:\n"+f)}}function complainAboutName(d){tempSpec=$("#templateSpecific");var b=document.createElement("p");b.className="ui-state-error ui-corner-all";var c=document.createElement("span");c.className="ui-icon ui-icon-alert";c.style["float"]="left";c.style["margin-right"]=".3em";b.appendChild(c);var a=document.createElement("strong");a.innerHTML="Um, excuse me:";b.appendChild(a);b.appendChild(document.createTextNode(" "+d));tempSpec.prepend(b);return}function loadUserTemplate(){var e=$("#template-form").serializeArray();if(!e[0].value){complainAboutName("Please enter a template name first");return}else{if(!(e[0].value in window.availableTemplates)){complainAboutName("Check the name - "+e[0].value+" is not one of the available templates");return}}var c={size:10};var d=firstline+"IMBedding.setBaseUrl('";var f;f=flyMineBase;d+=f+"');\n\n";var b={baseUrl:f};d+="IMBedding.loadTemplate(\n\t{\n\t";for(x in e){name=e[x].name;value=e[x].value;c[name]=value;if(name.match("constraint")){d+="\n\t"}d+="\t"+name+":\t";if(!name.match(/constraint/)){d+="\t\t"}d+='"'+value+'",\n\t'}d+="},\n\t'#placeholder'\n);";var g=$("#templateCodeContainer");g.empty();var a=document.createElement("textarea");a.id="templateCodeDisplay";a.className="coder";a.cols=80;a.innerHTML=d;g.append(a);Syntax.root="http://squirrel.flymine.org/imbedding/lib/jquery-syntax/";$(a).syntax({brush:"javascript",layout:"list",replace:true,tabWidth:4,root:"lib/jquery-syntax/"});IMBedding.loadTemplate(c,"#placeholder3",b)}$(function(){$("#tabs").tabs()});var oldRootClass="Employee";$(function(){$("input:button").button();$("button").button();$("#positionExButton").click(function(){loadTable2();$(this).hide()});$("#librHeadButton").click(function(){$("#librariesHead").slideToggle()});$("#query-loader").click(function(){loadUserQuery()});$("#view-adder").click(function(){var a=$("#root-class").val();addViewLine(a)});$("#constraint-adder").click(function(){var a=$("#root-class").val();addConstraintLine(a,true)});$("#join-adder").click(function(){var a=$("#root-class").val();addJoinLine(a)});$("#root-class").change(function(){$("#dialog-confirm").dialog({modal:true,width:400,position:"center",buttons:{"Change root class":function(){$("#querybuilder-views").empty();$("#querybuilder-constraints").empty();$("#querybuilder-joins").empty();$("#sortOrderSelector").empty();$("#sortOrderDiv").hide();$("#logic-box").hide();oldRootClass=$("#root-class").val();$(this).dialog("close")},Cancel:function(){$("#root-class").val(oldRootClass);$(this).dialog("close")}}})});$("#source-radios-t").buttonset();$(".sourcer").click(function(){if(this.value=="testmodel"){loadTemplateInfo("http://squirrel.flymine.org/intermine-test/service/templates")}else{if(this.value=="flymine"){loadTemplateInfo("http://preview.flymine.org/preview/service/templates")}}});$("#source-radios-q").buttonset();$(".model-sourcer").click(function(){if(this.value=="testmodel"){loadModel("http://squirrel.flymine.org/intermine-test/service/model")}else{if(this.value=="flymine"){loadModel("http://preview.flymine.org/preview/service/model")}}});$("#sortOrderSelector").button();$("#sortDirectionDiv").buttonset();$("#boxselector").change(function(){document.getElementById("jsonarea").disabled=($(this).val()=="xml");document.getElementById("xmlarea").disabled=($(this).val()=="json")});$("input:checkbox").button();$("#radio").buttonset();$("#graph-radios").buttonset();$("#query-radios").buttonset();$(".styles").buttonset();$("#querybuilder-opt").click(function(){$("#querybuilder").slideDown("fast",function(){});$("#cutandpaste").slideUp("fast",function(){})});$("#cutandpaste-opt").click(function(){$("#querybuilder").slideUp("fast",function(){});$("#cutandpaste").slideDown("fast",function(){})});$("#showMe").click(function(){$("#showMeAreaContainer").slideToggle("fast",function(){})});$("#showMeGraphCode").click(function(){$("#showGraphAreaContainer").slideToggle("fast",function(){})});$("#showTemplateCode").click(function(){$("#templateCodeContainer").slideToggle("fast",function(){})});$("#showQueryCode").click(function(){$("#codeContainer").slideToggle("fast",function(){})});$("input.styler").click(function(){setActiveStyleSheet(this.value)});$("input.templater").click(function(){if(this.id.match(/1/)){loadTable1()}else{if(this.id.match(/2/)){loadTable2()}else{if(this.id.match(/3/)){loadTable3()}}}});$("input.grapher").click(function(){if(this.id.match(/1/)){loadGraph1()}else{if(this.id.match(/2/)){loadGraph2()}else{if(this.id.match(/3/)){loadDepartmentSummary()}}}})});var operators={"=":"is","!=":"isn't",">":"is greater than/sorts after","<":"is less than/sorts before",">=":"is greater than or equal to","<=":"is less than or equal to",LIKE:"matches",LOOKUP:"any field matches",ISA:"is a","IS NOT NULL":"exists","IS NULL":"doesn't exist"};var isAttributeOp={"=":true,"!=":true,">":true,"<":true,">=":true,"<=":true,LIKE:true,LOOKUP:false,ISA:false,"IS NOT NULL":true,"IS NULL":true};var getViewCount=function(){return $("#querybuilder-views").children().length};var getConstraintCount=function(){return $("#querybuilder-constraints > tbody").children("tr").length};var getJoinCount=function(){return $("#querybuilder-joins").children().length};var getViewPathSuggester=function(a){return function(d,f){var c=d.term;var e=getPossibleViewPathsFor(a);var b=[];for(i in e){if(e[i].value.substring(0,c.length)==c){b.push(e[i])}}f(b)}};var getConsPathSuggester=function(a){return function(d,f){var c=d.term;var e=getPossibleConsPathsFor(a);var b=[];for(i in e){if(e[i].value.substring(0,c.length)==c){b.push(e[i])}}f(b)}};var getJoinPathSuggester=function(a){return function(d,f){var c=d.term;var e=getPossibleConsPathsFor(a);var b=[];for(i in e){if(e[i].type=="reference"&&e[i].value.substring(0,c.length)==c){b.push(e[i])}}f(b)}};var addToSortOrders=function(b){$("#sortOrderDiv").show();var a=document.createElement("option");a.value=b;a.innerHTML=b;$("#sortOrderSelector").append(a)};var removeSortOrder=function(a){$("#sortOrderSelector").children("option").each(function(){if(this.value==a){$(this).detach()}});if($("#sortOrderSelector").children("option").length<1){$("#sortOrderDiv").hide()}};var addViewLine=function(c){var f=document.createElement("tr");var b=document.createElement("td");var a=document.createElement("code");a.innerHTML=c+".";b.appendChild(a);var e=document.createElement("input");e.className="text-input";e.type="text";e.size=80;e.name="view"+(getViewCount()+1);$(e).autocomplete({source:getViewPathSuggester(c),minLength:2,change:function(h,j){addToSortOrders(c+"."+$(e).val())}});b.appendChild(e);f.appendChild(b);var d=document.createElement("td");var g=document.createElement("button");g.appendChild(document.createTextNode("delete"));$(g).click(function(){$(f).detach();removeSortOrder(c+"."+$(e).val())});$(g).button();d.appendChild(g);f.appendChild(d);$("#querybuilder-views").append(f)};var viewPathsFor={};var getPossibleViewPathsFor=function(a){if(viewPathsFor[a]){return viewPathsFor[a]}var b=getPathsFor(a);viewPathsFor[a]=b;return b};var consPathsFor={};var getPossibleConsPathsFor=function(a){if(consPathsFor[a]){return consPathsFor[a]}var b=getPathsFor(a,null,0,true);consPathsFor[a]=b;return b};var getPathsFor=function(b,n,a,l){a=a||0;if(a>3){return[]}a++;var o=[];var g=model.classes[b];var m=g.attributes;for(var f=0;f<m.length;f++){if(m[f].name==n){continue}o.push({value:m[f].name,type:"attribute"})}var k=g.references;for(var f=0;f<k.length;f++){if(l){o.push({value:k[f].name,type:"reference"})}var d=getPathsFor(k[f].referencedType,k[f].reverseReference,a,l);for(var e=0;e<d.length;e++){o.push({value:k[f].name+"."+d[e].value,type:d[e].type})}}var h=g.collections;for(var f=0;f<h.length;f++){if(l){o.push({value:h[f].name,type:"reference"})}var c=getPathsFor(h[f].referencedType,h[f].reverseReference,a,l);for(var e=0;e<c.length;e++){o.push({value:h[f].name+"."+c[e].value,type:c[e].type})}}return o};var letters="ABCDEFGHIJKMNOPQRSTUVWXYZ";var addConstraintLine=function(d,h){var a=getConstraintCount()+1;if(a>1){$("#logic-box").show()}var m=document.createElement("tr");var e=document.createElement("td");e.appendChild(document.createTextNode(d+"."));var k=document.createElement("input");k.className="text-input";k.type="text";k.size=40;k.name="constraint"+a;e.appendChild(k);m.appendChild(e);var g=document.createElement("td");var c=getOpInput(a,null,h);g.appendChild(c);m.appendChild(g);var f=document.createElement("td");var l=document.createElement("input");l.type="text";l.name="value"+a;f.appendChild(l);m.appendChild(f);$(c).change(function(){if($(this).val().match(/NULL/)){l.disabled=true}else{l.disabled=false}});$(k).autocomplete({source:getConsPathSuggester(d),minLength:2,select:function(o,p){var n=p.item.type;if(n=="attribute"){enableAttributeOptions(c)}else{enableClassOptions(c)}}});var b=document.createElement("td");var j=document.createElement("button");j.innerHTML="delete";$(j).click(function(){$(m).detach();if($("#querybuilder-constraints > tbody").children().length<2){$("#logic-box").hide()}});$(j).button();b.appendChild(j);m.appendChild(b);$("#querybuilder-constraints").append(m)};var addJoinLine=function(d){var a=getJoinCount()+1;var n=document.createElement("tr");var e=document.createElement("td");e.appendChild(document.createTextNode(d+"."));var m=document.createElement("input");m.className="text-input";m.type="text";m.size=40;m.name="join"+a;e.appendChild(m);n.appendChild(e);var b=document.createElement("td");var k=document.createElement("div");var h=document.createElement("input");h.type="radio";h.id="inner"+a;h.value="INNER";h.name="style"+a;h.checked=true;k.appendChild(h);var f=document.createElement("label");f.setAttribute("for","inner"+a);f.innerHTML="INNER";k.appendChild(f);var g=document.createElement("input");g.type="radio";g.id="outer"+a;g.value="OUTER";g.name="style"+a;k.appendChild(g);var j=document.createElement("label");j.setAttribute("for","outer"+a);j.innerHTML="OUTER";k.appendChild(j);b.appendChild(k);n.appendChild(b);$(k).buttonset();$(m).autocomplete({source:getJoinPathSuggester(d),minLength:2});var c=document.createElement("td");var l=document.createElement("button");l.innerHTML="delete";$(l).click(function(){$(n).detach()});$(l).button();c.appendChild(l);n.appendChild(c);$("#querybuilder-joins").append(n)};function enableAttributeOptions(b){var a=$(b).children("option");a.each(function(){this.disabled=!isAttributeOp[this.value];if(this.selected&&this.disabled){this.selected=false}})}function enableClassOptions(b){var a=$(b).children("option");a.each(function(){this.disabled=isAttributeOp[this.value];if(this.selected&&this.disabled){this.selected=false}})}function getOpInput(b,a,e){var c=document.createElement("select");c.name="op"+b;for(op in operators){if(op=="ISA"&&!e){continue}var d=document.createElement("option");d.value=op;d.innerHTML=operators[op];if(a&&op==a.op){d.selected="selected"}c.appendChild(d)}return c}getSelectHandler=function(a){return function(b,h){if(h.item){var d=h.item.value;tempSpec=$("#templateSpecific");tempSpec.empty();var o=a[d];var l=document.createElement("h3");l.innerHTML=o.title;tempSpec.append(l);var q=document.createElement("table");for(var e=0;e<o.constraints.length;e++){var r=document.createElement("tr");q.appendChild(r);cons=o.constraints[e];counter=e+1;var n=document.createElement("td");var m=document.createElement("input");m.type="hidden";m.name="constraint"+counter;m.value=cons.path;n.appendChild(m);var k=document.createElement("label");k.className="text-input";k["for"]="op"+counter;k.innerHTML=cons.path+": ";n.appendChild(k);r.appendChild(n);var j=document.createElement("td");var c=getOpInput(counter,cons,false);j.appendChild(c);r.appendChild(j);var g=document.createElement("td");var p=document.createElement("input");p.type="text";p.className="text-input";p.name="value"+counter;p.value=cons.value;g.appendChild(p);$(c).change(function(){if($(this).val().match(/NULL/)){p.disabled=true}else{p.disabled=false}});var f=document.createElement("input");f.type="hidden";f.name="code"+counter;f.value=cons.code;g.appendChild(f);r.appendChild(g)}tempSpec.append(q)}}};var loadTemplateInfo=function(a){$.jsonp({url:a,callbackParameter:"callback",data:{format:"jsonp"},success:function(b){window.availableTemplates=b;var c=[];for(name in b){c.push({value:name,label:b[name].title})}$("#templateName").autocomplete({source:c,minLength:0,delay:0,focus:function(d,e){$("#templateName").val(e.item.value);return false},select:getSelectHandler(availableTemplates)}).focus(function(){$(this).autocomplete("search","")}).data("autocomplete")._renderItem=function(d,e){return $("<li></li>").data("item.autocomplete",e).append("<a><strong>"+e.value+"</strong><br/><em>"+e.label+"</em></a>").appendTo(d)}}})};var loadModel=function(a){$.jsonp({url:a,callbackParameter:"callback",data:{format:"jsonp"},success:function(f){model=f;$("#root-class").children("option").remove();var g=[];for(c in f.classes){g.push(c)}g=g.sort();for(var d=0;d<g.length;d++){var c=g[d];var e=document.createElement("option");e.value=c;var b=c;if(b.match(/s$/)){b+="e"}b+="s";e.innerHTML=b;$("#root-class").append(e)}}})};$(function(){loadTemplateInfo("http://preview.flymine.org/preview/service/templates");loadModel("http://preview.flymine.org/preview/service/model")});
{'fraction_non_alphanumeric': 0.2707538811202281, 'fraction_numerical': 0.011691513540583228, 'mean_word_length': 16.174660932848163, 'pattern_counts': {'":': 60, '<': 84, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6744387', 'n_tokens_mistral': 18823, 'n_tokens_neox': 18434, 'n_words': 905}