[Proto-Scripty] Re: select only text (i.e. textnodes, probably) using $$
On Dec 11, 3:25 am, lskatz [EMAIL PROTECTED] wrote: I finally got around to this, and it turns out that even though the approach is good, I cannot insert HTML tags. I chose to not use recursion to make it simple. The problem is that it uses each character literally and displays the htmlentities instead of actually making html tags. Because you are modifying the text node's nodeValue attribute, not its innerHTML property so the replacement text isn't parsed as HTML. -- Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: select only text (i.e. textnodes, probably) using $$
You could check if the firstChild of the element in question is a textNode. i.e.: var c = el.firstChild; if(c.nodeType == 3){ //text node el.update(...); } Gabriel Gilini www.usosim.com.br [EMAIL PROTECTED] [EMAIL PROTECTED] On Wed, Nov 19, 2008 at 9:22 PM, lskatz [EMAIL PROTECTED] wrote: Hi, I want to automatically set up abbreviation tags everywhere in my document, and it works great, except I am altering the innerHTML to do so and sometimes some crazy results happen. For instance, an input's value should be untouched because the value should not be value=abbr title='united states of america'USA/abbr I believe the way to go would be to select for textnodes but I cannot figure out why that wouldn't work. Anyway, any help to fix my code would be appreciated (I hope the indentation is preserved when I post this). // find and add in abbr all over the place! var replacing={ 'TSV':'Tab-Separated Values', 'CSV':'Comma-Separated Values', 'STs?':'Sequence Type', 'CCs?':'Clonal Complex', 'MGIP':'Meningococcus Genome Informatics Platform', 'MLST':'Multilocus Sequence Typing', 'GIT':'Georgia Institute of Technology', 'CDC':'Centers for Disease Control and Prevention', 'OMP':'Outer Membrane Protein' }; $$('.systemMessage, .body p,.body div,label,h1,h2,h3,h4,.menu.firefox').each(function(el){ if(el.hasClassName('doNotDisturb')){ return; // equivalent to a continue inside of an each loop } el.select('text').each(function(s){ debug('textNode: '+s); }); for(var k in replacing){ var v=replacing[k]; var find=new RegExp('\\b('+k+')\\b','g'); // I should use something like innerContext or innerText instead of innerHTML el.update(el.innerHTML.replace(find,acronym title='+v+' $1/acronym,'')); } }); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: select only text (i.e. textnodes, probably) using $$
I notice you have an uppercase letter in your $$ selector. I don't know, but this could cause you some problems if you are not using Firefox. Please see the discussion called 'cross browser $$ selector problems'. You should not need to do this, but just for a test, try making all id's and class names completely lowercase and see if that helps. It is only a workaround, but if that works for you it would be evidence of a cross-browser issue in prototype. On Nov 19, 6:22 pm, lskatz [EMAIL PROTECTED] wrote: Hi, I want to automatically set up abbreviation tags everywhere in my document, and it works great, except I am altering the innerHTML to do so and sometimes some crazy results happen. For instance, an input's value should be untouched because the value should not be value=abbr title='united states of america'USA/abbr I believe the way to go would be to select for textnodes but I cannot figure out why that wouldn't work. Anyway, any help to fix my code would be appreciated (I hope the indentation is preserved when I post this). // find and add in abbr all over the place! var replacing={ 'TSV':'Tab-Separated Values', 'CSV':'Comma-Separated Values', 'STs?':'Sequence Type', 'CCs?':'Clonal Complex', 'MGIP':'Meningococcus Genome Informatics Platform', 'MLST':'Multilocus Sequence Typing', 'GIT':'Georgia Institute of Technology', 'CDC':'Centers for Disease Control and Prevention', 'OMP':'Outer Membrane Protein' }; $$('.systemMessage, .body p,.body div,label,h1,h2,h3,h4,.menu.firefox').each(function(el){ if(el.hasClassName('doNotDisturb')){ return; // equivalent to a continue inside of an each loop } el.select('text').each(function(s){ debug('textNode: '+s); }); for(var k in replacing){ var v=replacing[k]; var find=new RegExp('\\b('+k+')\\b','g'); // I should use something like innerContext or innerText instead of innerHTML el.update(el.innerHTML.replace(find,acronym title='+v+' $1/acronym,'')); } }); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---