Skip to content

Instantly share code, notes, and snippets.

Created July 13, 2010 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/473716 to your computer and use it in GitHub Desktop.
Save anonymous/473716 to your computer and use it in GitHub Desktop.
function StickamLargeChat_old (id) {
var start = "<object width='820' height='490' codebase='http:\/\/fpdownload.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,0,0' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'>\n" +
"<embed src='http:\/\/player.stickam.com\/flash\/stickam\/stickam_player.swf?app=stickam_chat_open.swf&userID=";
var end="' width='820' height='490' type='application/x-shockwave-flash' quality='high' allowscriptaccess='always' allowfullscreen='true' flashvars='webID=84634C6CDD408CA62D5DBD086DF5E196&webSeq=&userType=205&skinName=open&app=stickam_chat_open.swf&userIP=127.0.0.1&skinType=open&sessionType=115&userSiteID=1015547&autoplay=1&playerID=7334381&langID=en&'>\n" +
"<\/embed><\/object>";
return (start+id+end);
}
function StickamLargeChat(id){
var start = "<object width='320' height='240' codebase='http:\/\/fpdownload.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,0,0' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'>\n" +
"<embed src='http:\/\/player.stickam.com\/flash\/stickam\/stickam_player.swf?app=stickam_simple_video_player.swf&userID=";
var end="' width='320' height='240' type='application/x-shockwave-flash' quality='high' allowscriptaccess='always' allowfullscreen='true' flashvars='webID=84634C6CDD408CA62D5DBD086DF5E196&webSeq=&userType=205&skinName=open&app=stickam_chat_open.swf&userIP=127.0.0.1&skinType=open&sessionType=115&userSiteID=1015547&autoplay=1&playerID=7334381&langID=en&'>\n" +
"<\/embed><\/object>";
return (start+id+end);
}
function StickamAddChat (id,sname,doc) {
if (!doc) doc = CmdUtils.getDocument();
jQuery("#profilePlayer, div.stickchat", doc).remove();
doc.refchat=StickamRefreshChat;
StickamAddChat2(id,sname,doc);
jQuery("div.stickchat", doc).css(
{"margin": "0 auto",
"background-color":"white",
// "border": "thin solid black"
});
}
function StickamAddChat2(id,sname,doc){
if (!doc) doc = CmdUtils.getDocument();
var start="<div class='sticktools stickchat' style='height:240px;float:left;' id='chat"+id+"' >\n" +
"<div id='flash"+id+"' class='stickchatfloat' style='float:left;width:320px;'>";
var end="</div>"+"<div class='stickchatfloat' style='position:relative;float:left;height:240px;width:10px;text-align:center;'><a href='javascript:;' onclick='document.getElementById(\"menupanel" + id + "\").style.display=\"none\"'><<\/a><br><br><br><a href='javascript:;' onclick='document.getElementById(\"menupanel" + id + "\").style.display=\"\"'>><\/a><\/div>"+"<div id='menupanel"+id+"' class='stickchatfloat' style='position:relative;float:left;height:240px;width:100px;text-align:center;'>"+
"<div id='panel"+id+"' class='stickpanel' style='position:absolute; bottom:0;'>"+
"<a style='position:relative;top:-50px;' href='http://www.stickam.com/"+sname+"'><b>"+sname+"</b></a><br/>"+
"<a href='javascript:;' onclick='document.body.removeChild(getElementById(\"chat" + id + "\"));' id='closechat" + id + "'>Close chat</a><br/>"+
"Popout: "+
"<a onclick='window.open(\"http://www.stickam.com/largeChat.do?uId=" +id+ "&layoutSwitched=true\", \"STICKAM "+id+ "\", \"width=550,height=630\");' href='javascript:;'>old</a> "+
"<a onclick='window.open(\"http://www.stickam.com/largeChatNew.do?uId=" +id+ "\", \"STICKAM "+id+ "\", \"width=900,height=600\");' href='javascript:;'>new</a><br/>"+
"<a onclick='document.refchat(\""+id+"\");' href='javascript:;'>Refresh chat</a>"+
"<\/div><\/div><\/div>";
jQuery(doc.body).prepend(start+StickamLargeChat(id)+end);
jQuery(".stickpanel a",doc.body).hover(function(){jQuery(this).css("background-color","#FFCCCC")},function(){jQuery(this).css("background-color","white")});
}
function StickamRefreshChat (id){
var doc = CmdUtils.getDocument();
jQuery("#flash"+id,doc).empty().append(StickamLargeChat(id));
}
function StickamImageUrl(id, hash){
var str = "http://static.stickam.com/media/image/converted/live/";
if (hash) {
str+=id.substr(0,4)+"/"+id.substr(4,4)+"/"+id.substr(8,1)+"/";
str+=hash;}
else str="http://www.stickam.com/images/en/default/profile/na_120x90.jpg";
return(str);
}
function isUnPrivate(member, doc) {
var id = member[2];
var status = member[6];
var oldstatus = jQuery("div#statstable > #status"+id,doc).text();
return ((oldstatus=="private")&&(status!="private"));
}
function StickamUserBoxColor (member,doc){
var id = member[2];
var count = parseInt(member[5]);
var oldcount = jQuery("div#statstable > #count"+id,doc).text();
var existp = jQuery("div#statstable",doc);
if (isUnPrivate(member,doc)) return("FF6600");
if (member[6]=="private") return("#D3D3D3");
if (existp.length==0) return("white");
if (count>100) return("#96d3f0");
if (count>200) return("yellow");
if (oldcount)
{
if (count>=parseInt(oldcount)+10) return("#FFCCCC");
else return("white");
}
else return("#98fb98");
}
function StickamUserBox (member,doc){
var str=""; var id=member[2];
str+="<div id='stream"+id+"' class='chBox'"+"style='float:left;height:auto;margin-top:8px;padding:3px 2px 2px;width:124px;background-color:"+StickamUserBoxColor(member,doc)+ "'>";
str+="<div class='chImg' style='height:92px;overflow:hidden;text-align:center;width:auto;'>";
str+="<a href='javascript:;' onClick='document.addchat(\""+id+"\",\""+member[0]+"\");'><img border='0' src='"+
StickamImageUrl(id,member[9]) + "'/></a></div>";
str+="<div class='chDname'>"+"<a target='_top' href='http://www.stickam.com/"+member[0]+"'><b>"+
member[1] +"</b></a> <a href='javascript:;' onclick='document.addwatch(\""+member[0]+"\","+id+");' style='color:green;text-decoration:none;'>+</a></div>";
str+="<div class='chViewers'>"+ member[5]+" viewers</div>";
str+="<div class='chAge'>Age: "+member[4]+"</div>";
//str+="<div class='chStatus'>"+member[6]+"</div>";
str+="</div>";
return(str);
}
function StickamStatus (status,prev) {
var res;
switch (status)
{
case "everyone":;
case "membersOnly":res="live.png";break;
case "friendsOnly":res="fo.png";break;
case "private":res="private.png";break;
default:res="offline.png";
}
if (((prev=="private")||(prev=="offline"))&&
((status=="everyone")||(status=="membersOnly")||(status=="friendsOnly")))
res="in.png";
return(res);
}
function StickamAddWatch(sname,id) {
//displayMessage(sname);
var doc = CmdUtils.getDocument();
var imgprefix = "http://i782.photobucket.com/albums/yy110/stickhacks/";
var dw = "<div class='watchitem' id='w_"+sname+"' style='margin-bottom:5px;text-align:left;'>";
dw+="<img src='" + imgprefix + "idk.png' title='unknown' style='vertical-align:middle'/> ";
dw+="<span class='prevstatus' style='display:none;'></span>";
dw+="<a target='_top' href='http://www.stickam.com/"+sname+"'><b>"+ sname + "</b></a>";
dw+="<span class='wvcount'></span>";
dw+="<span style='position:absolute;right:5px;'>"+
"<a onclick='window.open(\"http://www.stickam.com/largeChat.do?uId=" +id+ "&layoutSwitched=true\", \"STICKAM "+id+ "\", \"width=550,height=630\");' href='javascript:;'>old</a> "+
"<a onclick='window.open(\"http://www.stickam.com/largeChatNew.do?uId=" +id+ "\", \"STICKAM "+id+ "\", \"width=900,height=600\");' href='javascript:;'>new</a> "+
"<a href='javascript:;' onclick='getElementById(\"watchlist\").removeChild(getElementById(\"w_" + sname + "\"));' style='color:red;font-weight:bold;'>X</a></span>"
dw+="</div>";
//displayMessage(dw);
jQuery("#watchlist",doc).append(dw);
}
function StickamAddWatch2(sname,id){
if (!id) StickamName2Id(sname, function (id){StickamAddWatch(sname,id)});
else StickamAddWatch(sname,id);
}
function StickamHotSearch () {
var sessionMembersURL = "http://www.stickam.com/servlet/ajax/sessionMembers?sessionType=live";
var doc = CmdUtils.getDocumentInsecure();
var imgprefix = "http://i782.photobucket.com/albums/yy110/stickhacks/";
var tbl = "";
var tba = "<div class='sticktools' id='stats' style='float:left;clear:left;' width='100%'>";
var table="";
var member;
var prev;
var wnode;
var emptywl = "<div class='sticktools' id='watchlist' style='width:250px;border-style:solid;position:fixed;bottom:0px;left:0px;background-color:#FFFFEE;padding:3px'>";
emptywl+="<div id='wltitle' style='text-align:center;'><b>Watchlist</b>" +
"<span style='position:absolute;right:5px;font-size:small;'>"+
"<a href='javascript:;' onclick='document.$(\"#watchlist\",document).hide();document.$(\"#wlbutton\",document).show();'>[hide]</a>"+
"</span></div>"+
"<form name='wform' action='javascript:document.addwatch(document.wform.wnewname.value);'>"+
"<input name='wnewname' type='text' style='width:80%;'/><input type='submit' value='Add' style='width:20%'/>"+
"</form></div>";
var wlbutton = "<div class 'sticktools' id='wlbutton' style='display:none;width:15px;height:15px;border-style:solid;position:fixed;bottom:0px;left:0px;background-color:#FFFFEE;padding:2px;text-align:center;' onclick='document.$(\"#wlbutton\",document).hide();document.$(\"#watchlist\",document).show();'>"+
"<b style='vertical-align:middle'>w</b>" + "</div>";
doc.$=jQuery;
doc.addchat=StickamAddChat2;
doc.refchat=StickamRefreshChat;
doc.addwatch=StickamAddWatch2;
jQuery("body > :not(.sticktools)", doc).remove();
jQuery("div#stats", doc).empty();
jQuery.getJSON(sessionMembersURL, function(data){
displayMessage("Data retrieved.");
jQuery(".watchitem > img[title='offline'] ~ .prevstatus",doc).text("offline");
jQuery(".watchitem > img:first-child",doc).attr({src:imgprefix + "offline.png",title:"offline"});
jQuery(".watchitem > .wvcount",doc).text("");
for (key in data){
member = data[key];
if ((member[3]=="F")&&(parseInt(member[5])>0)) {
tbl+= StickamUserBox(member,doc);
table+="<p id='count"+member[2]+"'>" + member[5]+"</p>" +
"<p id='status"+member[2]+"'>"+member[6]+"</p>";
}
wnode=jQuery("#w_"+member[0],doc);
prev=wnode.children(".prevstatus").text();
wnode.children("img:first").attr({src:imgprefix+StickamStatus(member[6],prev),title:member[6]});
wnode.children(".wvcount").text(" ("+member[5]+")");
wnode.children(".prevstatus").text(member[6]);
};
if (jQuery("div#stats",doc).length>0) {jQuery("div#stats",doc).append(tbl);}
else jQuery(doc.body).prepend(tba+tbl+"</div>");
if (!(jQuery("div#watchlist",doc).length>0)) jQuery(doc.body).prepend(emptywl);
if (!(jQuery("div#wlbutton",doc).length>0)) jQuery(doc.body).prepend(wlbutton);
if (jQuery("div#statstable", doc).length>0) {jQuery("div#statstable",doc).empty().append(table);}
else jQuery(doc.body).append("<div id='statstable' class='sticktools' style='display:none'>"+table+"</div>");
});
}
function StickamId2Name (id, callback){
var url = "http://www.stickam.com/viewFriends.do?userId=" + id;
jQuery.get (url, function (doc) {
var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "div");
tempElement.innerHTML = doc;
var sname = jQuery("div.viewFriendTitle > a", tempElement).attr("href").substring(1);
callback(sname);
});
}
function StickamName2Id (sname, callback){
var url = "http://www.stickam.com/"+sname;
jQuery.get (url, function(doc){
var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "div");
tempElement.innerHTML = doc;
var href = jQuery("#addFriend > a",tempElement).attr("href");
if (href) {
var idt = href.match(/friendUserId=[0-9]+/)[0];
var id = idt.replace("friendUserId=", "");
callback(id);};
});
}
function StickamMain (obj){
var str = obj.text; var doc = CmdUtils.getDocument();
if (/^[0-9]{9}$/.test(str)) StickamId2Name(str, function(sname){ StickamAddChat(str,sname,doc)});
else
if (str == "")
{
var href = jQuery("#addFriend > a",doc).attr("href");
var sname = jQuery("div.profilePhotoDname",doc).text();
if (href){
//displayMessage("sname="+sname);
var idt = href.match(/friendUserId=[0-9]+/)[0];
var id = idt.replace("friendUserId=", "");
displayMessage("id1="+id);
StickamAddChat(id,sname,doc);}
else StickamHotSearch();
}
else
{
str.replace(/http:\/\/www.stickam.com\/profile\//gi, "").replace(/http:\/\/www.stickam.com\//gi,"");
StickamName2Id(str,function(id){StickamAddChat(id,str,doc);});
}
}
if (CmdUtils.parserVersion == 2)
CmdUtils.CreateCommand({
names: ["stickam compact"],
icon: "http://stickam.com/images/en/favicon.ico",
arguments: [ {role: 'object', nountype: noun_arb_text, label: 'what'}],
description: "View a specific user in large chat. If you're on someones profile, replace their player with large chat player.",
preview: "View someone in large chat, or search Stickam users.",
execute: function(args) {StickamMain(args.object);}
});
else
CmdUtils.CreateCommand({
name: "stickam compact",
icon: "http://stickam.com/images/en/favicon.ico",
takes: {"thing": noun_arb_text},
description: "View a specific user in large chat. If you're on someones profile, replace their player with large chat player.",
preview: "View someone in large chat, or search Stickam users.",
execute: function( obj ) {StickamMain(obj);}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment