Template:Team:Paris Saclay/simbox
From 2013.igem.org
(Difference between revisions)
Line 11: | Line 11: | ||
function init_simbox(sb, id) | 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 xmlfile= "https://2013.igem.org/Team:Paris_Saclay/"+sb.getAttribute('data-load')+"?action=raw&ctype=text/css"; | ||
var width= sb.getAttribute('data-width'); | var width= sb.getAttribute('data-width'); | ||
var height= sb.getAttribute('data-height'); | var height= sb.getAttribute('data-height'); | ||
- | + | ||
+ | //Set box size | ||
sb.style.width=width+"px"; | sb.style.width=width+"px"; | ||
sb.style.height=height+"px"; | sb.style.height=height+"px"; | ||
+ | //Create canvas | ||
var canv= document.createElement('canvas'); | var canv= document.createElement('canvas'); | ||
var ctx= canv.getContext("2d"); | var ctx= canv.getContext("2d"); | ||
Line 25: | Line 28: | ||
sb.appendChild(canv); | sb.appendChild(canv); | ||
+ | //Create parameter box | ||
var paramdiv= document.createElement('div'); | var paramdiv= document.createElement('div'); | ||
sb.appendChild(paramdiv); | sb.appendChild(paramdiv); | ||
- | + | ||
+ | //Load data file | ||
+ | var xmldata= null; | ||
+ | try | ||
+ | { | ||
+ | var xhr= new XMLHttpRequest(); | ||
+ | xhr.open("GET", xmlfile, false); | ||
+ | xhr.send(); | ||
+ | xmldata= xhr.responseXML; | ||
+ | } | ||
+ | catch(err) | ||
+ | { | ||
+ | sb.innerHTML='Error : ' + err.message; | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | return true; | ||
} | } | ||
+ | |||
window.addEventListener("load", page_loaded, false); | window.addEventListener("load", page_loaded, false); |
Revision as of 18:43, 2 August 2013