Вы находитесь на странице: 1из 3

/*

viewer's main photo sidebar


author: feruzz � http://profiles.friendster.com/feruzz
internalize ajax handler
requirement: addbox function

no warranty expressed or implied. use at your own risk.


*/

/*global spawnpic*/
spawnpic = {};

if(pageviewerlangpref !== "en-us") {


window.location.href =
"http://profiles.friendster.com/"+pageownerid+"?lang=en-us&updatelang=1";
}

if (!attachonloadhandler(function() { spawnpic.init(); })) window.onload =


function() { spawnpic.init(); };

(function() {
spawnpic = {
// private property
photo: null,

info: {
name: null,
photo: null,
gender: null,
age: null,
status: null,
location: null,
seek: null,
since: null
},

regexp: {
name: /controlpanel_header">([\s\s]*?)<a\s*name="controlpanel/i,
photo: /imgblock200"><a[\s\s]*?>([\s\s]*?)<\/a><\/div>/i,
gender: /q">([\s]*male)/i,
age: /male,\s*([\d]*),/i,
status: /male,\s*[\d]*,\s*([\s\s]*?)<\/span>/i,
location:
/location\:\s*<\/span><a[\s\s]*?>([\s\s]*?)<\/a><\/li>/i,
seek: /interested\s*in\:\s*<\/span>([\s\s]*?)<\/li>/i,
since: /member\s*since\:\s*<\/span>([\w]*?[\s][\d]*?)<\/li>/i
},

init: function() {
try {
spawnpic.ajaxrequest("get", "http://" + location.hostname +
"/" + pageviewerid, true, null, spawnpic.viewer, null);
} catch(e) {}
},

viewer: function(mypic) {
if (mypic.replace(/^\s*|\s*$/g, "") === "") {
alert("vmp error: unable to parse user details!");
return;
} else if (mypic) {
for (var val in spawnpic.info) {
try {
spawnpic.info[val] = new
regexp(spawnpic.regexp[val]).exec(mypic)[1].replace(/^(\d)$/, "0$1");
} catch(e) {
spawnpic.info[val] = "";
}
}
var seek = spawnpic.info.seek;
switch (spawnpic.info.seek) {
case "":
seek = "just looking around";
break;
}
spawnpic.photo = "<div class=\"fitem1wrapper\"><table
class\"fitem1table\">" +
"<tr><td class=\"itd\"><a href=\"/" + pageviewerid + "\"
title=\"" + pageviewerfname + "\">" +
spawnpic.info.photo.replace(/<img /gi, "<img width=\"100\"
height=\"100\" ") + "</a></td>" +
"<td class=\"dtd\"><ul class=\"data\"><div
class=\"title\">" +
"<li><a href=\"/" + pageviewerid + "\">" +
spawnpic.info.name + "</a><br>" +
pageviewerid.replace(/^\s*[\d]*?/gi, "friendster id: ") +
"<br>" +
spawnpic.info.gender + ", " + spawnpic.info.age + ", " +
spawnpic.info.status.replace(/<[\s]*?>/g, "") + "<br>" +
"interested in: " + seek + "<br>" +
spawnpic.info.since.replace(/^\s*[\w]*?/gi, "member since:
") + "<br>" +
spawnpic.info.location.replace(/^\s*[\s\s]*?/gi, "location:
") + "</li>" +
"</div></ul></td></tr></table></div>";
addbox("hello " + spawnpic.info.name, spawnpic.photo,
"spawnpic", /commonbox[\s]*?friends/i);
}
},

ajaxrequest: function (type, url, async, param, func, handlerparam) {


/**
* ajaxrequest function
* version: 2.3
* copyright: feruzz � http://profiles.friendster.com/feruzz
*
* @type: "get" | "post"
* @cont: true | false
* @param: param | null
**/

var httprequest = null;


var requestdone = false;
var msxml = ["msxml2.xmlhttp.6.0", "msxml2.xmlhttp.3.0",
"msxml2.xmlhttp", "microsoft.xmlhttp"];
for (var x = 0, len = msxml.length; x < len; x++) {
try {
httprequest = window.activexobject ? new
activexobject(msxml[x]) : new xmlhttprequest();
break;
} catch (e) {
httprequest = null;
}
}
if (typeof func === "function") {
httprequest.onreadystatechange = function () {
if (!requestdone && httprequest &&
(httprequest.readystate === 4)) {
requestdone = true;
if ((httprequest.status >= 200 &&
httprequest.status < 300) || httprequest.status === 304 || httprequest.status ===
1223) {
func(httprequest.responsetext.replace(new
regexp("<script[^>]*>.*?<\/script>", "gi"), ""), handlerparam);
}
}
};
}
httprequest.open(type, url, async);
httprequest.setrequestheader("ajaxrequest", "true");
httprequest.setrequestheader("x-requested-with",
"xmlhttprequest");
httprequest.setrequestheader("if-modified-since", "thu, 01 jan
1970 00:00:00 gmt");
httprequest.setrequestheader("accept", "text/javascript,
application/javascript, text/html, application/xml, text/xml, text/plain, */*");
if (type === "post") {
var headers = "application/x-www-form-urlencoded" + ("utf-
8" ? "; charset=" + "utf-8" : "");
var contentlength = param ? param.length: 0;
httprequest.setrequestheader("content-type", headers);
httprequest.setrequestheader("content-length",
contentlength);
if (httprequest.overridemimetype &&
(navigator.useragent.match(/gecko\/(\d{4})/) || [0, 2005])[1] < 2005) {
httprequest.setrequestheader("connection", "close");
}
}
httprequest.send(param);
}
};
})();

Вам также может понравиться