Team:Groningen/Modelling/model/calc.js
From 2009.igem.org
(Difference between revisions)
Line 42: | Line 42: | ||
.replace(/e\+([0-9]+)$/i,'·10<sup>$1</sup>') | .replace(/e\+([0-9]+)$/i,'·10<sup>$1</sup>') | ||
.replace(/e\-([0-9]+)$/i,'·10<sup>-$1</sup>'); | .replace(/e\-([0-9]+)$/i,'·10<sup>-$1</sup>'); | ||
+ | } | ||
+ | |||
+ | // Annelies | ||
+ | |||
+ | |||
+ | var wooYayIntervalId = 0; | ||
+ | |||
+ | function wooYayClickHandler ( ) | ||
+ | { | ||
+ | if ( document.getElementById("wooYayButton").value == "Click me!" ) | ||
+ | { | ||
+ | // Start the timer | ||
+ | document.getElementById("wooYayButton").value = "Enough already!"; | ||
+ | wooYayIntervalId = setInterval ( "wooYay()", 1000 ); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | document.getElementById("wooYayMessage").innerHTML = ""; | ||
+ | document.getElementById("wooYayButton").value = "Click me!"; | ||
+ | clearInterval ( wooYayIntervalId ); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function wooYay ( ) | ||
+ | { | ||
+ | if ( Math.random ( ) > .5 ) | ||
+ | { | ||
+ | document.getElementById("wooYayMessage").innerHTML = "Woo!"; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | document.getElementById("wooYayMessage").innerHTML = "Yay!"; | ||
+ | } | ||
+ | |||
+ | setTimeout ( 'document.getElementById("wooYayMessage").innerHTML = ""', 500 ); | ||
+ | |||
} | } |
Revision as of 08:39, 25 August 2009
function calc(){
// gets input var growthFactorNode = document.getElementById("growthFactor");
// reads input var growthFactor = Number(growthFactorNode.value); // begin variable var time = 0; var x = 0; var y = 0; arrValueX = new Array(); arrValueY = new Array();
// process var growthFactor = growthFactor + 1; for (var time = 0; time < 30; time++) { var y = growthFactor*x*x; var x = x + 1; arrValueX.push(x); arrValueY.push(y); }
// Set outputs setOutput(growthFactorAnswer, growthFactor ); document.getElementById('growthFactorGraph').refresh();
}
function setOutput(node,v) {
node.innerHTML = formatNumberToHTML(v); node.value = v;
}
function formatNumberToHTML(v,p) {
if (p===undefined) p = 5; return v.toPrecision(p) .replace(/e\+([0-9]+)$/i,'·10$1') .replace(/e\-([0-9]+)$/i,'·10-$1');
}
// Annelies
var wooYayIntervalId = 0;
function wooYayClickHandler ( ) {
if ( document.getElementById("wooYayButton").value == "Click me!" ) { // Start the timer document.getElementById("wooYayButton").value = "Enough already!"; wooYayIntervalId = setInterval ( "wooYay()", 1000 ); } else { document.getElementById("wooYayMessage").innerHTML = ""; document.getElementById("wooYayButton").value = "Click me!"; clearInterval ( wooYayIntervalId ); }
}
function wooYay ( ) {
if ( Math.random ( ) > .5 ) { document.getElementById("wooYayMessage").innerHTML = "Woo!"; } else { document.getElementById("wooYayMessage").innerHTML = "Yay!"; }
setTimeout ( 'document.getElementById("wooYayMessage").innerHTML = ""', 500 );
}