Template:Team:Paris Saclay/simbox

From 2013.igem.org

(Difference between revisions)
Line 30: Line 30:
  this.molecules= Array();
  this.molecules= Array();
  this.running= false;
  this.running= false;
 +
this.refresh_interval= 100;
 +
this.refresh_min_interval= 50;
 +
this.timeout= null;
}
}
Line 154: Line 157:
   simulations[simid].running= true;
   simulations[simid].running= true;
   btn.innerHTML= 'PAUSE';
   btn.innerHTML= 'PAUSE';
-
   simulations[simid].timeout= setTimeout(function() {simbox_refresh(simid);}, 100);
+
   simbox_refresh(simid);
  }
  }
  simbox_update_controls(simid);
  simbox_update_controls(simid);
Line 162: Line 165:
function simbox_resetclick(btn, simid)
function simbox_resetclick(btn, simid)
{
{
-
  //TODO STOP
+
  if(simulations[simid].running)
-
  window.clearTimeout(simulations[simid].timeout);
+
  {
-
simulations[simid].running= false;
+
  window.clearTimeout(simulations[simid].timeout);
-
document.getElementById('simbox_start_'+simid).innerHTML= 'PLAY';
+
  simulations[simid].running= false;
 +
  document.getElementById('simbox_start_'+simid).innerHTML= 'PLAY';
 +
}
   
   
  //Reset quantities, clear curves
  //Reset quantities, clear curves
Line 188: Line 193:
   }
   }
  }
  }
 +
}
 +
 +
function simbox_refresh(simid)
 +
{
 +
var time1= getTime();
 +
 +
 +
 +
var dtime= getTime() - time1;
 +
var reswait= null;
 +
if(simulations[simid].refresh_interval - dtime < simulations[simid].refresh_min_interval)
 +
  reswait= simulations[simid].refresh_min_interval;
 +
else
 +
  reswait= simulations[simid].refresh_interval - dtime;
 +
simulations[simid].timeout= setTimeout(function() {simbox_refresh(simid);}, reswait);
}
}

Revision as of 22:29, 2 August 2013