|
<script type="text/Javascript"> // Mini-Profile Base v2 by Chris // Open Source // Tested in FireFox 1.5, IE6, and Opera 9 // The function returns an associative array containing the data.
/* "user" = username "display" = displayname link to profile "customtitle" = custom title "status" = online/offline status "karma" = Boolean false for no karma or the number "karmalinks" = Boolean false for none or contains them "avatar" = Boolean false if none or contains the img tag "contacts" = Contains the contact links "personal" = Personal text "posts" = Number of posts "location" = Boolean false if none, other contains location "joined" = Joined date "gender" = Boolean false if none, otherwise is gender and image "rank1" = User's text rank "rank2" = User's star rank if rankLines = 2 */
var br_re = /<br\s?\/?>/gi; var rankLines = 2;
function miniProfile(ext){ var _arr = []; _arr["user"] = ""; _arr["display"] = ""; _arr["customtitle"] = ""; _arr["status"] = ""; _arr["karma"] = false; _arr["karmalinks"] = false; _arr["avatar"] = false; _arr["contacts"] = ""; _arr["personal"] = ""; _arr["posts"] = 0; _arr["location"] = false; _arr["joined"] = ""; _arr["gender"] = false; _arr["rank1"] = ""; _arr["rank2"] = "";
var cen = ext.getElementsByTagName("center")[ext.getElementsByTagName("center").length-1]; // Gets around the use of center UBBC in custom title var cens = cen.innerHTML.split(br_re); for(var a=0;a<cens.length;a++){ if(cens[a].match(/\[avatar\]/i)) _arr["avatar"] = cens[a]; else if(cens[a].match(/\[(icq|yim|msn|aim|homepage|email|send\spm)\]/i)) _arr["contacts"] += cens[a]; else _arr["personal"] += cens[a]; } cen.parentNode.removeChild(cen);
var spi = ext.innerHTML.split(br_re); _arr["display"] = spi[0]; _arr["rank1"] = spi[1]; _arr["user"] = (spi[0].match(/user=(.+?)("|'|\s|>)/i)?RegExp.$1:""); if(rankLines == 2){ _arr["rank2"] = spi[2]; spi.splice(2,1); } spi.splice(0,2);
for(var a=0;a<spi.length;a++){ if(spi[a].match(/Gender: (.+?)$/i)) _arr["gender"] = RegExp.$1; else if(spi[a].match(/Joined: (.+?)$/i)) _arr["joined"] = RegExp.$1; else if(spi[a].match(/Posts: ([\d,]+)/i)) _arr["posts"] = RegExp.$1; else if(spi[a].match(/Location: (.+?)$/i)) _arr["location"] = RegExp.$1; else if(spi[a].match(/Karma: (-?[\d,]+)/i)) _arr["karma"] = RegExp.$1; else if(spi[a].match(/>Exalt</) && spi[a].match(/>Smite</)) _arr["karmalinks"] = spi[a]; else if(spi[a].match(/Member is ((<b>)?(on|off)line(<\/b>)?)/i)) _arr["status"] = RegExp.$1.replace(/<\/?b>/gi,""); else if(spi[a] != "") // Fix glitch where in IE, it removes it from the array if it has no value. This duplicates it for FF _arr["customtitle"] += spi[a]+"<br />"; }
return _arr; }
var aTD = document.getElementsByTagName("TD"); var br = "<br /><br /><br /><br />"; for(a=0;a<aTD.length;a++){ if(aTD[a].width == "20%" && aTD[a].innerHTML.match(/Posts:/i)){ var user = miniProfile(aTD[a]); var data = ""; for(b in user) data += b+": "+user[b]+br; aTD[a].innerHTML = data; } } </script> 100% open source for your usage. If you use it, I'd appreciate some credit, but it is not needed. Also, if you use it, just let me know what for. Kinda fun to see where my coding gets used. Anyways, about it. It is basically a function. The function should be called on the miniprofile cell. Make sure that it is a user's cell (check for posts) before calling the function however. Anyways, the function returns an associative array containing the data. I left my comments in there, they show what items are in an array and they also show why something is done how it's done. Enjoy. P.S. Since I know someone will ask, v1 was never released publicly.
Last Edit: Sept 17, 2006 20:14:03 GMT by Chris
|
|
|
|