home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 October / CHIP1002.ISO / exe / COMPUGUI.exe / whframes.js < prev    next >
Encoding:
Text File  |  2002-04-23  |  2.0 KB  |  78 lines

  1. // this value should be identical to the value used in whproxy.js
  2. window.whname = "wh_stub";
  3.  
  4. // this file will be used by Topic and NavBar and NavPane and other components
  5. // and this file is used in child frame html.
  6. // and the whstub.js will be used in the start page.
  7. // see reference in whstub.js.
  8. // Internal Area
  9. var gbInited = false;
  10. var gWndStubPage = null;
  11. function getStubPage()
  12. {
  13.     if (!gbInited)
  14.     {
  15.         gWndStubPage = getStubPage_inter(window);
  16.         gbInited = true;
  17.     }
  18.     return gWndStubPage;
  19. }
  20.  
  21. function getStubPage_inter(wCurrent) {
  22.     if (null == wCurrent.parent || wCurrent.parent == wCurrent)
  23.         return null;
  24.  
  25.     if (wCurrent.parent.whname && "wh_stub" == wCurrent.parent.whname) 
  26.         return wCurrent.parent;
  27.     else
  28.         if (wCurrent.parent.frames.length != 0 && wCurrent.parent != wCurrent)
  29.             return getStubPage_inter(wCurrent.parent);
  30.         else 
  31.             return null;
  32. }
  33.  
  34. // Public interface begin here................
  35. function RegisterListener(framename, nMessageId)
  36. {
  37.     var wStartPage = getStubPage();
  38.     if (wStartPage && wStartPage != this) {
  39.         return wStartPage.RegisterListener(framename, nMessageId);
  40.     }
  41.     else 
  42.         return false;
  43. }
  44.  
  45. function RegisterListener2(oframe, nMessageId)
  46. {
  47.     var wStartPage = getStubPage();
  48.     if (wStartPage && wStartPage != this) {
  49.         return wStartPage.RegisterListener2(oframe, nMessageId);
  50.     }
  51.     else 
  52.         return false;
  53. }
  54.  
  55. function UnRegisterListener2(oframe, nMessageId)
  56. {
  57.     var wStartPage = getStubPage();
  58.     if (wStartPage && wStartPage != this && wStartPage.UnRegisterListener2) {
  59.         return wStartPage.UnRegisterListener2(oframe, nMessageId);
  60.     }
  61.     else 
  62.         return false;
  63. }
  64.  
  65. function SendMessage(oMessage)
  66. {
  67.     var nMsgId = oMessage.nMessageId;
  68.     if (nMsgId == WH_MSG_ISINFRAMESET && oMessage.wSender != this)
  69.         return true;
  70.     var wStartPage = getStubPage();
  71.     if (wStartPage && wStartPage != this && wStartPage.SendMessage) 
  72.     {
  73.         return wStartPage.SendMessage(oMessage);
  74.     }
  75.     else 
  76.         return false;
  77. }
  78. var gbWhProxy=true;