Hello,
I am experimenting with DOM Manipulation.
I am facing a problems and need some help. :-)
Here is my experiment page :
http://202.137.6.98/yuan/test1/
The goal is to convert text on page to link based on keyword.
It''s something like www.ContextAdsPro.com
What I done is :
(or see the js.js at
http://202.137.6.98/yuan/test1/library/javascript/other/js.js
My question is how to change the original text, instead of inserting to new div.
(I am inserting to different div this just to test that the request to
server returns
what I expected)
Thanks
here is my JS code :
function convertText()
{
var doc = $$(''p'').each(function(doc){
t = ajaxRequest(doc);
})
}
function ajaxRequest(docElement)
{
var notice = $(''contentDiv'');
var tempInvisible = $(''invisible'');
var tempText = new Array;
for(j=0;j<docElement.childNodes.length;j++)
{
var textPost = docElement.childNodes[j].nodeValue;
if (textPost == null) {
//alert("1");
textPost = docElement.childNodes[j].firstChild.nodeValue;
//docElement.childNodes[j].firstChild
new Ajax.Request(''contextAds.php?action=checkAds&doc=''
+ textPost, {
method: ''post'',
onSuccess: function(transport) {
if (j == 0) {
//docElement.childNodes[j].parentNode.innerHTML += "
<<000>>"+transport.responseText;
}else{
//docElement.childNodes[j].parentNode.innerHTML +=
"<<1111>>
"+transport.responseText;
}
var tt = transport.responseText;
notice.innerHTML += " "+tt
tempText[j]= tt;
docElement.childNodes[j].parentNode.nodeValue = tt;
//alert(transport.responseText);
//docElement.childNodes[j].firstChild.replace(docElement.childNodes[j].parentNode.nodeValue,transport.responseText);
},
});
}else{
//alert("2");
//docElement.childNodes[j]
new Ajax.Request(''contextAds.php?action=checkAds&doc=''
+ textPost, {
method: ''post'',
onSuccess: function(transport) {
if (j == 0) {
//docElement.innerHTML += "<<222>>
"+transport.responseText;
}else{
// docElement.innerHTML += "1>> "+transport.responseText;
}
var tt = transport.responseText;
notice.innerHTML += " "+tt
tempText[j]= tt;
//alert(transport.responseText);
docElement.childNodes[j].nodeValue =tt;
//docElement.childNodes[j].replace(docElement.childNodes[j].nodeValue,transport.responseText);
},
});
}
}
return tempText;
}
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Limitless undying love
which shines around me like a million suns
It calls me on and on across the universe...."
Accross The Universe - The Beatles -
--------------------------------------------
Visit :
http://www.sabukhitam.com/
=====================
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---