On May 6, 6:01 pm, Matthias Watermann <li...@[EMAIL PROTECTED]
> wrote:
> On Tue, 06 May 2008 02:25:41 -0700, VK wrote:
> > [...]
>
> Just some hints after reading (w/o testing) it:
>
> > if ('userLanguage' in navigator) {
> > var lang = navigator.userLanguage.substring(0,2);
> > }
> > else if ('language' in navigator) {
> > var lang = navigator.language.substring(0,2);
> > }
> > else {
> > var lang = 'en';
> > }
>
> Should be:
>
> var lang = 'en';
> if ('userLanguage' in navigator) {
> lang = navigator.userLanguage.substring(0,2);
> }
> else if ('language' in navigator) {
> lang = navigator.language.substring(0,2);
> }
with pending else{} left this way. Not a crime of any kind and often
met, but we have here a standard logical construct
if X then do this
else if Y then do that
(if neither of both then)
else do default
which is
if (X) {}
else if (Y) {}
else {}
what would be benefits to break the logic flow? I am not claiming that
there are not any, but what are they?
> > TransModal.lang = (lang in TransModal.buttonLabelSet) ?
> > lang : 'en';
>
> I'd assume that "lang" is unknown here since there are only three
> vars with that name each of which inside a different "if"-scope.
Variable scope in Javascript was already explained by other posters as
I see.
> > [...]
> > var wndDialog = do***ent.createElement('DIV');
>
> > wndDialog.id = 'TransModalDialog';
>
> > /* Some complex styling of a completely empty element
> > * may make IE to act strange. To avoid that we are
> > * setting the default content to NO-BREAK SPACE
> > */
> > wndDialog.innerHTML = '<span>\u00A0</span>';
>
> Why use "innerHTML" (instead of "createElement()") here?
because then we have to add TextNode into it which is a royal pain in
IE6 - not talking about adding form controls this way which is a
headache beyond tolerance IMO with IE. Also innerHTML is 10-15 times
quicker then per-node manipulations.
This being said, I am ready to replace both innerHTML usages by a
reliable DOM alternative if anyone has it.
> > with (wndDialog.style) {
> > position = 'absolute';
> > zIndex = '1002';
> > left = '0px';
> > top = '0px';
> > cursor = 'default';
> > visibility = 'hidden';
> > }
>
> Just a matter of style & opinion:
>
> var s;
> if ((s = wndDialog.style)) {
> s.position = 'absolute';
> s.zIndex = '1002';
> s.left = '0px';
> s.top = '0px';
> s.cursor = 'default';
> s.visibility = 'hidden';
> }
Yeah... "To WITH, or not to WITH" :-)
Javascript WITH implementation is indeed a ticking bomb to handle with
extreme care. I myself once was a complete fool with it:
http://groups.google.com/group/mozilla.dev.tech.svg/msg/e3ef5a71b7d95318
So I do agree with Matt Kruse at
http://www.javascripttoolbox.com/bestpractices/#with
as overall - but I do not agree to make WITH as some self-contained
evilness that acts by its own no matter what :-) In case as above
is .style is available then all these properties should be here as
well. Or still better do not take the risk?
> > [...]


|