Template:Team:Paris Saclay/simbox
From 2013.igem.org
(Difference between revisions)
Line 1: | Line 1: | ||
<html> | <html> | ||
<script> | <script> | ||
- | + | 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 | ||
- | + | simulations[id].volume= xmldata.getElementsByTagName("volume")[0].childNodes[0].nodeValue; | |
- | + | simulations[id].timestep= xmldata.getElementsByTagName("timestep")[0].childNodes[0].nodeValue; | |
//Load molecules | //Load molecules | ||
- | |||
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) | ||
{ | { | ||
- | + | simulations[id].molecules[i]= new molecule(); | |
- | + | simulations[id].molecules[i].name= molecule_tags[i].getAttribute('name'); | |
if(molecule_tags[i].hasAttribute('quantity')) | if(molecule_tags[i].hasAttribute('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')) | ||
- | + | 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')) | ||
- | + | simulations[id].molecules[i].curve_color= molecule_tags[i].getAttribute('curve_color'); | |
if(molecule_tags[i].hasAttribute('const')) | if(molecule_tags[i].hasAttribute('const')) | ||
- | + | simulations[id].molecules[i].const= (molecule_tags[i].getAttribute('const') == 'true'); | |
if(molecule_tags[i].hasAttribute('adjustable')) | if(molecule_tags[i].hasAttribute('adjustable')) | ||
- | + | 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 < | + | for(var i= 0 ; i < simulations[id].molecules.length ; ++i) |
{ | { | ||
- | if( | + | if(simulations[id].molecules[i].curve_show) |
- | reshtmlparamdiv += '<span style="font-weight:bold;padding:0.1em 0.3em;color:#FFFFFF;background-color:'+ | + | 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> '; |
} | } | ||
//quantity controls | //quantity controls | ||
- | for(var i= 0 ; i < | + | for(var i= 0 ; i < simulations[id].molecules.length ; ++i) |
{ | { | ||
- | if( | + | if(simulations[id].molecules[i].adjustable) |
{ | { | ||
reshtmlparamdiv += '<br /><br />'; | reshtmlparamdiv += '<br /><br />'; | ||
- | reshtmlparamdiv += | + | 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