greenflame wrote:[color=blue]
> First of all I only have IE for testing.
>
> Ok. I have a script that is supposed to show, not evaluate, the
> indefinite integral of something. When I run the script it just craches
> IE. I have tried to get all the obvious bugs out... Um... The script is
> at:
http://ali.freezope.org/idf test and what it is supposed to show is
> at:
http://ali.freezope.org/idf result
>[/color]
Post URL's thusly:
<URL:
http://ali.freezope.org/idf result>
especially if you have spaces in the URL.
You should probably warn users explicitly to turn of JavaScript before
they click on the link if JavaScript is the cause of the 'crash'. The
browser doesn't crash, you send it into a never-ending loop in your
indefiniteintegral() function.
function indefiniteintegral(input,mainline,differential) {
var dummy;
var output = copy2darr(input);
dummy = output.unshift(new Array(output[0].length));
dummy = output.push(new Array(output[0].length));
Why assign some number to the variable 'dummy', then overwrite it, then
do so again below?
for (var i=0;i<output.length;i++) {
-----------------^^^^^^^^^^^^^
Here the value of output.length is evaluated every loop. This is slow
and, in this case, creates an infinite loop. Use a variable to store
the value of output.length (it will also slightly speed up your loop):
for (var i=0, len=output.length; i<len; i++) {
if (i == 0) {
dummy = output[i].unshift("<font face=symbol>ó</font>");
dummy = output[i].push(" ");
Don't use such outdated HTML - use span elements, preferably using DOM
rather than document.write. And create a class so you don't have
numerous style declarations:
dummy = output[i].unshift('<span style="font-family:symbol">'
+ 'ó</span>');
or, if using CSS and classes, have a style declaration in the head:
<style type="text/css">
.sym { font-family: symbol; }
then:
dummy = output[i].unshift('<span class="sym"> + 'ó</span>');
} else if (i == mainline) {
dummy = output[i].unshift("<font face=symbol>ô</font>");
dummy = output[i].push(differential);
} else if (i == output.length-1) {
dummy = output.unshift("<font face=cymbol>õ</font>");
--------------^^^^^^^^^
Here you are putting stuff into output and making it longer while your
for loop is trying to catch up - it never will . You also have a fault
in the depreciated font tag - I think you want 'symbol', not 'cymbol'.
dummy = output[i].unshift("<font face=cymbol>õ</font>");
dummy = output[i].push(" ");
} else {
dummy = output.unshift("<font face=symbol>ô</font>");
--------------^^^^^^^^^
And the same here.
dummy = output[i].push(" ");
}
}
return output;
}
Fixing the above mostly fixes your output, but not entirely for me.
Other comments:
* In your copy2darr() function, the line:
var output = new Array(input.length);
can be replaced with:
var output = [];
* The depreciated 'font' element at the start of your file should be
replaced with either a span, pre or code element:
<font face="courier new"> ... </font> becomes:
<pre> ... </pre>
* All of those lines with:
if (input == "del") {output = "<font face=symbol>Ñ</font>"}
can be replaced by creating the following variables at the start of the
function:
var fOn = '<font face="symbol">'
var fOf = '</font>'
then use:
if (input == "del") {output = fOn + 'Ñ' + fOf }
You really should be using span elements with CSS, but I don't know the
appropriate font-family to replace symbol - try in:
comp.infosystems.
www.authoring.stylesheets
--
Rob