home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 May / Chip_2001-05_cd2.bin / ChipCD / browsery / msie6_beta / iew2k_1.cab / browselc.dll / HTML / IBARMGR.JS < prev    next >
Encoding:
JavaScript  |  2000-11-13  |  5.3 KB  |  251 lines

  1. //
  2. // Global variables shared with the other pages
  3. //
  4.  
  5.  
  6. //
  7. // Methods shared with the other pages
  8. //
  9. function BodyOnKeyPress(nCode)
  10. {
  11.   if (nCode == 27)  //ESC
  12.   {
  13.     window.close();
  14.     return;
  15.   }
  16. }
  17.  
  18. function GetText(oTextInput)
  19. {
  20.   var szValue = oTextInput.value;
  21.   return (szValue && szValue != oTextInput.initialText) ? szValue : '';
  22. }
  23.  
  24. function PopulateLeftPane(szRelatedTasks, szLearnAbout, szDescription)
  25. {
  26.   idDescription.innerHTML = szDescription ? szDescription : '';
  27.  
  28.   if (szRelatedTasks && szRelatedTasks.length > 0)
  29.   {
  30.     idRelatedTaskLinks.innerHTML = szRelatedTasks;
  31.     idRelatedTasks.style.display = 'block';
  32.   }
  33.   else
  34.     idRelatedTasks.style.display = 'none';
  35.  
  36.   if (szLearnAbout && szLearnAbout.length > 0)
  37.   {
  38.     idLearnAboutLinks.innerHTML = szLearnAbout;
  39.     idLearnAbout.style.display = 'block';
  40.   }
  41.   else
  42.     idLearnAbout.style.display = 'none';
  43. }
  44.  
  45.  
  46. //
  47. // Methods specific to the main frame
  48. //
  49.  
  50.  
  51. function PageInit()
  52. {
  53.   // Initialize globals
  54.   g_Navigator = new Navigator(idContent);
  55.   if (g_Navigator)
  56.   {
  57.     var ibarOC = window.dialogArguments;
  58.     var ibarStart = ibarOC.start;
  59.     if (ibarStart=="")
  60.     {
  61.       g_Navigator.navigate("mainpage.htm");
  62.     }
  63.     else
  64.     {
  65.       g_Navigator.navigate("settings.htm");
  66.     }
  67.   }
  68. }
  69.  
  70. // Since this is a web page the user can select elements on the
  71. // page. Since this is an app, selecting element is undesireable.
  72. // Therefore we catch the start of a selection event and cancel it.
  73. function OnSelectStart()
  74. {
  75.   // We still want to be able to select text in entry fields though.
  76.   if (!event.srcElement.isTextEdit)
  77.     event.returnValue = false;
  78. }
  79.  
  80.  
  81. //
  82. // Navigator object implementation
  83. //
  84. var g_Navigator = null;
  85.  
  86. function push(url)
  87. {
  88.   if (url)
  89.   {
  90.     if (this.current < 0 || url != this.stack[this.current])
  91.       this.stack[++this.current] = url;
  92.  
  93.     // Make sure there's nothing left on the stack after this
  94.     this.stack.length = this.current + 1;
  95.   }
  96. }
  97.  
  98. function navigate(urlTo, bTrim)
  99. {
  100.   // Check for empty stack
  101.   if (this.current < 0)
  102.     bTrim = false;
  103.  
  104.   if (bTrim)
  105.   {
  106.   // Look backwards for the page, trimming as we go
  107.     while (this.current >= 0)
  108.     {
  109.     // Trim the stack to the current location
  110.       this.stack.length = this.current + 1;
  111.  
  112.     // Is the page here on the stack?
  113.       if (urlTo == this.stack[this.current])
  114.         break;
  115.  
  116.       if (0 == this.current)
  117.       {
  118.         // Got all the way back to the beginning and didn't
  119.         // find it.  Push it and stop.
  120.         this.push(urlTo);
  121.         break;
  122.       }
  123.  
  124.       --this.current;
  125.     }
  126.   }
  127.   else
  128.   {
  129.   // Normal navigation
  130.     this.push(urlTo);
  131.   }
  132.  
  133.   this.SetBtnState();
  134.   this.frame.navigate(urlTo);
  135. }
  136.  
  137. function back(nCount)
  138. {
  139.   if (this.current > 0)
  140.   {
  141.     if (!nCount)
  142.       nCount = 1;
  143.  
  144.     if (-1 == nCount)
  145.       this.current = 0;
  146.     else
  147.       this.current = Math.max(0, this.current - nCount);
  148.  
  149.     this.frame.navigate(this.stack[this.current]);
  150.   }
  151.   this.SetBtnState();
  152. }
  153.  
  154. function forward()
  155. {
  156.   if (this.current < this.stack.length - 1)
  157.     this.frame.navigate(this.stack[++this.current]);
  158.   this.SetBtnState();
  159. }
  160.  
  161. function SetBtnState()
  162. {
  163.   idBackBtn.disabled = (this.current <= 0);
  164.   if (idBackBtn.disabled)
  165.     idBackBtn.src = "back.bmp";
  166.  
  167.   idForwardBtn.disabled = (this.current == this.stack.length - 1);
  168.   if (idForwardBtn.disabled)
  169.     idForwardBtn.src = "fwd.bmp";
  170.  
  171.   idHomeBtn.disabled = (this.current <= 0);
  172.   if (idHomeBtn.disabled)
  173.     idHomeBtn.src = "home.bmp";
  174. }
  175.  
  176. function UpdateSelection()
  177. {
  178.   var ibarOC = window.dialogArguments;
  179.  
  180.   var iCount = ibarOC.count;
  181.   var newHTML = "";
  182.  
  183.   if (iCount==0)
  184.   {
  185.     newHTML = "<I>There are currently no items on your Show menu</i>";
  186.   }
  187.   else if (iCount==1)
  188.   {
  189.     newHTML = "<I>Item currently on your Show menu</i><br><br>" + ibarOC.item(0).title;
  190.   }
  191.   else
  192.   {
  193.     newHTML = "<I>Items currently on your Show menu</i><br><br>";
  194.     for (var i=0; i < iCount - 1; i++)
  195.     {
  196.       var itemClsid = ibarOC.item(i);
  197.       newHTML = newHTML + itemClsid.title + ", ";
  198.     }
  199.     newHTML = newHTML + "and " + ibarOC.item(i).title;
  200.   }
  201. //  idSelection.innerHTML = newHTML; 
  202. }
  203.  
  204. function UpdateStack()
  205. {
  206.   var ibarOC = window.dialogArguments;
  207.   var ibarStack  = ibarOC.stack;
  208.   var iCount = ibarStack.count;
  209.   var newHTML = "";
  210.  
  211.   if (iCount==0)
  212.   {
  213.     newHTML = "<I>There are currently no items on My Bar</i>";
  214.   }
  215.   else if (iCount==1)
  216.   {
  217.     newHTML = "<I>Item currently on My Bar</i><br><br>" + ibarStack.item(0).title;
  218.   }
  219.   else
  220.   {
  221.     newHTML = "<I>Items currently on My Bar</i><br><br>";
  222.     for (var i=0; i < iCount - 1; i++)
  223.     {
  224.       var itemClsid = ibarStack.item(i);
  225.       newHTML = newHTML + itemClsid.title + ", ";
  226.     }
  227.     newHTML = newHTML + "and " + ibarStack.item(i).title;
  228.   }
  229. //  idSelection.innerHTML = newHTML; 
  230. }
  231.  
  232. function Navigator(frame)
  233. {
  234.   // methods
  235.   this.push = push;
  236.   this.navigate = navigate;
  237.   this.back = back;
  238.   this.forward = forward;
  239.   this.SetBtnState = SetBtnState;
  240.   this.UpdateSelection = UpdateSelection;
  241.   this.UpdateStack = UpdateStack;
  242.     
  243.   // properties
  244.   this.frame = frame;
  245.   this.current = -1;
  246.   this.stack = new Array();
  247.  
  248.   this.SetBtnState();
  249. }
  250.  
  251.