Require robust autocomplete field

T

Thomas 'PointedEars' Lahn

VK said:
Thomas said:
VK said:
Thomas 'PointedEars' Lahn wrote:
VK wrote:
It is not completely correct. Not every HTML encoded entity
"trash out" the input but only < > & and   and
only if one treats the input string as HTML code (using
.innerHTML) [...]

Rubbish.
Do you have a counterexample?
Do you have an example that proves it?

?? The test is in my first post. Can you see it?

Do you mean that *invalid* *markup*?

Really? What HTML validator are you using? I am still on W3C one.

http://validator.w3.org/#validate_by_input
[past my HTML sample]
[press Check]
"This document was successfully checked as HTML5!"

And now you should look at what the relevant `select' element says.
"HTML 5" is not even a Proposed Recommendation yet, let alone a Web
standard.
It is irrelevant though to the issue. If you like HTML 4.01 or XHTML
better, simply insert the code from BODY to your own preferred test
page.

And test it where?


PointedEars
 
V

VK

Do you mean that *invalid* *markup*?
Really? What HTML validator are you using? I am still on W3C one.
http://validator.w3.org/#validate_by_input
 [past my HTML sample]
 [press Check]
"This document was successfully checked as HTML5!"

And now you should look at what the relevant `select' element says.
"HTML 5" is not even a Proposed Recommendation yet, let alone a Web
standard.

It is a valid markup by W3C Validator, period. Any "spiritually
conforming" validations based on a particular opinion of a group
memeber are completely out of any public interest. Yet again, if you
are interested in historical curiosities and artifacts, no one
prohibit you to use valid XHTML, HTML3 or HTML4.x in your own
projects. Just do not mix your personal preferences with the public
demand ;-)
And test it where?

If you don't know how and where to test a code snippet posted in this
newsgroup then what are you doing here?
 
V

VK

It is very poor design to deliberately break functionality in browsers
that *you* don't care about when a funcionally equivalent alternative
is available that will work in nearly all browsers that support a
scriptable DOM.

The most poor design IMHO is to make some "abstractly robust" code and
claim it universally robust because it corresponds to such and such
programming principles. Well, it is an evangelistic matter with Mb of
posting made here over years, with Matt Kruse vainly trying to bring
some practical sense into the orthodoxy. I don't feel like taking his
place. I will never change the opinion of say Richard, he will never
change mine.
Perhaps you should join the jQuery development team, that seems to be
their list of browsers too.

And the EU as well :) :
http://europa.eu/rapid/pressReleasesAction.do?reference=MEMO/09/439&format=HTML
http://arstechnica.com/microsoft/ne...s-will-also-get-to-vote-ie-off-the-island.ars

- not talking about my US customers were say Opera being supported on
my own time expenses were possible because no one will give you a damn
penny extra to support an absolutely unknown browser.

Again: a browser is a commercial product, and the Web market is not
some sweet garden for badly made software or for market-impotent
company managers. One wants to be noticed by developers? Then get at
least 0.5% of usage share in recognized usage stats companies.

Cannot get 0.5% in years? Die, sucker, die and free the space for new
rivals.

"recognized usage stats companies are not counting right", "we have
other usage stats companies that are counting right", blah-blah-blah -
die, sucker, and die as a man, the crying corner is not here.

:)
:-|
 
T

Thomas 'PointedEars' Lahn

VK said:
Do you mean that *invalid* *markup*?
Really? What HTML validator are you using? I am still on W3C one.
http://validator.w3.org/#validate_by_input
[past my HTML sample]
[press Check]
"This document was successfully checked as HTML5!"

And now you should look at what the relevant `select' element says.
"HTML 5" is not even a Proposed Recommendation yet, let alone a Web
standard.

It is a valid markup by W3C Validator, period.

No so. The validators at w3.org are known to provide validation of features
that are not even implemented. In particular, W3C HTML 5 is clearly marked
a Working Draft, and the Validator's `select' element labels its validation
"(experimental)".

If you have any doubts what "Working Draft" means with regard to W3C
Technical Reports, read the HTML 5 Working Draft's "Status of this
document" section.
If you don't know how and where to test a code snippet posted in this
newsgroup then what are you doing here?

