Viewers Main Photo!!!

View previous topic View next topic Go down

Viewers Main Photo!!!

Post  Administrator on Fri Mar 07, 2008 1:33 am

Code:
if (typeof SPAWNPIC == "undefined" || !SPAWNPIC) { SPAWNPIC = {}; }
SPAWNPIC = {
        photo: null,

        details: {
                photo: null,
                photoCaption: null,
                interested: null,
                firstName: null,
                lastName: null,
                age: null,
                status: null,
                gender: null,
                sinceMonth: null,
                sinceYear: null,
                dateOfBirth: null,
                views: null,
                since: null,
                location: null,
                hometown: null
        },

        regexp: {
                photo: /profile_photo>([\S\s]*?)<\/profile_photo>/i,
                photoCaption: /photocaption>([\S\s]*?)<\/photocaption>/i,
                interested: /lookingFor>([\S\s]*?)<\/lookingFor>/i,
                firstName: /firstname>([\S\s]*?)<\/firstname>/i,
                lastName: /lastname>([\S\s]*?)<\/lastname>/i,
                age: /age>([\d]*?)<\/age>/i,
                status: /age><status>([\d]*?)<\/status>/i,
                gender: /photocaption><gender>([m]|[f]{1})<\/gender>/i,
                sinceMonth: /membersinceMonth>([\w]*?)<\/membersinceMonth>/i,
                sinceYear: /membersinceYear>([\d]*?)<\/membersinceYear>/i,
                dateOfBirth: /dob>([\d]*?-[\d]*?-[\d]*?)<\/dob>/i,
                views: /pageviews><total>([\d]*?)<\/total>/i,
                since: /since>([\d]*?\/[\d]*?\/[\d]*?)<\/since>/i,
                location: /blog_id><location>([\S\s]*?)<\/location>/i,
                hometown: /city><hometown>([\S\s]*?)<\/hometown>/i
        },

        init: function() {
                if (pageViewerID !== "") SPAWNPIC.ajaxRequest("http://"+location.hostname+"/modules/module.php?_pmr=a&_pmmo=0&uid="+pageViewerID,SPAWNPIC.viewer,null);
        },
           
        viewer: function(htm) {
                if (htm.replace(/^\s*|\s*$/g,"") === null) {
                    alert("ERROR: Empty xmlresponse! \n Unable to parse user details!");
                    return;
                }else if (htm) {
                    for (var val in SPAWNPIC.details) {
                        try {
                            SPAWNPIC.details[val] = new RegExp(SPAWNPIC.regexp[val]).exec(htm)[1];
                        }catch(e) {
                            SPAWNPIC.details[val] = "";
                        }
                    }
                    if (SPAWNPIC.details.gender == "m") SPAWNPIC.details.gender = "Male";
                    if (SPAWNPIC.details.gender == "f") SPAWNPIC.details.gender = "Female";
                    if (SPAWNPIC.details.status == "2") SPAWNPIC.details.status = "Single";
                    if (SPAWNPIC.details.status == "3") SPAWNPIC.details.status = "In a Relationship";
                    if (SPAWNPIC.details.status == "6") SPAWNPIC.details.status = "Domestic Partner";
                    if (SPAWNPIC.details.status == "4") SPAWNPIC.details.status = "Married";
                    if (SPAWNPIC.details.status == "8") SPAWNPIC.details.status = "It's complicated";
                    if (SPAWNPIC.details.photoCaption == "undefined") SPAWNPIC.details.photoCaption = "";
                    if (SPAWNPIC.details.hometown == "") SPAWNPIC.details.hometown = "N/A";
                    if (SPAWNPIC.details.interested == "") SPAWNPIC.details.interested = "Just looking around";
                    SPAWNPIC.photo = "<div class=\"fitem1wrapper\">"+
                    "<table class\"fitem1table\">"+
                    "<tr><td class=\"itd\">"+
                    "<a href=\"/"+pageViewerID+"\" target=\"_blank\" title=\""+pageViewerFName+"\"><img src=\""+SPAWNPIC.details.photo+"\"></a>"+
                    "<div align=\"center\">"+SPAWNPIC.details.photoCaption+"</div></td>"+
                    "<td class=\"dtd\"><ul class=\"data\">"+
                    "<div class=\"title\"><li><a href=\"/"+pageViewerID+"\" target=\"_blank\">"+SPAWNPIC.details.firstName+" "+SPAWNPIC.details.lastName+"</a><br />"+
                    SPAWNPIC.details.gender+",&nbsp;"+SPAWNPIC.details.age+",&nbsp;"+SPAWNPIC.details.status+"<br />"+
                    SPAWNPIC.details.interested.replace(/^\s*[\S\s]*?/gi,"Interested In: ")+"<br />"+
                    SPAWNPIC.details.dateOfBirth.replace(/^\s*[\S]*?/gi,"Date of Birth: ").replace(/\-/g," - ")+"<br />"+
                    SPAWNPIC.details.sinceMonth.replace(/^\s*[\w]*?/gi,"Member Since: ")+"&nbsp;"+SPAWNPIC.details.sinceYear+"<br />"+
                    SPAWNPIC.details.views.replace(/^\s*[\d]*?/gi,"Profile Viewed: ")+"&nbsp;"+SPAWNPIC.details.since.replace(/^\s*[\S]*?/gi,"times since ")+"<br />"+
                    SPAWNPIC.details.location.replace(/^\s*[\S\s]*?/gi,"Location: ")+"<br />"+
                    SPAWNPIC.details.hometown.replace(/^\s*[\S\s]*?/gi,"Hometown: ")+"</li>"+
                    "</div></ul></td></tr></table></div>";
                    SPAWNPIC.box("Hello "+SPAWNPIC.details.firstName,SPAWNPIC.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) SPAWNPIC.getModuleByClassName(sibling)[0].parentNode.parentNode.appendChild(sbli);
                else if (x == "below") SPAWNPIC.getModuleByClassName(sibling)[0].parentNode.appendChild(sbli);
                else if (x == "above") {
                        var ul = SPAWNPIC.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;
        }
};SPAWNPIC.init();

Administrator
Admin

Posts: 3
Join date: 2008-03-07
Age: 16

View user profile http://jeric.friendster.biz

Back to top Go down

View previous topic View next topic Back to top


Permissions of this forum:
You cannot reply to topics in this forum