home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2001 March / PCpro_2001_03.ISO / tipps / winfaq / faqhtml / faq_html / hbhelp.js < prev    next >
Encoding:
JavaScript  |  1999-10-13  |  4.8 KB  |  251 lines

  1.  
  2. // global variables
  3. var        wndCount = 0;
  4. var        curXPos = 0;
  5. var     curYPos = 0;
  6. var        wnd = null;
  7. var        ht_loc = "";
  8. var        curr_frames = new Array (5);
  9.  
  10. // functions
  11.  
  12.  
  13. function OpenWindow (file, width, height, x_pos, y_pos, wndname) {
  14.  
  15.     var        name, cc, temp = "";
  16.  
  17.     if (width == 0)
  18.         width = 250;
  19.     
  20.     if (height == 0)
  21.         height = 100;
  22.  
  23.     // adjust x and y to fit on screen
  24.     if (SupportsDHTML ()) {
  25.         if (x_pos < screen.width) {
  26.             if (x_pos + width > (screen.width - 15))
  27.                 x_pos -= (x_pos + width) - (screen.width - 15)
  28.             }
  29.         else {    // assume 2nd monitor
  30.             if (x_pos + width > ((screen.width * 2) - 15))
  31.                 x_pos -= (x_pos + width) - ((screen.width * 2) - 15)
  32.             }
  33.  
  34.         if (y_pos + height > (screen.height - 60))
  35.             y_pos -= (y_pos + height) - (screen.height - 60)
  36.         }
  37.  
  38.     if (wndname == "") {
  39.         name = file.substring (0, file.indexOf ("."));
  40.         name += wndCount;
  41.         wndCount++;
  42.         }
  43.     else
  44.         name = wndname;
  45.     
  46.     // take all invalid chars out of name
  47.     for (i = 0; i < name.length; i++) {
  48.         cc = name.substring (i, i+1);
  49.         if ((cc >= 'a' && cc <= 'z') || (cc >= 'A' && cc <= 'Z') && (cc >= '0' && cc <= '9'))
  50.             temp += cc;
  51.         else {
  52.             val = parseInt (cc);
  53.             if (val >= 0 || val <= 9)
  54.                 temp += cc;
  55.             else
  56.                 temp += "_";
  57.             }
  58.         }
  59.  
  60.     name = temp;
  61.  
  62.     if (FullDHTML () == 1)
  63.         wnd = open (file, name, 'width=' + width + ',height=' + height + ',left=' + x_pos + ',top=' + y_pos + ',resizable=1,scrollbars=1')        
  64.     else if (PartialDHTML () == 1)
  65.         wnd = open (file, name, 'width=' + width + ',height=' + height + ',screenX=' + x_pos + ',screenY=' + y_pos + ',resizable=1,scrollbars=1')        
  66.     else
  67.         wnd = open (file, name, 'width=' + width + ',height=' + height + ',resizable=1,scrollbars=1')
  68.  
  69.     if (wndname != "") {
  70.         if (GetBrowser () == 0)    // netscape
  71.             wnd.focus ();
  72.         else {
  73.             if (FullDHTML ()) {
  74.                 test = wnd.location;    // this seems to make the window available
  75.                 wnd.focus ();
  76. //                setTimeout ("wnd.focus ()", 1000);
  77.                 }
  78.             }
  79.         }
  80.     }
  81.  
  82.  
  83. function SaveMousePos (evnt) {
  84.  
  85.     if (FullDHTML ()) {
  86.         curXPos = window.event.screenX;
  87.         curYPos = window.event.screenY;
  88.         }
  89.     else if (PartialDHTML ()) {
  90.         curXPos = evnt.screenX;
  91.         curYPos = evnt.screenY;
  92.         }
  93.     else
  94.         curXPos = curYPos = 0;
  95.     }
  96.  
  97.  
  98. function ShowPopup (file, width, height) {
  99.     OpenWindow (file, width, height, curXPos, curYPos, "");
  100.     }
  101.  
  102.  
  103. function ShowSecWindow (file, wndname) {
  104.  
  105.     var     width, height;
  106.     var        x_pos, y_pos;
  107.     var        data, caption;
  108.     var        i, str;
  109.  
  110.     // parse window data to caption, x, y, width, height
  111.     data = windows[wndname];
  112.  
  113.     // first parse off caption
  114.     i = data.indexOf (',');
  115.     caption = data.substring (0, i);
  116.     data = data.substring (i + 1);
  117.  
  118.     // parse off x pos
  119.     i = data.indexOf (',');
  120.     str = data.substring (0, i);
  121.     x_pos = parseInt (str);
  122.     data = data.substring (i + 1);
  123.  
  124.     // parse off y pos
  125.     i = data.indexOf (',');
  126.     str = data.substring (0, i);
  127.     y_pos = parseInt (str);
  128.     data = data.substring (i + 1);
  129.  
  130.     // parse off width
  131.     i = data.indexOf (',');
  132.     str = data.substring (0, i);
  133.     width = parseInt (str);
  134.     data = data.substring (i + 1);
  135.  
  136.     // height is left
  137.     height = parseInt (data);
  138.  
  139.     OpenWindow (file, width, height, x_pos, y_pos, wndname);
  140.     }
  141.  
  142.  
  143. function ShowHideObject (val) {
  144.  
  145.     var        e;
  146.  
  147.     if (FullDHTML ()) {
  148.         e = eval (val);
  149.         if (e.style.visibility == "hidden")
  150.             e.style.visibility = "visible";
  151.         else
  152.             e.style.visibility = "hidden";
  153.         }
  154.     else if (PartialDHTML ()) {
  155.         e = eval ("document." + val);
  156.         if (e.visibility == "hide")
  157.             e.visibility = "show";
  158.         else
  159.             e.visibility = "hide";
  160.         }
  161.     }
  162.  
  163.  
  164.  
  165. function SetPopupDuration (val) {
  166.  
  167.     if (val == 0)
  168.         val = 120000;
  169.     else
  170.         val = val * 1000;
  171.     
  172.     if (SupportsDHTML () == 0 && GetBrowser () == 1)    // ie3.0
  173.         setTimeout ("self.close ()", val);        // 2 minutes by default
  174.     }
  175.  
  176.  
  177. function SaveSubFrames () {
  178.  
  179.     for (i = 0; i < 5; i++) {
  180.         if (parent.frames['subframe'].frames.length > i) {
  181.             if (parent.frames['subframe'].frames[i].document) {
  182.                 curr_frames[i] = parent.frames['subframe'].frames[i].name;
  183.                 }
  184.             else
  185.                 curr_frames[i] = "";
  186.             }
  187.         else
  188.             curr_frames[i] = "";
  189.         }
  190.     }
  191.  
  192.  
  193. function FindFrame (name) {
  194.  
  195.     for (i = 0; i < curr_frames.length; i++)  {
  196.         if (curr_frames[i] == name)
  197.             return i;
  198.         }
  199.  
  200.     return -1;
  201.     }
  202.  
  203.  
  204. function ShowNavPane () {
  205.  
  206.     SaveSubFrames ();
  207.  
  208.     if (IsHidden ()) {
  209.         if (IsOldBrowser ())
  210.             return 0;
  211.  
  212.         ToggleNavPane ();
  213.         return 1;
  214.         }
  215.  
  216.     return 1;
  217.     }
  218.  
  219.  
  220. function IsHidden () {
  221.  
  222.     if (FindFrame ("hlptopics") == -1)
  223.         return 1;
  224.     return 0;
  225.     }
  226.  
  227.  
  228. function Back () {
  229.     
  230.     var            num;
  231.  
  232.     SaveSubFrames ();
  233.  
  234.     num = FindFrame ("content");
  235.     if (num != -1)            
  236.         parent.frames['subframe'].frames[num].history.back ();
  237.     }
  238.  
  239.  
  240. function Forward () {
  241.     
  242.     var            num;
  243.  
  244.     SaveSubFrames ();
  245.  
  246.     num = FindFrame ("content");
  247.     if (num != -1)
  248.         parent.frames['subframe'].frames[num].history.forward ();
  249.     }
  250.  
  251.