home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 July & August / PCWorld_2005-07-08_cd.bin / komunikace / netscape / nsb-install-8-0.exe / chrome / aim.jar / content / aim / InviteAFriendWizard.js < prev    next >
Text File  |  2004-12-02  |  4KB  |  138 lines

  1. var InviteScreenName = "";
  2. var inviteMsg = "";
  3. var numHits = null;
  4. var queryEmailAddress = null;
  5. var containerArray = new Array();
  6.  
  7.  
  8. var wizardMap = {
  9.   InviteAFriend1: { previous: null,   next:"InviteAFriend1_5",   finish: false },
  10.   InviteAFriend1_5: { previous: "InviteAFriend1",    next: null,    finish: false },
  11.   InviteAFriend2: { previous: "InviteAFriend1", next:null, finish: true },
  12.   InviteAFriend3: { previous: "InviteAFriend1", next:null, finish: true },
  13.   InviteAFriend3_5: { previous: "InviteAFriend1", next:null, finish: true },
  14.   InviteAFriend5: { previous: "InviteAFriend1", next:null, finish: true },
  15. }
  16.  
  17. var profName      = "";
  18. var profDir       = "";
  19. var wizardManager = null;
  20.  
  21.  
  22. function InviteWizardOnload() {
  23.     if (window.arguments[0])
  24.     {
  25.         InviteScreenName=window.arguments[0];
  26.     }
  27.   if (window.arguments[1])
  28.     inviteMsg = window.arguments[1];
  29.       
  30. }
  31.  
  32.  
  33. function Startup( startPage, frame_id )
  34. {
  35.  
  36.   if( frame_id == "" ) {
  37.     dump("Please supply a content_frame ID!");
  38.     return false;
  39.   }
  40.  
  41.   wizardManager                   = new WizardManager( frame_id, null, null, wizardMap );
  42.   wizardManager.URL_PagePrefix    = "chrome://aim/content/";
  43.   wizardManager.URL_PagePostfix   = ".xul";
  44.   wizardManager.SetHandlers(  onNext, null, onFinish, onCancel, null, null );
  45.   wizardManager.LoadPage( startPage, false );
  46. }
  47.  
  48. function onCancel()
  49. {
  50.    window.close();
  51. }
  52.  
  53.  
  54. function onFinish()
  55. {
  56.    if( !wizardManager.wizardMap[wizardManager.currentPageTag].finish )
  57.     return;
  58.    window.close();
  59.  
  60. }
  61.  
  62. function onNext()
  63. {
  64.     var tag =  wizardManager.WSM.GetTagFromURL( wizardManager.content_frame.src, "/", ".xul" );
  65.     wizardManager.WSM.SavePageData( tag, null, null, null );
  66.     var inputemail = wizardManager.WSM.PageData["InviteAFriend1"].emailaddress.value;
  67.     if(inputemail == null)
  68.       return;
  69.     if (checkvalidemail())
  70.     {
  71.         var curPageTag = wizardManager.wizardMap[wizardManager.currentPageTag];
  72.         wizardManager.WSM.SavePageData( curPageTag, null, null, null );
  73.         var nextPageTag = wizardManager.wizardMap[wizardManager.currentPageTag].next;
  74.         wizardManager.LoadPage( nextPageTag, false );  
  75.         wizardManager.ProgressUpdate( ++wizardManager.currentPageNumber );
  76.     }
  77. }
  78.  
  79.  
  80. var invCallback = new Object();
  81.  
  82. invCallback.OnSendInviteComplete = function(emailaddr) 
  83. {
  84.  
  85.     var invitedate= new Date();
  86.     AddToInviteList(emailaddr, invitedate);
  87.     parent.wizardManager.LoadPage('InviteAFriend2',false);
  88. }
  89.  
  90. invCallback.OnSendInviteError = function(emailaddr,pErrMsg) 
  91. {
  92.     if (pErrMsg) {
  93.     parent.wizardManager.LoadPage('InviteAFriend5',false);
  94.     parent.document.getElementById('header').setAttribute('description',pErrMsg);
  95.     return;}
  96.     parent.wizardManager.LoadPage('InviteAFriend3',false);
  97. }
  98.  
  99.  
  100. function checkvalidemail()
  101. {
  102.   var email=parent.wizardManager.WSM.PageData.InviteAFriend1.emailaddress.value;
  103.   var isValid=checkInputEmail(email);
  104.   return isValid;
  105. }
  106.  
  107.  
  108. function cmdInviteBuddy()
  109. {
  110.     var pIIMManager  = aimManager();
  111.     
  112.     if (!pIIMManager)
  113.     {
  114.         return;
  115.     }
  116.     var pIInviteManager=aimInviteManager();
  117.     if (!pIInviteManager)
  118.     {
  119.         return;
  120.     }
  121.     
  122.     var InviteAddress=parent.wizardManager.WSM.PageData.InviteAFriend1.emailaddress.value;
  123.     var InviteMessage=parent.wizardManager.WSM.PageData.InviteAFriend1.greeting.value;
  124.     
  125.     try{
  126.         pIInviteManager.SendInvite(invCallback, InviteAddress, InviteMessage);
  127.     }
  128.     catch (ex) {
  129.     parent.wizardManager.LoadPage('InviteAFriend1',false);   
  130.     }
  131. }
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.