Red herring. You are the one claiming your code displays a certain behavior
in one or more runtime environments; you are the person who needs to tell
where exactly it displays that behavior, so that your observations can be
double-checked, and other environments than that which you tested can be
checked for the problem to see how grave a problem it is. Extraordinary
claims require extraordinary evidence, or they may be easily be written off
as nonsense (and, let's face it, which you are known to submit).

<http://www.catb.org/~esr/faqs/smart-questions.html#id382249>

I will not reply next time unless you have learned to pay proper attribution
to those who you quoted.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Garrett said:
Can be much better with a simple property:

var TEXT_CONTENT = typeof documentElement.textContent === "string" ?
"textContent" : "innerText";

That makes the assumption that if one object supports the `textContent'
property all other objects must also support it, and that if one object does
not support the `textContent' property no other object supports it. That is
hardly "better" in any sense of the word.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Garrett said:
Can be much better with a simple property:

var TEXT_CONTENT = typeof documentElement.textContent === "string" ?
"textContent" : "innerText";

That is based on the jump to the conclusion that if an object referred to by
`documentElement' supports the `textContent' property all other objects must
also support it, and that if this object does not support the `textContent'
property it and other objects must support the `innerText' property. That
is hardly "better" than the above in any sense of the word.


PointedEars
 
R

RobG

The most poor design IMHO is to make some "abstractly robust" code and
claim it universally robust because it corresponds to such and such
programming principles.

Your criterion for "most poor design" (as bizarre and poorly stated as
it is) is not the issue. The point is that in an environment of a wide
variety of browsers you shouldn't go out of your way to write crap
code that is guaranteed to break in a good proportion of them.
Well, it is an evangelistic matter with Mb of
posting made here over years, with Matt Kruse vainly trying to bring
some practical sense into the orthodoxy. I don't feel like taking his
place.

Irrelevant crap. You will never be considered a Matt Kruse surrogate -
he at least has a clue about how to write javascript.

I will never change the opinion of say Richard, he will never
change mine.

I think that rates as name dropping. I will never change Barack
Obama's opinion on anything - does that make me sound important?


If you think either of those articles offers any kind of endorsement
by the EU for your choice of supported browsers then your level of
English comprehension is approaching zero. From the second article:

"Upon closer inspection, Microsoft's browser ballot proposal for the
EU is much more drastic than one would expect. Users will choose from
up to 10 different browsers. And it won't be limited to Windows 7
users; the ballot screen will be pushed as an update to current
Windows XP and Windows Vista users. PC manufacturers will also have
the option of shipping one or more third-party browsers in place of
IE8."

The articles are about *Microsoft's* proposed system for letting users
chose a browser, they do not in any way establish a set of preferred
browsers. I imagine that the ones in the article are there purely as
examples, they are not a definitive collection. Secondly, OEMs can put
whatever browsers they want into the ballot system so users will have
a much greater choice of browser then the minimal list you proposed.
The articles are evidence *against* your proposal to support only a
limited group of browsers.

- not talking about my US customers were say Opera being supported on
my own time expenses were possible because no one will give you a damn
penny extra to support an absolutely unknown browser.

More irrelevant drivel. You clearly don't understand the issue so I'm
not going to repeat it yet again.

Again: a browser is a commercial product, and the Web market is not
some sweet garden for badly made software

Then stop post badly written code.

or for market-impotent
company managers. One wants to be noticed by developers? Then get at
least 0.5% of usage share in recognized usage stats companies.

Cannot get 0.5% in years? Die, sucker, die and free the space for new
rivals.

So where are your tests for Mobile Safari? Opera on game consoles?
Blackberry? Your advice is not worth the paper it's printed on.

"recognized usage stats companies are not counting right", "we have
other usage stats companies that are counting right", blah-blah-blah -
die, sucker, and die as a man, the crying corner is not here.


Perhaps you should take your own advice.
 
V

VK

code that is guaranteed to break in a good proportion of them.

Here it comes again... OK, just as a creative writing exercise, let's
give it another shoot to the sky.

1) Please define "a good proportion of browsers" in an approximate
numeric percentage value.

2) Please define an approximate numeric percentage value of browsers
where such code as

/*@cc_on
/*@if (@_jscript)
var IE = true;
@else @*/
var IE = false;
/*@end
@*/
this.form.elements['txt'].value = (IE)?
document.getElementById('Sample').innerText
:
document.getElementById('Sample').textContent;

will lead to an error. Please name that UA and its version.

[...]
So where are your tests for Mobile Safari? Opera on game consoles?
Blackberry?

? Obviously in the relevant UA in the relevant device, where else? I
actually like these as it gives me 20% price increase per mobile
environment.
 
D

David Mark

code that is guaranteed to break in a good proportion of them.

Here it comes again... OK, just as a creative writing exercise, let's
give it another shoot to the sky.

1) Please define "a good proportion of browsers" in an approximate
numeric percentage value.

2) Please define an approximate numeric percentage value of browsers
where such code as

