initialize
<script>
//compile("coffee");
//source = document.getElementById("coffee").innerText;
//JS = CoffeeScript.compile(source);
//alert(JS);
//eval(JS);
//cube = window.cube;
//alert(window.JS);
function setfv() {
f=document.getElementById('fv').value;
}
a = 2.5;
xmode = 0;
thestroke = "blue";
compile("coffee");
cube = window.cube;
square = window.square;
function toggle() {
if (xmode == 1) { thestroke = "blue"; xmode = 0; }
else { thestroke = "red"; xmode = 1; }
// alert("update");
update();
}
function xstroke() { return thestroke; }
function update () {
f=document.getElementById('fv').value;
p = []
with (Math)
for (var x = -a; x < a+.1; x += .1)
// p[p.length] = [x, x-x*x*x]
//p[p.length] = [x, eval(f)]
p[p.length] = [x, cube(x)]
stroke = xstroke()
//path(p,"func")
//stroke = "blue"
plot(f,-a,a)
setText(f,"fval")
setText(a.toFixed(2),"aval")
setText((-a).toFixed(2),"maval")
}
</script>
<h5>
y=<span id="fval">f</span>
<input type="text" id="fv" name="fname" value="cube(x)" onblur="toggle()" />
for <span id="maval">a <=x<= a</span>
<input type="button" value="-" onclick="a-=.25;update()"/>
<input type="button" value="+" onclick="a+=.25;update()"/>
</h5>
</center>
</body>
