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

  1.  
  2. /*
  3. * Name: CommandUpdate_App
  4. * Arguments: none. 
  5. * Description:
  6. * This function is called by the command update handler. Based on the events you specify this get called.
  7. * Right now it is used only by delete.
  8. * Return Value: none
  9. * Author: Suresh Kasinathan<suresh@netscape.com> 8/29/01
  10. */
  11.  
  12. function CommandUpdate_App()
  13. {
  14.   goUpdateCommand("cmd_delete");
  15.   goUpdateCommand("cmd_buddyalert");
  16.   goUpdateCommand("cmd_editbuddyalert");
  17.   goUpdateCommand("cmd_delbuddyalert");
  18. }
  19.  
  20.  
  21. var AppController =
  22. {
  23.   
  24.   supportsCommand: function(command)
  25.   {
  26.     switch (command) {
  27.       case "cmd_delete":
  28.         return true;
  29.         break;
  30.       case "cmd_buddyalert":  
  31.         if (SetMenuBuddyAlert() == false) {
  32.           var result= getSelectedScreenName();
  33.           var Msg1=top.document.getElementById("cmd_buddyalert").getAttribute("buddyAlertMsg1");
  34.           var Msg2=top.document.getElementById("cmd_buddyalert").getAttribute("buddyAlertMsg2");
  35.           var newlabel=Msg1+result+Msg2;
  36.           top.document.getElementById("menu_buddyAlert").removeAttribute("hidden");
  37.           top.document.getElementById("menu_buddyAlert").setAttribute("label", newlabel);
  38.           goSetAccessKey("cmd_buddyalert", 'buddyAlertAccessKey');
  39.           top.document.getElementById("menu_editAlert").removeAttribute("label");
  40.           top.document.getElementById("menu_delAlert").removeAttribute("label");
  41.           top.document.getElementById("menu_editAlert").setAttribute("hidden", true);
  42.           top.document.getElementById("menu_delAlert").setAttribute("hidden", true);
  43.           return true;
  44.           }
  45.           else 
  46.             return false;
  47.           break;
  48.       case "cmd_editbuddyalert":
  49.           if (SetMenuBuddyAlert() == true) {
  50.              top.document.getElementById("cmd_buddyalert").removeAttribute("label");
  51.              top.document.getElementById("cmd_buddyalert").setAttribute("hidden",true);
  52.              top.document.getElementById("cmd_editbuddyalert").removeAttribute("hidden");
  53.              goSetMenuValue("menu_editAlert", "editbuddyAlert");                 
  54.              goSetAccessKey("cmd_editbuddyalert", "editbuddyAlertAccessKey");
  55.              return true;
  56.           }
  57.           else 
  58.             return false;
  59.         break;
  60.       case "cmd_delbuddyalert":
  61.           if (SetMenuBuddyAlert() == true) {
  62.             var result= getSelectedScreenName();
  63.             var Msg1=top.document.getElementById("cmd_delbuddyalert").getAttribute("delbuddyAlertMsg1");
  64.             var Msg2=top.document.getElementById("cmd_delbuddyalert").getAttribute("delbuddyAlertMsg2");
  65.             var newlabel=Msg1+result+Msg2;
  66.             top.document.getElementById("menu_delAlert").removeAttribute("hidden");
  67.             top.document.getElementById("menu_delAlert").setAttribute("label", newlabel);
  68.             goSetAccessKey("cmd_delbuddyalert", "delbuddyAlertAccessKey");
  69.             return true;
  70.           }
  71.           else 
  72.             return false;
  73.          break;
  74.       case "cmd_sendFile":
  75.         var screenName = getSelectedScreenName();
  76.         if (aimBuddyIsOnline(screenName)) {
  77.             top.document.getElementById("menu_sendFile").removeAttribute("hidden");
  78.             top.document.getElementById("menu_sendFileSep").removeAttribute("hidden");
  79.         }
  80.         else
  81.         {
  82.             top.document.getElementById("menu_sendFile").setAttribute("hidden", true);
  83.             top.document.getElementById("menu_sendFileSep").setAttribute("hidden", true);
  84.         }
  85.       default:
  86.         return true;
  87.     }
  88.   },
  89.  
  90.   isCommandEnabled: function(command)
  91.   {
  92.     switch (command) {
  93.       case "cmd_delete":
  94.         return true;
  95.         break;
  96.       case "cmd_buddyalert":
  97.         return true;
  98.         break;
  99.       case "cmd_delbuddyalert":
  100.         return true;
  101.         break;
  102.       case "cmd_editbuddyalert":
  103.         return true;
  104.         break;
  105.       default:
  106.         return true;
  107.     }
  108.   },
  109.  
  110.   doCommand: function(command)
  111.   {
  112.     switch (command) {
  113.       case "cmd_delete":
  114.         cmdDelete();
  115.         break;
  116.       case "cmd_buddyalert":
  117.         cmdBuddyAlert();
  118.         break;
  119.       case "cmd_editbuddyalert":
  120.         cmdBuddyAlert();
  121.         break;
  122.     }
  123.   },
  124.  
  125.   onEvent: function(event)
  126.   {
  127.      dump("Nothing for now ...\n");
  128.   }
  129. };
  130.  
  131. /*
  132. * Name: SetupCommandUpdateHandlers
  133. * Arguments: none. 
  134. * Description:
  135. * This function initializes command update handler. This is called by AppSessionObserver.
  136. * Return Value: none
  137. * Author: Suresh Kasinathan<suresh@netscape.com> 8/29/01
  138. */
  139.  
  140. function AimSetupCommandUpdateHandlers()
  141. {
  142.   var sidebarframe=getsidebarframe();
  143.   var onlineTree;
  144.   var listsetupTree;
  145.   if (sidebarframe) {
  146.     onlineTree = sidebarframe.document.getElementById("OnlineBuddies");
  147.     listsetupTree = sidebarframe.document.getElementById("ListSetup");
  148.   }
  149.   else {
  150.     onlineTree = document.getElementById("OnlineBuddies");
  151.     listsetupTree = document.getElementById("ListSetup");
  152.   }
  153.   
  154.   if (onlineTree) {
  155.     onlineTree.controllers.appendController(AppController);
  156.   }
  157.  
  158.   if (listsetupTree) {
  159.     listsetupTree.controllers.appendController(AppController);
  160.   }
  161. }
  162.  
  163. /*
  164. * Name: onSelectionChange
  165. * Arguments: none. 
  166. * Description:
  167. * This function is called whenever the selection changes in Online tree and list setup tree. 
  168. * Return Value: none
  169. * Author: Suresh Kasinathan<suresh@netscape.com> 8/29/01
  170. */
  171.  
  172. function onSelectionChange(event) {
  173.   goUpdateCommand("cmd_delete");
  174.   goUpdateCommand("cmd_sendFile");
  175.   onItemFocus(event);
  176. }
  177.  
  178. function onItemFocus(event) {
  179.   goUpdateCommand("cmd_buddyalert");
  180.   goUpdateCommand("cmd_editbuddyalert");
  181.   goUpdateCommand("cmd_delbuddyalert");
  182.   goUpdateCommand("cmd_sendFile");
  183. }
  184.  
  185.  
  186. /*
  187. * Name: SetMenuBuddyAlert
  188. * Arguments: none. 
  189. * Description:
  190. * This function is called to check if the selected screen name is in alert list and show the appropriate alert 
  191. * menu. Do not show menu is a specific screen name was not selected.
  192. * Return Value: screenName
  193. * Author: Prassanna<prass@netscape.com> 
  194. */
  195.  
  196. function SetMenuBuddyAlert() {
  197.       var scrName = getSelectedScreenName();
  198.       if (!scrName  || scrName == null) {
  199.         //remove the buddy alert menu item from people Menu if no screen name was selected
  200.         top.document.getElementById("menu_buddyAlert").removeAttribute("label");
  201.         top.document.getElementById("menu_buddyAlert").setAttribute("hidden", true);
  202.         // Do not set buddy alert menu item (mutiple select or screen name was null);
  203.         return false;
  204.       }
  205.       var isInList = new Object();
  206.       aimBuddyManager().IsBuddyInAlertList(scrName, isInList);
  207.       return isInList.value;
  208. }
  209.  
  210.  
  211.