jshanman said on 25/04/2006 10:46 PM AEST:
You mean to tell me all the experts in this group found absolutly no
problems in my code!
No one has told you anything, you should not presume that no response
means there is nothing to respond about (noting that Thomas has
subsequently replied with some tips).
I looked briefly at your code - it is very inefficient, unnecessarily
complicated and lacks comments. No documentation is provided about what
it is supposed to do or how it is supposed to do it. For example, you
have arrays of month names and day numbers that don't appear on the
page. Is that an error or isn't that functionality implemented yet?
There are efficient ways of determining the number of days in the month
and adding the ordinal suffix (st, nd, rd, and so on) without creating
literal arrays with all of the values in them.
I don't have the time to wade through the code to find the answer or
provide useful assistance. These issues are obvious and hint that there
are many, many more.
e.g. (my wrapping)
this.labels.style.left =
String(
-1*this.GetPos(
DtObj.getFullYear(),
DtObj.getMonth(),
DtObj.getDate(),
DtObj.getHours()
) + 400
) + "px"
Seems silly, why not pass the date object to the function and have it
return the value? Why explicitly convert the returned value to a
number, then convert it back to a string? Appending 'px' to a number
will convert the value to a string without using a String object, so:
this.labels.style.left = '-' + (GetPos(DtObj) + 400) + 'px';
would be far simpler. Then the getPos() function can do its thing with
the date parts as required. Incidentally, getPos() seems far more
complex than it needs to be, for example:
with (D = new Date(0)) {
setFullYear(year, month, day);
setHours(hour);
}
Why not:
var D = new Date(year, month, day, hours);
Which just creates a copy of the date object above - DtObj. Since D
(which isn't declared anywhere and so is global) isn't modified, why not
just pass a reference to DtObj and use that directly?
As a general hint, if you ask a specific, clearly presented problem you
will usually get timely and worthwhile assistance - posting a page that
very likely has many basic design flaws (given that no design is
provided) and poor coding practices will likely deter everyone from
offering any help at all.
[...]