Template:Team:Paris Saclay/simbox

From 2013.igem.org

(Difference between revisions)
 
(185 intermediate revisions not shown)
Line 1: Line 1:
-
<html>
+
<html><div class="simbox" data-width="785" data-height="300" data-load="https://2013.igem.org/Team:Paris_Saclay/</html>{{{load}}}<html>">Loading simulation...</div></html>
-
<script>
+
-
function page_loaded()
+
-
{
+
-
var simboxes= document.getElementsByClassName("simbox");
+
-
 
+
-
for(var i=0 ; i < simboxes.length ; ++i)
+
-
  init_simbox(simboxes[i], i);
+
-
}
+
-
 
+
-
function init_simbox(sb, id)
+
-
{
+
-
//Get parameters
+
-
var xmlfile= 'https://2013.igem.org/Team:Paris_Saclay/'+sb.getAttribute('data-load')+'?action=raw&ctype=text/css';
+
-
var width= sb.getAttribute('data-width');
+
-
var height= sb.getAttribute('data-height');
+
-
+
-
//Set box size
+
-
sb.style.width=width+"px";
+
-
sb.style.height=height+"px";
+
-
 
+
-
//Create canvas
+
-
var canv= document.createElement('canvas');
+
-
var ctx= canv.getContext("2d");
+
-
canv.id= "simbox_canv"+id;
+
-
canv.width= width;
+
-
canv.height= height;
+
-
sb.appendChild(canv);
+
-
 
+
-
//Create parameter box
+
-
var paramdiv= document.createElement('div');
+
-
sb.appendChild(paramdiv);
+
-
 
+
-
//Load data file
+
-
var xmldata= null;
+
-
try
+
-
{
+
-
  var xhr= new XMLHttpRequest();
+
-
  xhr.open("GET", xmlfile, false);
+
-
  xhr.send();
+
-
  var parser= new DOMParser();
+
-
  xmldata= parser.parseFromString(xhr.responseText, "application/xml");
+
-
}
+
-
catch(err)
+
-
{
+
-
  sb.innerHTML='Error : ' + err.message;
+
-
  return false;
+
-
}
+
-
+
-
alert(xmldata);
+
-
 
+
-
return true;
+
-
}
+
-
 
+
-
 
+
-
window.addEventListener("load", page_loaded, false);
+
-
</script>
+
-
 
+
-
<div class="simbox" data-width="</html>{{{width}}}<html>" data-height="</html>{{{height}}}<html>" data-load="</html>{{{load}}}<html>"></div>
+
-
 
+
-
</html>
+

Latest revision as of 20:48, 27 September 2013

Loading simulation...