Template:Team:Paris Saclay/simbox
From 2013.igem.org
(Difference between revisions)
Line 1: | Line 1: | ||
<html> | <html> | ||
<script> | <script> | ||
- | function | + | function simboxes_load() |
{ | { | ||
var simboxes= document.getElementsByClassName("simbox"); | var simboxes= document.getElementsByClassName("simbox"); | ||
Line 8: | Line 8: | ||
init_simbox(simboxes[i], i); | init_simbox(simboxes[i], i); | ||
} | } | ||
+ | |||
+ | function molecule() | ||
+ | { | ||
+ | this.name= undefined; | ||
+ | this.quantity= 0; | ||
+ | this.curve_show= false; | ||
+ | this.curve_color= "#000000"; | ||
+ | this.const= false; | ||
+ | this.adjustable= false; | ||
+ | } | ||
+ | |||
function init_simbox(sb, id) | function init_simbox(sb, id) | ||
Line 32: | Line 43: | ||
sb.appendChild(paramdiv); | sb.appendChild(paramdiv); | ||
- | // | + | //Open XML data file |
var xmldata= null; | var xmldata= null; | ||
try | try | ||
Line 50: | Line 61: | ||
} | } | ||
+ | //Load simulation parameters | ||
var volume= xmldata.getElementsByTagName("volume")[0].childNodes[0].nodeValue; | var volume= xmldata.getElementsByTagName("volume")[0].childNodes[0].nodeValue; | ||
- | + | var timestep= xmldata.getElementsByTagName("timestep")[0].childNodes[0].nodeValue; | |
- | + | ||
- | //hasAttribute | + | //Load molecules |
+ | var molecules= new Array(); | ||
+ | var molecule_tags= xmldata.getElementsByTagName("molecule"); | ||
+ | for(var i= 0 ; i < molecule_tags.length ; ++i) | ||
+ | { | ||
+ | molecules[i]= new molecule(); | ||
+ | molecules[i].name= molecule_tags[i].getAttribute('name'); | ||
+ | if(molecule_tags[i].hasAttribute('quantity')) | ||
+ | molecules[i].quantity= molecule_tags[i].getAttribute('quantity'); | ||
+ | if(molecule_tags[i].hasAttribute('curve_show')) | ||
+ | molecules[i].curve_show= (molecule_tags[i].getAttribute('curve_show') == 'true'); | ||
+ | if(molecule_tags[i].hasAttribute('curve_color')) | ||
+ | molecules[i].curve_color= molecule_tags[i].getAttribute('curve_color'); | ||
+ | if(molecule_tags[i].hasAttribute('const')) | ||
+ | molecules[i].const= (molecule_tags[i].getAttribute('const') == 'true'); | ||
+ | if(molecule_tags[i].hasAttribute('adjustable')) | ||
+ | molecules[i].adjustable= (molecule_tags[i].getAttribute('adjustable') == 'true'); | ||
+ | } | ||
+ | |||
+ | for(var i= 0 ; i < molecules.length ; ++i) | ||
+ | { | ||
+ | alert(molecules[i].name); | ||
+ | } | ||
return true; | return true; | ||
Line 59: | Line 93: | ||
- | window.addEventListener("load", | + | window.addEventListener("load", simboxes_load, false); |
</script> | </script> | ||
Revision as of 19:49, 2 August 2013