[opencms-dev] Firefox 3.5 script errors in Explorer view -- fixed version of tree.js
Christian Steinert
christian_steinert at web.de
Thu Jul 9 11:29:00 CEST 2009
Dear all, dear Achim
I have fixed various issues with the javascript code that displays the
Explorer tree, to make it work properly with Firefox 3.5.
The updated file is attached. It should work at least with Opencms 7.0.x
and 7.5.x.
You have to upload it to the folder /system/workplace/resources/commons/
of your opencms installation and then publish it.
As noted before, I won't have time to look into other Firefox 3.5
issues. If further bugs come up for tree.js, I would be willing to take
another look but if there are still problems in other areas, then it
would be great, if others could also help to fix them. Alkacon is doing
a lot, but they can't be expected to always do everything by themselves.
____________
Things that were changed (none of these changes should negatively affect
other browsers):
- The tree does not seem to hang/freeze anymore after a rewrite of
function getNodeIdByName. Before, the logic had been a bit complicated
and the conditions for terminating this functions, were in my opinion a
bit dubious before when not finding a tree node.
- All access to tree nodes (previously done directly through direct
array access in the form tree.nodes[ nodeId ]) is now handled by a new
function getNodeById.
It seems that at least part of the tree problems in Firefox was, that
tree nodes are usually using numbers as IDs but sometimes, strings that
contain numbers are used for accessing them. Maybe, Firefox 3.5 is a
little stricter in such situations, as soon as the JIT is enabled, since
the JIT will try to impose type information onto javascript variables.
The new getNodeById function will sanitize input and find tree nodes
anyway, even if the node index was passed in as a String and not a
number. All future read access of tree nodes should also be done through
this function.
- lots of cleanup:
* sanitized all checks for null/undefined - if(foo != null) was changed
to if(foo); if(foo==null) was changed to if(!foo), both of which are
much safer
* changed string concatenation so that "+" is at the end of the previous
line, which is not as nice to read, but a lot safer (javascript will
automatically insert semicolons in various situations, and therefore, it
matters a lot, where line breaks are)
* where possible, changed comparisons to use === instead of == which is
faster and safer. Note that this is not alway possible, because node ids
can sometimes be numbers and sometimes be strings
* added various missing variable declarations where they had been
forgotten (undeclared variables are implicitly global in Javascript,
which can lead to nasty bugs)
* re-ordered functions so that they are always defined before their
first caller, as advised by jslint.
* fixed all remaining jslint errors
Comments are welcome.
Kind Regards
Christian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tree.js
Type: application/javascript
Size: 23457 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20090709/e2546f90/attachment.js>
More information about the opencms-dev
mailing list