/*@cc_on
   /*@if (@_jscript)
      var IE = true;
   @else @*/
      var IE = false;
   /*@end
@*/
this.form.elements['txt'].value = (IE)?
 document.getElementById('Sample').innerText
 :
 document.getElementById('Sample').textContent;

will lead to an error. Please name that UA and its version.

We're trying to have a civilization here, VK.
[...]
So where are your tests for Mobile Safari? Opera on game consoles?
Blackberry?

? Obviously in the relevant UA in the relevant device, where else? I
actually like these as it gives me 20% price increase per mobile
environment.

Do you mind?
 
V

VK

Here it comes again... OK, just as a creative writing exercise, let's
give it another shoot to the sky.
1) Please define "a good proportion of browsers" in an approximate
numeric percentage value.
2) Please define an approximate numeric percentage value of browsers
where such code as
/*@cc_on
   /*@if (@_jscript)
      var IE = true;
   @else @*/
      var IE = false;
   /*@end
@*/
this.form.elements['txt'].value = (IE)?
 document.getElementById('Sample').innerText
 :
 document.getElementById('Sample').textContent;
will lead to an error. Please name that UA and its version.

We're trying to have a civilization here, VK.

UA? version? usage stats per markets?

I am not interested in the abstract wording, clj is already sinking in
it, if not already sunk.
Do you mind?

See above.
 
R

RobG

Here it comes again... OK, just as a creative writing exercise, let's
give it another shoot to the sky.

It seems you've completely missed the point of my OP.

1) Please define "a good proportion of browsers" in an approximate
numeric percentage value.

The code you originally posted will fail in any browser that is not IE
and doesn't support textContent. There are plenty of those, such as
Safari 2.

2) Please define an approximate numeric percentage value of browsers
where such code as

/*@cc_on
   /*@if (@_jscript)
      var IE = true;
   @else @*/
      var IE = false;
   /*@end
@*/
this.form.elements['txt'].value = (IE)?
 document.getElementById('Sample').innerText
 :
 document.getElementById('Sample').textContent;

will lead to an error. Please name that UA and its version.

That is only half the issue. The problem is that having split browsers
into two categories - IE and others - the code in your OP assumes that
all non-IE browsers support the textContent property. That is a
demonstrably false assumption. The alternative is a feature test that
looks at support for textContent and innerText directly, clearly a
better strategy.

You are trying to push browser sniffing in a forum that wrote it off
as a flawed strategy many years ago.
[...]
So where are your tests for Mobile Safari? Opera on game consoles?
Blackberry?

? Obviously in the relevant UA in the relevant device, where else? I
actually like these as it gives me 20% price increase per mobile
environment.

So that's your angle. Instead of writing robust code, you'd write
stuff that will break outside your supported list, then charge an
exorbitant fee to support some other browser.
 
V

VK

RobG said:
It seems you've completely missed the point of my OP.

OK, I am ready to follow it over again.
The code you originally posted will fail in any browser that is not IE
and doesn't support textContent. There are plenty of those, such as
Safari 2.

This is a false statement (I mean "plenty of those") and you know it.
The current amount of Safari 2.x users is equal to the current amount
of Netscape 4.x users thus so negligible that is not reflected by any
known market share stats service, so >0.01%
At the same time the current amount of IE6 users is bigger than the
amount of users of all versions of FF together (24%-25% per region).
The secret of this phenomenon is in the "netbook explosion" on the
market with Windows XP SP2 + IE6 preinstalled.
This is the old lasting silliness of clj we're going to say bye-bye:
create most stupid imaginary compatibility problems yet disregard some
most practical ones as soon as "pure feature detection" cannot handle
them.
Of course any stats numbers never prove anything to some clj regulars
as unreliable, easily spoofed, blah-blah-blah etc. but for other
readers some sample stats:
http://marketshare.hitslink.com/browser-market-share.aspx?qprid=0
http://marketshare.hitslink.com/browser-market-share.aspx?qprid=2
Used methodology:
http://marketshare.hitslink.com/
You are trying to push browser sniffing in a forum that wrote it off
as a flawed strategy many years ago.

It is a false statement as well. What was rightly wrote off is the
code branching based purely on User-Agent string examination. The rest
is a hoax just like "DIV layout", "semantical Web", XHTML and many
other things to forget and to move on. IMHO it is also a long lasting
hypocrisy when

/*@cc_on
/*@if (@_jscript)
var IE = true;
@else @*/
var IE = false;
/*@end
@*/

is really bad because we dare to name the browser we are detecting
while

if (window.ActiveXObject) { ... }

