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 / chatPanel.js < prev    next >
Text File  |  2006-01-06  |  5KB  |  155 lines

  1.  
  2.  
  3. //create template for user management.
  4. function chatPanelObj()
  5. {
  6.   this.chatPanelAddScreenName = chatPanelAddScreenName;
  7.   this.chatPanelRemoveScreenName = chatPanelRemoveScreenName;
  8.   this.chatPanelUpdateScreenName = chatPanelUpdateScreenName;
  9.   return this;
  10. }
  11.  
  12. myChatPanel = new chatPanelObj()
  13.  
  14. function chatPanelOnWinLoad()
  15. {
  16.   try {
  17.     if(parent.myManager && parent.chatPanelLoaded) {
  18.       for(z=0;z<parent.myManager.members.length;z++)
  19.         chatPanelUpdateScreenName(parent.myManager.members[z].screenName,parent.myManager.members[z].status)
  20.     }
  21.   }
  22.   catch (e) {
  23.     dump("chatPanelOnWinLoad : couldnt find parent.myManager (caught exception) \n");
  24.   }
  25.  
  26.   parent.chatPanelLoaded=true;
  27. }
  28.  
  29. function chatPanelAddScreenName(screenName,initialState)
  30. {
  31.   var listbox = document.getElementById("chatPanelTree");
  32.   listitem=document.createElement("listitem");
  33.   listitem.setAttribute('label',screenName)
  34.   listitem.setAttribute('class',initialState);
  35.   listbox.appendChild(listitem)
  36.     
  37.   top.updateMemberCount();
  38.   top.chatContentStatusChange(screenName,initialState)
  39.  
  40.   if(listbox.childNodes.length == 1) {
  41.     //Im the first person here! Select me
  42.     document.getElementById("chatPanelTree").selectedIndex=0;
  43.     }
  44. }
  45.  
  46. function chatPanelRemoveScreenName(screenName)
  47. {
  48.   var listbox  = document.getElementById("chatPanelTree");
  49.   var listitems = listbox.getElementsByTagName("listitem");
  50.   var theDoomedScreenName = null;
  51.   var theDoomedScreenNameWasSelected = false;
  52.  
  53.   for (k=0; k < listitems.length; k++) {
  54.     if (listitems[k].getAttribute("label").toLowerCase() == screenName.toLowerCase())
  55.       theDoomedScreenName = listitems[k];
  56.   }
  57.  
  58.   if(theDoomedScreenName != null) {
  59.     if(theDoomedScreenName.selected) {
  60.       theDoomedScreenNameWasSelected = true;
  61.     }
  62.   
  63.     listbox.removeChild(theDoomedScreenName)
  64.     top.updateMemberCount();
  65.     top.chatContentStatusChange(screenName,"has left")
  66.   }
  67.  
  68.   if (theDoomedScreenNameWasSelected) {
  69.     //it was selected - reset selection now 
  70.     //dont need to check for 0 because if it's zero - you'd not be in the chatroom yourself
  71.     listbox.selectedIndex= 0 ;
  72.   }
  73.  
  74. }
  75.  
  76. //update the status of a given screenname
  77. function chatPanelUpdateScreenName(screenName,snStatus)
  78. {
  79.   var theTreeChildren = document.getElementsByTagName("listitem");
  80.   var theSNtoUpdate= null;
  81.   for (j=0; j<theTreeChildren.length; j++) {
  82.     if(aimIsSameScreenName(theTreeChildren.item(j).getAttribute("label"), screenName)) {
  83.       theSNtoUpdate = theTreeChildren.item(j);
  84.     }
  85.   }
  86.  
  87.   if(theSNtoUpdate!=null) {
  88.     theSNtoUpdate.setAttribute("class",snStatus);
  89.  
  90.         // in case its formatting has changed
  91.     theSNtoUpdate.setAttribute("label", screenName);
  92.     top.updateMemberCount();
  93.     top.chatContentStatusChange(screenName,snStatus)
  94.   }
  95.   else {
  96.     chatPanelAddScreenName(screenName,snStatus)
  97.   }
  98. }
  99.  
  100.  
  101. function cmdUserSelected(e)
  102. {
  103.   document.getElementById("userSelected").setAttribute("disabled","false")
  104.   var theTree = document.getElementById("chatPanelTree")
  105.   if(theTree.selectedItems.length >=1 ) {
  106.     document.getElementById("userSelected").setAttribute("selectedScreenName",theTree.selectedItems[0].getAttribute("label"))
  107.     document.getElementById("userSelected").setAttribute("disabled","false");
  108.   }
  109.   if(theTree.selectedItems.length==0) {
  110.     document.getElementById("userSelected").setAttribute("disabled","true")
  111.     document.getElementById("userSelected").setAttribute("selectedScreenName",'')
  112.   }
  113. }
  114.  
  115. function cmdSendIMFromChat()
  116. {
  117.   var theTree = document.getElementById("chatPanelTree")
  118.   if(theTree.selectedItems.length>=1) {
  119.     var selectedScreenName = cmdGetSelectedScreenName(); 
  120.     aimIMInvokeIMForm(selectedScreenName);
  121.   }
  122.   else
  123.     aimIMInvokeIMForm(null, null);
  124. }
  125.  
  126. function cmdIgnoreFromChat() 
  127. {
  128.   var theTree = document.getElementById("chatPanelTree")
  129.   var i;
  130.   for (i = 0; i < theTree.selectedItems.length; i++) {
  131.     var selectedScreenName =theTree.selectedItems[i].getAttribute("label");
  132.     var wasIgnored = top.chatRoomObj.Ignore(selectedScreenName);
  133.     if (wasIgnored)
  134.       top.frames['chatpanel'].chatPanelUpdateScreenName(selectedScreenName, "joined");
  135.     else
  136.       top.frames['chatpanel'].chatPanelUpdateScreenName(selectedScreenName, "ignored");
  137.   }
  138. }
  139.  
  140. function cmdGetSelectedScreenName()
  141. {
  142.   return document.getElementById("userSelected").getAttribute("selectedScreenName")
  143. }
  144.  
  145. function cmdUserBlurred(e)
  146. {
  147.   //I'm an empty fn and I don't do any useful thing.
  148.   //document.getElementById("userSelected").setAttribute("disabled","true");
  149. }
  150.  
  151.  
  152.  
  153.  
  154.  
  155.