Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #13883
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="ISO-8859-1" |
| Message-ID | <2943028.PjCfEcWMYn@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Sat, 12 May 2012 15:02:40 +0200 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 7Bit |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: Modify Element Tag Question |
| Newsgroups | comp.lang.javascript |
| References | <a158cjFt46U1@mid.individual.net> <4fae34c6$0$9503$9b4e6d93@newsspool1.arcor-online.net> |
| Followup-To | comp.lang.javascript |
| MIME-Version | 1.0 |
| Lines | 87 |
| NNTP-Posting-Date | 12 May 2012 15:02:42 CEST |
| NNTP-Posting-Host | 385ceac3.newsspool1.arcor-online.net |
| X-Trace | DXC=<F9mk[U5f@TE47KDAk81NWic==]BZ:af^4Fo<]lROoRQnkgeX?EC@@PIRTKiQcV`1TDZm8W4\YJN\J`:FmdeL>KPU@3`]Ai;BfR=K_:[S?JcZ] |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:13883 |
Followups directed to: comp.lang.javascript
Show key headers only | View raw
Martin Honnen wrote:
> Mel Smith wrote:
>> In my phone book (of 613 multi-line entries in a table), I am
>> currently
>> 'bolding' the names of the people, and leaving other fields 'unbolded'.
>>
>> Now, when a user decides to change the sorting order to street
>> address,
>> I wish to 'unbold' the names, and bold the street addresses.
>>
>> So, is there a 'placeholder' HTML Element Tag that I can use for all
>> sortable fields (and later search for) so that the text is displayed
>> correctly but *unbolded*.
>
> Define a class with CSS e.g.
> td.sorted { font-weight: bold; }
> then make sure you manipulate the className for the cells you want to
> change e.g.
> function changeSortStyle(table, unsortedIndex, sortedIndex) {
> for (var i = 0, l = table.rows.length; i < l; i++) {
> table.rows[i].cells[unsortedIndex].className = '';
> table.rows[i].cells[sortedIndex].className = 'sorted';
> }
> }
However, it is a lot more efficient to give each column (or element, in
general) a class corresponding to its content in advance, and just change
the corresponding style rule.
Finding that rule only has to be done once and is most beautifully done in
conforming implementations of ECMAScript, 5.1 Edition (or emulations
thereof):
/* See also <http://PointedEars.de/scripts/dom/css.js> */
var findRules = (function () {
var _slice = Array.prototype.slice;
var a = [];
var _concat = Array.prototype.concat;
function toArray (obj)
{
return _slice.call(obj || a);
}
return function (selector, exactMatch) {
var prefix = "(^|\\s)";
if (exactMatch)
{
prefix = "^\\s*";
}
var rxSelector = new RegExp(
prefix + selector.replace(/[$.(){}\[\]^]/g, "\\$&") + "\\s*$");
var hits = toArray(document.styleSheets).map(
function (styleSheet) {
return toArray(styleSheet.cssRules || styleSheet.rules).filter(
function (rule) {
return rxSelector.test(rule.selectorText);
});
}).filter(function (hit) {
return hit.length > 0;
});
return _concat.apply([], hits);
};
}());
var rulesets = Object.create(null);
if (!rulesets["people"])
{
rulesets["people"] = findRules(".people", true);
}
var rules = rulesets["people"];
if (rules.length > 0)
{
rules[rules.length - 1].style.fontWeight = "normal";
}
PointedEars
--
When all you know is jQuery, every problem looks $(olvable).
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-11 13:42 -0600
Re: Modify Element Tag Question Martin Honnen <mahotrash@yahoo.de> - 2012-05-12 12:00 +0200
Re: Modify Element Tag Question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-12 15:02 +0200
Re: Modify Element Tag Question John G Harris <john@nospam.demon.co.uk> - 2012-05-12 16:15 +0100
Re: Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-12 14:32 -0600
Re: Modify Element Tag Question Dr J R Stockton <reply1219@merlyn.demon.co.uk.not.invalid> - 2012-05-12 19:29 +0100
Re: Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-12 18:08 -0600
Re: Modify Element Tag Question "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-13 08:11 +0000
Re: Modify Element Tag Question Martin Honnen <mahotrash@yahoo.de> - 2012-05-13 11:25 +0200
Re: Modify Element Tag Question Dr J R Stockton <reply1220@merlyn.demon.co.uk.not.invalid> - 2012-05-14 20:19 +0100
Re: Modify Element Tag Question Denis McMahon <denismfmcmahon@gmail.com> - 2012-05-13 02:59 +0000
Re: Modify Element Tag Question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-13 15:50 +0200
Re: Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-13 08:56 -0600
Re: Modify Element Tag Question Dr J R Stockton <reply1219@merlyn.demon.co.uk.not.invalid> - 2012-05-14 20:01 +0100
Re: Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-13 09:00 -0600
Re: Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-14 08:45 -0600
Re: Modify Element Tag Question Scott Sauyet <scott.sauyet@gmail.com> - 2012-05-14 16:31 -0700
Re: Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-15 09:03 -0600
Re: Modify Element Tag Question Dr J R Stockton <reply1220@merlyn.demon.co.uk.not.invalid> - 2012-05-15 20:04 +0100
Re: Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-15 22:19 -0600
Re: Modify Element Tag Question Dr J R Stockton <reply1220@merlyn.demon.co.uk.not.invalid> - 2012-05-17 19:13 +0100
Re: Modify Element Tag Question Scott Sauyet <scott.sauyet@gmail.com> - 2012-05-17 18:48 -0700
Re: Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-18 13:14 -0600
Re: Modify Element Tag Question Dr J R Stockton <reply1220@merlyn.demon.co.uk.not.invalid> - 2012-05-19 20:47 +0100
Re: Modify Element Tag Question "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-20 08:31 +0000
Re: Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-20 18:25 -0600
Re: Modify Element Tag Question "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-21 16:06 +0000
Re: Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-21 13:24 -0600
Re: Modify Element Tag Question "Mel Smith" <med_cutout_syntel@aol.com> - 2012-05-21 13:34 -0600
Re: Modify Element Tag Question Scott Sauyet <scott.sauyet@gmail.com> - 2012-05-21 13:09 -0700
Re: Modify Element Tag Question Dr J R Stockton <reply1221@merlyn.demon.co.uk.not.invalid> - 2012-05-21 20:33 +0100
csiph-web