is good because we like not naming anything, just "any browser with
this feature"...
So that's your angle. Instead of writing robust code, you'd write
stuff that will break outside your supported list, then charge an
exorbitant fee to support some other browser.

No, and it is clear if you follow the modern Web trends. I am writing
code that tested to work for 99.9% of current environments - that
automatically includes the legacy systems holding up to 0.1% of the
market share.
If my customer needs to support an environment with 0.09%-0.01% of
market shares than it is obviously an individual custom adjustment for
an extra pay. It is natural to understand to both the vendor and the
customer. To make it clearer, a standard furniture set may cost you
$1000 but the same set separately made for your room dimensions and
shape may cost you as much as $5,000
 
T

Thomas 'PointedEars' Lahn

RobG said:
The code you originally posted will fail in any browser that is not IE

s/is not IE/does not support JScript's conditional compilation feature/
and doesn't support textContent. There are plenty of those, such as
Safari 2.


PointedEars
 
D

David Mark

OK, I am ready to follow it over again.


This is a false statement (I mean "plenty of those") and you know it.

No, Safari 2 is just an example.
The current amount of Safari 2.x users is equal to the current amount
of Netscape 4.x users thus so negligible that is not reflected by any
known market share stats service, so >0.01%

That's pure nonsense.
At the same time the current amount of IE6 users is bigger than the
amount of users of all versions of FF together (24%-25% per region).
The secret of this phenomenon is in the "netbook explosion" on the
market with Windows XP SP2 + IE6 preinstalled.

Who cares if IE6 outnumbers Safari 2?
This is the old lasting silliness of clj we're going to say bye-bye:
create most stupid imaginary compatibility problems yet disregard some
most practical ones as soon as "pure feature detection" cannot handle
them.

Like what? At least three people have told you how to detect the
proper property, in this very thread...
Of course any stats numbers never prove anything to some clj regulars
as unreliable, easily spoofed, blah-blah-blah etc. but for other
readers some sample stats:
 http://marketshare.hitslink.com/browser-market-share.aspx?qprid=0
 http://marketshare.hitslink.com/browser-market-share.aspx?qprid=2
Used methodology:
 http://marketshare.hitslink.com/

Worthless and irrelevant to your "argument". You've been shown how to
write the function to work in virtually anything (and without
resorting to conditional compilation).
It is a false statement as well. What was rightly wrote off is the
code branching based purely on User-Agent string examination.

Good riddance to that (ten years later).
The rest
is a hoax just like "DIV layout", "semantical Web", XHTML and many
other things to forget and to move on. IMHO it is also a long lasting
hypocrisy when

Who is perpetuating these "hoaxes?" For one, nobody in here
recommends XHTML. There's really no such thing as a "DIV layout" and
if there were, it wouldn't be discussed in this group. Semantic
markup is not a hoax, nor is it discussed in this JS group.
/*@cc_on
/*@if (@_jscript)
   var IE = true;
  @else @*/
   var IE = false;
/*@end
@*/

is really bad because we dare to name the browser we are detecting
while

It's really bad because there is a much simpler (and far more
effective) alternative. It's been posted in this very thread.
if (window.ActiveXObject) { ... }

is good because we like not naming anything, just "any browser with
this feature"...

No, if you read this group regularly, you'd know that's awful as well
(in general and especially for this case).
No, and it is clear if you follow the modern Web trends. I am writing
code that tested to work for 99.9% of current environments - that
automatically includes the legacy systems holding up to 0.1% of the
market share.

Who conducted that study?
If my customer needs to support an environment with 0.09%-0.01% of
market shares than it is obviously an individual custom adjustment for
an extra pay. It is natural to understand to both the vendor and the
customer. To make it clearer, a standard furniture set may cost you
$1000 but the same set separately made for your room dimensions and
shape may cost you as much as $5,000

What you don't seem to grasp is that hacks, object inferences, browser
sniffs, etc. don't keep. Your clients will have to call VK in the
near future to twiddle with them. Oh, as noted, perhaps that is your
strategy.
 
V

VK

David said:
No, Safari 2 is just an example.

I am still open for another more reasonable (>= 0.1% market share is a
must)
That's pure nonsense.

It is a proven fact. Though anyone is entitle to believe that there is
a world-wide conspiracy against comp.lang.javascript supported and
financed by all major statistical agencies across the globe.
Who cares if IE6 outnumbers Safari 2?

the customers
Like what?  At least three people have told you how to detect the
proper property, in this very thread...



Worthless and irrelevant to your "argument".
You've been shown how to
write the function to work in virtually anything (and without
resorting to conditional compilation).

I am using the bulletproof methods, others may use almost bulletproof
or easily spoofed but "ideologically proper" but I don't have this
luxury.
Good riddance to that (ten years later).

? Did I ever insisted in this group to use User-Agent string and only
it? Back in 1998 it was document.layers vs. document.all in my script.
The other question is that the right idea (detect particular UAs by
feature tests and not by navigator.userAgent) was brought in clj into
some crazy dogmatic overstatement. All this is IMHO.

[...] (nothing new)
Who conducted that study?

The members of the world-wide anti-c.l.j. conspiracy plot ;) , link to
one of them was provided
What you don't seem to grasp is that hacks, object inferences, browser
sniffs, etc. don't keep.  Your clients will have to call VK in the
near future to twiddle with them.  Oh, as noted, perhaps that is your
strategy.

My NN4+IE4,5 pop-up calendar written at summer 1998 still perfectly
working. Unfortunately I cannot provide the download link as my
anonymity at c.l.j. is part of my comfort. So you are free to decide
that I'm boasting.
 
D

David Mark

[snip]
My NN4+IE4,5 pop-up calendar written at summer 1998 still perfectly
working. Unfortunately I cannot provide the download link as my
anonymity at c.l.j. is part of my comfort. So you are free to decide
that I'm boasting.

Long-since decided. Thanks! :)
 
G

Garrett Smith

Thomas said:
That makes the assumption that if one object supports the `textContent'
property all other objects must also support it, and that if one object does
not support the `textContent' property no other object supports it. That is
hardly "better" in any sense of the word.

It will work in Safari2, so that is better.

But certainly not better for Blackberry9000 (which supports neither).
 
G

Garrett Smith

Thomas said:
That is based on the jump to the conclusion that if an object referred to by
`documentElement' supports the `textContent' property all other objects must
also support it, and that if this object does not support the `textContent'
property it and other objects must support the `innerText' property. That
is hardly "better" than the above in any sense of the word.

I find that a fair inference to make that if one HTMLElement has a
"textContent" property, then most others will, too

An implementation that has neither innerText nor textContent poses a
problem.

That's Blackberry9000. Blackberry9000 has innerHTML and Text node, so
another approach using those can work.

But this has gotten spectacularly off-track.
 
G

Garrett Smith

Mark said:
Hi,

I'm looking for a way to implement an autocomplete field on some of my
forms.

I need both ajax support (for larger lists) and also a way to pass in
json arrays for smaller lists.

The best I have found so far is this one:

http://www.pengoworks.com/workshop/jquery/autocomplete.htm

(I know, jQuery - yuck!)

Line 3:
var $input = $(input).attr("autocomplete", "off");

Where:
input.autocomplete = "off";

I know, boring. No dollar signs or chaining, but certainly much simpler.
The problem with this one (and others) is that the rendering breaks
when any of the strings contain html entity encoded characters. This
is because the dropdown list is html, but the text box value is raw
text. Fixing the code myself to reconcile the two looks like it will
become very messy.

Help my understanding of that problem a bit:
Is the user typing "&amp;" and the list has &?

That can't be; I must have misunderstood.
If anyone could recommend a way to do this properly. (Either a plugin
for an existing framework or a tried and tested pattern for
implementing autocomplete in pure JS would be greatly appreciated)

Working out the details of the U/X is probably harder.
 
M

Mark Smith

Line 3:
var $input = $(input).attr("autocomplete", "off");

Where:
input.autocomplete = "off";

I know, boring. No dollar signs or chaining, but certainly much simpler.


Help my understanding of that problem a bit:
Is the user typing "&amp;" and the list has &?

That can't be; I must have misunderstood.

Thanks for getting back OT.

The list contains an item such as "'O'Neill &amp; Son'" (In order
to appear correctly in the rendered dropdown).

When selected and placed in the text box, it should appear as "O'Neill
& Son', however it doesn't all the ugly encoding is displayed to the
user.

Hacking it to decode makes jquery think the input is invalid, as the
selection must appear in the original list...

The way I see it there are 3 options:

1: Hack the jquery library to make the comparison callbacks to
decode / encode between the 2 formats on the fly. (Not sure if it's
possible to do reliably and with tidy code. The whole point of using a
library was to avoid this kind of minefield.)

2: Hack the jquery library to use 2 lists, "HTML" and "TEXT"
formatted. (Same problems as option 1)

3: Ditch the library and do it manually... Hence this post. Any
examples out there of this problem being solved right? It seems like a
common problem, yet the only examples out there use half baked
libraries that only kind of work some of the time.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top