home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 December
/
PCWorld_2006-12_cd.bin
/
komunikace
/
netscape
/
nsb-install-8-1-2.exe
/
chrome
/
aim.jar
/
content
/
aim
/
BuddyAddBuddy.js
< prev
next >
Wrap
Text File
|
2006-01-06
|
3KB
|
102 lines
var RDF = aimRDF();
var aim = aimRDFDataSource();
var containerClass = Components.classes['@mozilla.org/rdf/container;1'];
var container = containerClass.createInstance(Components.interfaces.nsIRDFContainer);
container.Init(aim, RDF.GetResource("NC:AIM/BuddyList"));
function BuildGroupFrame(groupName)
{
var a = new Array();
var i = 0;
top.a = a;
var enumerator = container.GetElements();
while (enumerator.hasMoreElements()) {
var element = enumerator.getNext();
var resource = element.QueryInterface(Components.interfaces.nsIRDFResource);
dump( "Element is " + element + "\n" );
dump( "Resource is " + resource + "\n" );
var attr = aim.GetTarget(resource,
RDF.GetResource("http://home.netscape.com/NC-rdf#Name"), true);
if (attr)
attr = attr.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (attr) {
attr = attr.Value;
a[ i ] = attr;
i = i + 1;
}
}
CreateGroupList( a, groupName );
}
function GroupSelected(groupName)
{
top.groupSelected = groupName;
}
function CreateGroupList( a, groupName )
{
listDocument = document.getElementById("AddBuddyGroupPopup")
var selectedIndexHere = 0;
for ( var i=0; i < a.length; i++ ) {
chkboxname = "checkBox" + a[i];
outputElement = document.createElement('menuitem');
outputElement.setAttribute('id',chkboxname);
outputElement.setAttribute('name',a[i]);
outputElement.setAttribute('label',a[i]);
if (groupName) {
for (var j=0; j<groupName.length; j++) {
if (a[i] == groupName[j]) {
outputElement.setAttribute("selected", "true");
selectedIndexHere = i;
}
}
}
listDocument.appendChild(outputElement)
document.getElementById("AddBuddyGroupDrop").selectedIndex = selectedIndexHere;
GroupSelected(document.getElementById("AddBuddyGroupDrop").selectedItem.getAttribute('name'));
}
}
function GetCheckBoxState( a, i )
{
chkboxname = "checkBox" + a[i];
chkbox = document.getElementById(chkboxname);
return( chkbox.checked || chkbox.getAttribute("selected"));
}
// for later
function FindSelectedGroup()
{
// Locate selection in setup list
// XXX There must be a better way to do this
var selectedGroup = null;
var tree = window.tree;
var groups = tree.childNodes[2].childNodes;
for (var i = 0; i != groups.length; i++) {
if (groups[i].getAttribute("selected") == "true") {
selectedGroup = groups[i].getAttribute("Name");
break;
}
}
return( selectedGroup );
}
function FindBuddySelected( group, tree )
{
var buddyList;
if ( tree )
buddyList = tree.selectedItems;
if ( !buddyList || buddyList.length != 1 )
return null;
return( buddyList[0].getAttribute("Name") );
}