I was thinking that it would be great to have a search and replace function
that could be used in tiddlers. I couldn’t find anything already coded, but did
find a bookmarlet that looks promising. I would like to have this work only in
the opened text area of the tiddler being editied.
How could this bookmarket be modified?
Bookmarklet below:
<pre>
javascript:var count=0;
function htmlreplace(a,b,element){
if(!element)element=document.body;
var nodes=element.childNodes;
for(var n=0;n<nodes.length;n++){
if(nodes[n].type&&nodes[n].type.toLowerCase()=='textarea'){
var r=new RegExp(a,'gim');
if(nodes[n].value.match(r)){
count++;
}
nodes[n].value=nodes[n].value.replace(r,b)
}
else if(nodes[n].nodeValue && nodes[n].nodeValue.length > 0){
var r=new RegExp(a,'gim');
if(nodes[n].nodeValue.match(r)){
count++;
}
nodes[n].nodeValue=nodes[n].nodeValue.replace(r,b)
}
else{
htmlreplace(a,b,nodes[n])
}
}
}
htmlreplace(prompt('find'),prompt('replace'));
alert('replaced '+count+' words.');
</pre>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/be8de0a6-f70a-4e55-a844-80d698c57bcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.