Template:Team:Paris Saclay/simbox

From 2013.igem.org

(Difference between revisions)
Line 1: Line 1:
<html>
<html>
<script>
<script>
-
molecules= new Array();
+
simulations= new Array();
function simboxes_load()
function simboxes_load()
Line 21: Line 21:
}
}
 +
function simulation()
 +
{
 +
this.id= undefined;
 +
this.volume= undefined;
 +
this.timestep= undefined;
 +
this.molecules= Array();
 +
}
function init_simbox(sb, id)
function init_simbox(sb, id)
{
{
 +
simulations[id]= new simulation();
 +
  //Get parameters
  //Get parameters
  var xmlfile= 'https://2013.igem.org/Team:Paris_Saclay/'+sb.getAttribute('data-load')+'?action=raw&ctype=text/css';
  var xmlfile= 'https://2013.igem.org/Team:Paris_Saclay/'+sb.getAttribute('data-load')+'?action=raw&ctype=text/css';
Line 48: Line 57:
  //Load simulation parameters
  //Load simulation parameters
-
  var volume= xmldata.getElementsByTagName("volume")[0].childNodes[0].nodeValue;
+
  simulations[id].volume= xmldata.getElementsByTagName("volume")[0].childNodes[0].nodeValue;
-
  var timestep= xmldata.getElementsByTagName("timestep")[0].childNodes[0].nodeValue;
+
  simulations[id].timestep= xmldata.getElementsByTagName("timestep")[0].childNodes[0].nodeValue;
  //Load molecules
  //Load molecules
-
molecules[id]= new Array();
 
  var molecule_tags= xmldata.getElementsByTagName("molecule");
  var molecule_tags= xmldata.getElementsByTagName("molecule");
  for(var i= 0 ; i < molecule_tags.length ; ++i)
  for(var i= 0 ; i < molecule_tags.length ; ++i)
  {  
  {  
-
   molecules[id][i]= new molecule();
+
   simulations[id].molecules[i]= new molecule();
-
   molecules[id][i].name= molecule_tags[i].getAttribute('name');
+
   simulations[id].molecules[i].name= molecule_tags[i].getAttribute('name');
   if(molecule_tags[i].hasAttribute('quantity'))
   if(molecule_tags[i].hasAttribute('quantity'))
-
   molecules[id][i].quantity= molecule_tags[i].getAttribute('quantity');
+
   simulations[id].molecules[i].quantity= molecule_tags[i].getAttribute('quantity');
   if(molecule_tags[i].hasAttribute('curve_show'))
   if(molecule_tags[i].hasAttribute('curve_show'))
-
   molecules[id][i].curve_show= (molecule_tags[i].getAttribute('curve_show') == 'true');
+
   simulations[id].molecules[i].curve_show= (molecule_tags[i].getAttribute('curve_show') == 'true');
   if(molecule_tags[i].hasAttribute('curve_color'))
   if(molecule_tags[i].hasAttribute('curve_color'))
-
   molecules[id][i].curve_color= molecule_tags[i].getAttribute('curve_color');
+
   simulations[id].molecules[i].curve_color= molecule_tags[i].getAttribute('curve_color');
   if(molecule_tags[i].hasAttribute('const'))
   if(molecule_tags[i].hasAttribute('const'))
-
   molecules[id][i].const= (molecule_tags[i].getAttribute('const') == 'true');
+
   simulations[id].molecules[i].const= (molecule_tags[i].getAttribute('const') == 'true');
   if(molecule_tags[i].hasAttribute('adjustable'))
   if(molecule_tags[i].hasAttribute('adjustable'))
-
   molecules[id][i].adjustable= (molecule_tags[i].getAttribute('adjustable') == 'true');
+
   simulations[id].molecules[i].adjustable= (molecule_tags[i].getAttribute('adjustable') == 'true');
  }
  }
Line 83: Line 91:
  //legend
  //legend
  var reshtmlparamdiv= '';
  var reshtmlparamdiv= '';
-
  for(var i= 0 ; i < molecules[id].length ; ++i)
+
  for(var i= 0 ; i < simulations[id].molecules.length ; ++i)
  {
  {
-
   if(molecules[id][i].curve_show)
+
   if(simulations[id].molecules[i].curve_show)
-
   reshtmlparamdiv += '<span style="font-weight:bold;padding:0.1em 0.3em;color:#FFFFFF;background-color:'+molecules[id][i].curve_color+';">'+molecules[id][i].name+'</span>&nbsp;';
+
   reshtmlparamdiv += '<span style="font-weight:bold;padding:0.1em 0.3em;color:#FFFFFF;background-color:'+simulations[id].molecules[i].curve_color+';">'+simulations[id].molecules[i].name+'</span>&nbsp;';
  }
  }
  //quantity controls
  //quantity controls
-
  for(var i= 0 ; i < molecules[id].length ; ++i)
+
  for(var i= 0 ; i < simulations[id].molecules.length ; ++i)
  {
  {
-
   if(molecules[id][i].adjustable)
+
   if(simulations[id].molecules[i].adjustable)
   {
   {
   reshtmlparamdiv += '<br /><br />';
   reshtmlparamdiv += '<br /><br />';
-
   reshtmlparamdiv += molecules[id][i].name + ' = <input id="simbox_ctl'+i+'" type="number" min="0" value="'+molecules[id][i].quantity+'"/>';
+
   reshtmlparamdiv += simulations[id].molecules[i].name + ' = <input id="simbox_ctl'+i+'" type="number" min="0" value="'+simulations[id].molecules[i].quantity+'"/>';
   }
   }
  }
  }
 +
reshtmlparamdiv += '<br />';
 +
//controls
 +
reshtmlparamdiv += '<button>START</button><button>RESET</button>'
 +
  paramdiv.innerHTML= reshtmlparamdiv;
  paramdiv.innerHTML= reshtmlparamdiv;

Revision as of 21:22, 2 August 2013