Re: [quote][b][color=red]For educational purposes only.[/color][/b][/quote]
[b]Updated as of April 15, 2008 [Internalize AJAX handler & new AJAX URL][/b]
[b]Browser compatible: Firefox 2+, Firefox 3, IE 6
where should i patse this code, in my costumized css in edit profile or in an external css or js file?
[i]Viewer's Main Photo at Side Bar
Code:
if (!attachOnLoadHandler(function() { mainVpic();})) window.onload = function() { mainVpic();};
function mainVpic() {
if(pageViewerID!="") SPAWNPIC.init();
}
if (typeof SPAWNPIC == "undefined") { SPAWNPIC = {}; }
SPAWNPIC = {
photo: [],
init: function() {
this.ajaxRequest("http://"+location.hostname+"/"+pageViewerID,SPAWNPIC.viewer,null);
},
viewer: function(htm) {
if (htm.replace(/^\s*|\s*$/g,"") === null) {
alert("VMP Error: Unable to parse the photo!");
return;
}else if (htm) {
var name = /controlpanel_header">([\S\s]+?)<a\s+?name="controlpanel/i.exec(htm)[1].replace(/^(\d)$/,"0$1");
var photo = /imgblock200"><a[\S\s]*?>([\S\s]+?)<\/a><\/div>/i.exec(htm)[1].replace(/^(\d)$/,"0$1");
var status = /data">([\S\s]+?)<\/span><\/li>/i.exec(htm)[1].replace(/^(\d)$/,"0$1");
var since = /Since\:\s+?<\/span>([\S\s]+?)<\/li>/i.exec(htm)[1].replace(/^(\d)$/,"0$1");
var location = /Location\:\s+<\/span>([\S\s]+?)<\/li>/i.exec(htm)[1].replace(/^(\d)$/,"0$1");
this.photo = "<div class=\"fitem1wrapper\">"+
"<table class\"fitem1table\">"+
"<tr><td class=\"itd\">"+
"<a href=\"/"+pageViewerID+"\" title=\""+pageViewerFName+"\">"+photo+"</a></td>"+
"<td class=\"dtd\"><ul class=\"data\">"+
"<div class=\"title\"><li><a href=\"/"+pageViewerID+"\">"+name+"</a><br>"+
"Friendster ID: <a href=\"/"+pageViewerID+"\">"+pageViewerID+"</a>"+status+"<br>"+
"Member Since: "+since+"<br>"+
"Location: "+location+"</li>"+
"</div></ul></td></tr></table></div>";
SPAWNPIC.box("Hello "+name,this.photo,"spawnpic",/friends/i,"above");
}
},
ajaxRequest: function(url,func,handler) {
var httprequest = window.XMLHttpRequest? new XMLHttpRequest():new ActiveXObject("Msxml2.XMLHTTP");
httprequest.onreadystatechange = function() {
if (httprequest.readyState == 4) {
if (httprequest.status == 200) {
func(httprequest.responseText,handler);
}
}
};
httprequest.open("GET", url, true);
httprequest.send(null);
},
box: function(head,code,id,sibling,x) {
var sbdiv = document.createElement("div");
sbdiv.className="commonbox "+id;
sbdiv.id = id;
if (!head) head = "";
else head = "<h2>"+head+"</h2>";
sbdiv.innerHTML = head;
sbdiv.appendChild(document.createElement("div"));
sbdiv.getElementsByTagName("div")[0].id ="content_"+id;
sbdiv.getElementsByTagName("div")[0].innerHTML = code;
var sbli = document.createElement("LI");
sbli.appendChild(sbdiv);
if (!x) this.getModuleByClassName(sibling)[0].parentNode.parentNode.appendChild(sbli);
else if (x == "below") this.getModuleByClassName(sibling)[0].parentNode.appendChild(sbli);
else if (x == "above") {
var ul = this.getModuleByClassName(sibling)[0];
ul.parentNode.parentNode.insertBefore(sbli,ul.parentNode);
}
},
getModuleByClassName: function(sClass) {
var elm = [];
var els = document.getElementsByTagName("*") || document.all;
for (var j=0,k=els.length;j<k;j++) {
if (new RegExp(sClass).test(els[j].className))elm.push(els[j]);
}
return elm;
}
};[/i]