Åh ja, så er det også lykkedes mig at aflure noget javekode fra Skype, som jeg tror viser hvordan man laver knapper på websiden.
var skype_injection_path='
chrome://skype_ff_toolbar_win/content/';var skype_tool=null;
//FLAG TOOLTIP
function HideSkypeFull()
{
skype_active=false;
// document.getElementById('skype_dc').style.visibility="hidden";
skype_tool.hide_flag_tooltip();
}
function ShowSkype(event)
{
skype_active=true;
skype_tool.show_flag_tooltip(event.screenX, event.screenY);
// DoShowSkype(event.pageX+2, event.pageY-20);
}
function DoShowSkype(cX, cY)
{
/* var menu=document.getElementById('skype_dc');
menu.style.visibility="visible";
menu.style.left=cX+'px';
menu.style.top=cY+'px';
*/
}
function doSkypeFlag(obj,brd)
{
obj.style.borderColor = brd;
}
//COMMANDS
function SkypeToolBarInit(tb)
{
skype_tool=tb;
}
function doRunCMD(link, id, name)
{
if (skype_tool)
{
if (link == 'chdial')
skype_tool.chprefix(id, document);
else if (link == 'copy')
skype_tool.copy_num(id, document);
else if (link == 'sms')
skype_tool.sms(id);
else if (link == 'add')
skype_tool.add(id, name);
else if (link == 'fax')
skype_tool.fax(id, name);
else
skype_tool.call(id);
}
}
function runCMD(link)
{
HideSkypeFull();
doRunCMD(link, skype_curid, skype_cur_name);
}
function skype_tb_imgOnOff(e,onoff,id)
{
var node=e.originalTarget;
while(!(node.tagName.toLowerCase() == 'span' && node.getAttribute('id') == '__skype_highlight_id'))
{
node=node.parentNode;
}
if (node.getAttribute('fax') != 'true')
{
if (node.getAttribute('rtl') == 'false')
{
node.childNodes.item(1).src=(onoff=='_on')?skype_injection_path+'call_small_on.gif':skype_injection_path+'call_small_off.gif';
node.childNodes.item(2).setAttribute('class', (onoff=='_on')?'skype_tb_injectionInAct':'skype_tb_injectionIn');
node.childNodes.item(3).src=(onoff=='_on')?skype_injection_path+'active_r.gif':skype_injection_path+'inactive_r.gif';
}
else
{
node.childNodes.item(2).src=(onoff=='_on')?skype_injection_path+'call_small_on.gif':skype_injection_path+'call_small_off.gif';
node.childNodes.item(1).setAttribute('class', (onoff=='_on')?'skype_tb_injectionInAct':'skype_tb_injectionIn');
node.childNodes.item(0).src=(onoff=='_on')?skype_injection_path+'active_r.gif':skype_injection_path+'inactive_r.gif';
}
}
else
{
if (node.getAttribute('rtl') == 'false')
{
node.childNodes.item(1).src=(onoff=='_on')?skype_injection_path+'fax/fax_small_on.gif':skype_injection_path+'fax/fax_small_off.gif';
node.childNodes.item(2).setAttribute('class', (onoff=='_on')?'skype_tb_injectionInAct':'skype_tb_injectionIn');
node.childNodes.item(3).src=(onoff=='_on')?skype_injection_path+'fax/active_r.gif':skype_injection_path+'fax/inactive_r.gif';
node.childNodes.item(0).src=(onoff=='_on')?skype_injection_path+'fax/active_l.gif':skype_injection_path+'fax/inactive_l.gif';
}
else
{
node.childNodes.item(2).src=(onoff=='_on')?skype_injection_path+'fax/fax_small_on.gif':skype_injection_path+'fax/fax_small_off.gif';
node.childNodes.item(1).setAttribute('class', (onoff=='_on')?'skype_tb_injectionInAct':'skype_tb_injectionIn');
node.childNodes.item(0).src=(onoff=='_on')?skype_injection_path+'fax/active_r.gif':skype_injection_path+'fax/inactive_r.gif';
node.childNodes.item(3).src=(onoff=='_on')?skype_injection_path+'fax/active_l.gif':skype_injection_path+'fax/inactive_l.gif';
}
}
}
//MENU
var skype_curid=0,skype_active=false,skype_showseed=0,skype_ctm=0,skype_cur_name='';
function HideSkypeMenu()
{
if(!skype_active)
HideSkypeMenuFull();
else
setTimeout("HideSkypeMenu()",1000);
}
function HideSkypeMenu2()
{
skype_showseed=0;
if(!skype_active)
HideSkypeMenuFull();
else
{
skype_active=false;
setTimeout("HideSkypeMenu()",1000);
}
}
function HideSkypeMenuFull()
{
skype_active=false;
// document.getElementById('skype_menu').style.visibility="hidden";
}
function CheckSkype()
{
skype_active=true;
}
function ShowSkypeMenu(event, call_msg, id, callto, isMobile, name)
{
try{
/* skype_active=true;
if(document.getElementById('skype_menu').style.visibility!="hidden" && skype_curid==id)
return;
skype_showseed=Math.random();
clearTimeout(skype_ctm);
var obj=event.originalTarget;
if (!obj)
obj=event; //alert(obj);
var brd=getBounds(obj);
var pcx=brd.left, pcy=brd.top+15; //alert('('+pcx+', '+pcy+') - ('+event.x+', '+event.y+')');
skype_ctm=setTimeout('DoShowSkypeMenu(\''+call_msg+'\','+skype_showseed+',"'+callto+'",'+pcx+','+pcy+','+isMobile+',"'+name+'")',0);
*/
if (event.button != 0) return;
event.stopPropagation();
/*event.preventBubble();*/
skype_tool.rclick(event);
}catch(e){ }
}
function DoShowSkypeMenu(call_msg, seed, callto, pcx, pcy, isMobile, name)
{
try{
/* if(seed!=skype_showseed)
return;
skype_showseed=0;
skype_curid=callto;
skype_cur_name=name;
var menu=document.getElementById('skype_menu');
/*
var m_name=new String(name);
if(name.length>16)
m_name=m_name.substring(0,13)+'...';
document.getElementById('name_text').innerHTML=call_msg;
* /
var docelem = document.documentElement;
if ((docelem.scrollTop == 0 && document.body.scrollTop != 0) || (docelem.scrollLeft == 0 && document.body.scrollLeft != 0))
docelem=document.body;
scrollY=docelem.scrollTop;
scrollX=docelem.scrollLeft;
var my=pcy, mx=pcx, mby=docelem.clientHeight+scrollY, mbx=docelem.clientWidth-192+scrollX;
if(my>mby) my=mby;
if(my<scrollY) my=scrollY;
if(mx>mbx) mx=mbx;
if(mx<scrollX) mx=scrollX;
menu.style.left=mx+'px';
menu.style.top=my+'px';
skype_tool.doFixMenu(menu, isMobile, document);
menu.style.visibility="visible";
*/
}catch(e){ }
}
function doSkypeArrow(obj,onoff)
{
obj.src=(onoff=='_on')?skype_injection_path+'active_ln.gif':skype_injection_path+'inactive_ln.gif';
}
function SetBgColor(obj, color)
{
try{
obj.lastChild.style.backgroundColor = color;
}catch(e){ }
}
function getBounds(element)//event)
{
try{
//var element=event.originalTarget;
var left = element.left; //event.clientX;
var top = element.top; //event.clientY;
if (document.location.toString().indexOf('local.google') == -1)
{
while(!(element.tagName.toLowerCase() == 'span' && element.getAttribute('id') == '__skype_highlight_id'))
{
element=element.parentNode;
}
left = element.offsetLeft;
top = element.offsetTop;
for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
{
left += parent.offsetLeft;
top += parent.offsetTop;
/*
if (parent.tagName.toLowerCase() == 'table' && parent.parentNode && parent.childNodes
&& parent.childNodes.item(0) && parent.parentNode.tagName.toLowerCase() == 'body')
{
for(var j=0; j<parent.childNodes.length; j++)
if (parent.childNodes.item(j).nodeType == parent.childNodes.item(j).ELEMENT_NODE
&& parent.childNodes.item(j).tagName.toLowerCase() == 'tbody')
break;
if (j!=parent.childNodes.length)
{
// alert(parent.childNodes.item(j));
// alert(parent.offsetParent.offsetWidth +' - '+ parent.childNodes.item(j).offsetWidth);
left -= parent.offsetLeft;
left += (parent.offsetParent.offsetWidth - parent.childNodes.item(j).offsetWidth)/2;
}
}
*/
}
}
return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
}catch(e){ }
}