Open
Bug 66163
Opened 24 years ago
Updated 2 years ago
Implement generic masking for textfields
Categories
(Core :: XUL, defect)
Core
XUL
Tracking
()
NEW
mozilla1.2alpha
People
(Reporter: bugzilla, Unassigned)
References
Details
Attachments
(1 file)
7.43 KB,
patch
|
Details | Diff | Splinter Review |
Clients should be able to specify generic masks for textfields, like only
allowing letters, numbers, or alphanumeric characters. Just assigning this to
me for the work...
Reporter | ||
Comment 1•24 years ago
|
||
er...really.
Assignee: trudelle → blakeross
Target Milestone: --- → mozilla0.8
Reporter | ||
Comment 2•24 years ago
|
||
Reporter | ||
Updated•24 years ago
|
Status: NEW → ASSIGNED
Reporter | ||
Comment 3•24 years ago
|
||
cc'ing timeless/alec for r/sr
I plan on adding more masking flags later.
<property name="allows"
onset="this.setAttribute('allows', val); return val;"
onget="return this.getAttribute('allows');"/>
don't you only need onset/onget if you're doing something unusual?
var strBundleService =
Components.classes["@mozilla.org/intl/stringbundle;1"].getService()
.QueryInterface(Components.interfaces.nsIStringBundleService);
shouldn't we cache these services?
/*** Attribute "allowflags" ... *****/ outside the CDATA, is that proper?
shouldn't you use <!-- --> ?
return (alphabet.indexOf(aChar.toLowerCase()) != -1 || (aChar == " " &&
allowSpace));
please use return statement; instead of return (statement);
[asside:
javascript:alert(0==0&&0) javascript:alert(0==(0&&0)) so i guess == is
evaluated before &&]
probably:
return alphabet.indexOf(aChar.toLowerCase()) != -1 ||
(aChar == " " && allowSpace);
you use:
var allowSpace = (flags.indexOf("allow-space") != -1);
I think the outer () is unnecessary, but if brendan tells me that you should
keep it...
please follow the following indentation style [unless brendan overrules, this
disclaimer applies to everything]
switch (variable) {
case caseStatement:
statements;
case caseStatement:
statements;
default:
statements;
}
as always aim for 80 columns
I think beyond the above, it's ok asside from your concerns about it being
'really ugly'
Reporter | ||
Comment 5•24 years ago
|
||
> don't you only need onset/onget if you're doing something unusual?
I don't think so...
> var strBundleService =
> Components.classes["@mozilla.org/intl/stringbundle;1"].getService()
> .QueryInterface(Components.interfaces.nsIStringBundleService);
> shouldn't we cache these services?
They are. That's the default value for the pref, it's not re-retrieved every
time.
> /*** Attribute "allowflags" ... *****/ outside the CDATA, is that proper?
> shouldn't you use <!-- --> ?
Yes, sorry; those should be xml comments.
Comment 6•24 years ago
|
||
minor nit: if you use ....getService(Components.interfaces.nsIFoo) instead of
....getService().QueryInterface(Components.interfaces.nsIFoo) you'll avoid an
extra AddRef/Release.
major nit: It seems like we should be caching an alphabet, essentially breaking
up the task of determining the mask from the task of testing against it. This
way you could (in the future) actually prevent certain keys from ever being
entered, such that I could never even type a "b" when the mask is set to "numbers"
Reporter | ||
Comment 7•24 years ago
|
||
> This way you could (in the future) actually prevent certain keys from ever
> being entered, such that I could never even type a "b" when the mask is set to
> "numbers"
I don't understand this; how does this differ from how it is now?
Comment 8•24 years ago
|
||
oh man!
I didn't read the code closely enough
this is a huge performance suck.
you're doing a lot of work every time the user hits a key...
My comments above still apply, except that you ARE doing the work every time the
user hits a key. Find me on IRC, I'll explain
Reporter | ||
Comment 9•24 years ago
|
||
Yeah, it's silly to keep retrieving the flags/string each time the user types
(although keep in mind we only do all this work when there's a mask). I'll
attach a new patch when I get home, I'm in class.
Comment 10•24 years ago
|
||
blake: use RegExps, that's what they're for (for example, a regexp of the form
[a-z0-9] compiles into a bitmap for constant-time compiled-C-code character in
set membership tests).
Also,
+ catch(ex) {
+ null;
+ }
will get you a strict "useless expression" warning now. Why null;?
/be
Comment 11•24 years ago
|
||
I do not see a need for this feature to be built right into all textfields.
Could you explain your motivations here?
Comment 12•24 years ago
|
||
I especially don't like the additional raw property "stringBundle". Every
textfield gets more bloated with the addition of raw properties. Getters and
setters can be shared among all textfields, but raw properties cannot. Why
wouldn't that property also be a getter/setter?
I would prefer that this capability not be built into the baseline text field.
You could (if people are demanding this functionality) always put it into a
derived binding (e.g., textfield mask="true") with binding applied using
textfield[mask="true"]).
Component: XP Toolkit/Widgets → ActiveX Wrapper
Reporter | ||
Comment 13•24 years ago
|
||
We currently have many textfields that require only numbers or letters (e.g. in
prefs alone: dpi, global history expiration, number of session history entries,
maximum number of recent composer pages, number of characters to wrap plain
text messages at, number of addressbook cards, cache, and so forth), but each
has their own way of handling this, and their own inconsistent
implementations. Someone suggested this as an easy and convenient way of doing
this generically in another bug.
The derived binding sounds fine.
Comment 14•24 years ago
|
||
One idea jag had (he was leaning over my shoulder here) was that the mask attr
actually specify a mask... e.g.,
<textfield mask="[a-zA-Z]"/>
Regular expressions would be the way to go with the mask, as brendan said. For
example the above mask would allow you to input only alphabetic chars.
Comment 15•24 years ago
|
||
[Even though Hyatt is the toolkit god, I don't think he really believes this is
an ActiveX wrapper bug. Back to -->Toolkit/Widgets.]
Component: ActiveX Wrapper → XP Toolkit/Widgets
Comment 16•24 years ago
|
||
(bugzilla glitched up as he submitted his post and thought he wanted to change
product, he had to reset back to browser which I think selected ActiveX)
Reporter | ||
Updated•24 years ago
|
Target Milestone: mozilla0.8 → mozilla0.9
Comment 17•24 years ago
|
||
blake: you still interested in working on this? i'd kind of like to take a crack
at it if you're not :)
Reporter | ||
Updated•24 years ago
|
Target Milestone: mozilla0.9 → mozilla0.9.2
Reporter | ||
Updated•24 years ago
|
Target Milestone: mozilla0.9.2 → mozilla0.9.3
Reporter | ||
Updated•24 years ago
|
Target Milestone: mozilla0.9.3 → mozilla1.0
Reporter | ||
Updated•23 years ago
|
Target Milestone: mozilla1.0 → mozilla1.2
Comment 18•20 years ago
|
||
I've been thinking about writing a javascript library that would do validation
for network data structures (IPv4, IPv6 addresses, DNS, port numbers, netmasks, etc.
It would be an extension/re-write of the PAC util functions.
Updated•18 years ago
|
Assignee: bross2 → jag
Status: ASSIGNED → NEW
QA Contact: jrgmorrison → xptoolkit.widgets
Updated•16 years ago
|
Assignee: jag → nobody
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•