home *** CD-ROM | disk | FTP | other *** search
/ Thomson (Residential) / TGSTPv7203.iso / mac / Documentation / HTML / TG787v_es / wwhelp / wwhimpl / common / scripts / switch.js < prev   
Text File  |  2007-06-22  |  5KB  |  236 lines

  1. // Copyright (c) 2000-2001 Quadralay Corporation.  All rights reserved.
  2. //
  3.  
  4. function  WWHSwitch_Object()
  5. {
  6.   this.mParameters = "";
  7.   this.mbSingle    = false;
  8.   this.mbForceJS   = false;
  9.   this.mSettings   = new WWHCommonSettings_Object();
  10.  
  11.   this.fExec        = WWHSwitch_Exec;
  12.   this.fProcessURL  = WWHSwitch_ProcessURL;
  13.   this.fJavaEnabled = WWHSwitch_JavaEnabled;
  14.   this.fJavaCapable = WWHSwitch_JavaCapable;
  15.   this.fSwitch      = WWHSwitch_Switch;
  16. }
  17.  
  18. function  WWHSwitch_Exec(bParamNormalizeURL,
  19.                          ParamURL)
  20. {
  21.   var  TargetURL   = ParamURL;
  22.   var  bUseJava    = false;
  23.   var  FrameSetURL = "";
  24.  
  25.  
  26.   // Normalize URL if necessary
  27.   //
  28.   if (bParamNormalizeURL)
  29.   {
  30.     TargetURL = WWHStringUtilities_NormalizeURL(ParamURL);
  31.   }
  32.  
  33.   // Process parameters
  34.   //
  35.   this.fProcessURL(TargetURL);
  36.  
  37.   // Use single frame if specified
  38.   //
  39.   if (this.mbSingle)
  40.   {
  41.     FrameSetURL = "../../common/html/wwhelp.htm";
  42.   }
  43.   else
  44.   {
  45.     // Determine if Java version can be used
  46.     //
  47.     if (this.mbForceJS)
  48.     {
  49.       bUseJava = false;
  50.     }
  51.     else if (this.mSettings.mbForceJavaScript)
  52.     {
  53.       bUseJava = false;
  54.     }
  55.     else
  56.     {
  57.       // See if Java is enabled
  58.       //
  59.       if (this.fJavaEnabled())
  60.       {
  61.         bUseJava = this.fJavaCapable();
  62.       }
  63.     }
  64.  
  65.     // Pick frameset to use
  66.     //
  67.     if (bUseJava)
  68.     {
  69.       FrameSetURL = "../../java/html/wwhelp.htm";
  70.     }
  71.     else
  72.     {
  73.       FrameSetURL = "../../js/html/wwhelp.htm";
  74.     }
  75.   }
  76.  
  77.   // Switch to frameset
  78.   //
  79.   this.fSwitch(FrameSetURL);
  80. }
  81.  
  82. function  WWHSwitch_ProcessURL(ParamURL)
  83. {
  84.   this.mParameters = "";
  85.   this.mbForceJS   = false;
  86.  
  87.   if (ParamURL.indexOf("?") != -1)
  88.   {
  89.     var  Parts;
  90.     var  Parameters;
  91.  
  92.  
  93.     Parts = ParamURL.split("?");
  94.     Parameters = Parts[1];
  95.  
  96.     if (Parameters.indexOf("&") != -1)
  97.     {
  98.       var  MaxIndex;
  99.       var  Index;
  100.  
  101.  
  102.       // Reset parameters to drop single and forcejs if present
  103.       //
  104.       this.mParameters = "";
  105.  
  106.       Parts = Parameters.split("&");
  107.       for (MaxIndex = Parts.length, Index = 0 ; Index < MaxIndex ; Index++)
  108.       {
  109.         if (Parts[Index] == "single=true")
  110.         {
  111.           this.mbSingle = true;
  112.         }
  113.         else if (Parts[Index] == "forcejs=true")
  114.         {
  115.           this.mbForceJS = true;
  116.         }
  117.         else
  118.         {
  119.           if (this.mParameters.length > 0)
  120.           {
  121.             this.mParameters += "&";
  122.           }
  123.  
  124.           this.mParameters += Parts[Index];
  125.         }
  126.       }
  127.     }
  128.     else if (Parameters == "single=true")
  129.     {
  130.       this.mParameters = "";
  131.       this.mbSingle    = true;
  132.     }
  133.     else if (Parameters == "forcejs=true")
  134.     {
  135.       this.mParameters = "";
  136.       this.mbForceJS   = true;
  137.     }
  138.     else
  139.     {
  140.       this.mParameters = Parameters;
  141.     }
  142.  
  143.     // Prefix parameters with "?" if parameters exist
  144.     //
  145.     if (this.mParameters.length > 0)
  146.     {
  147.       this.mParameters = "?" + this.mParameters;
  148.     }
  149.   }
  150. }
  151.  
  152. function  WWHSwitch_JavaEnabled()
  153. {
  154.   var  bJavaEnabled = false;
  155.  
  156.  
  157.   // Check if Java is enabled
  158.   //
  159.   if ((typeof navigator != "undefined") &&
  160.       (navigator != null))
  161.   {
  162.     bJavaEnabled = navigator.javaEnabled();
  163.   }
  164.  
  165.   return bJavaEnabled;
  166. }
  167.  
  168. function  WWHSwitch_JavaCapable()
  169. {
  170.   var  bJavaCapable = false;
  171.   var  Browser  = WWHFrame.WWHBrowserInfo.mBrowser;
  172.   var  Platform = WWHFrame.WWHBrowserInfo.mPlatform;
  173.  
  174.  
  175.   // Determine if platform supports Java version
  176.   //
  177.   if (Browser == 1)  // Shorthand for Netscape
  178.   {
  179.     if (Platform == 1)  // Shorthand for Windows
  180.     {
  181.       bJavaCapable = true;  // Java works on NS for Windows
  182.     }
  183.     else if (Platform == 2)  // Shorthand for Macintosh
  184.     {
  185.       bJavaCapable = false;  // Java doesn't work on NS for Macintosh
  186.     }
  187.     else
  188.     {
  189.       bJavaCapable = true;  // Java works on NS for UNIX
  190.     }
  191.   }
  192.   else if (Browser == 4)  // Shorthand for Netscape
  193.   {
  194.     // LiveConnect broken under Netscape 6.0 on Windows and Mac
  195.     //
  196.     bJavaCapable = false;  // Play it safe.
  197.   }
  198.   else  // Assume IE
  199.   {
  200.     if (Platform == 1)  // Shorthand for Windows
  201.     {
  202.       bJavaCapable = true;  // Java works on IE for Windows
  203.  
  204.       if (WWHFrame.WWHBrowserInfo.mbIEWindowsXP)
  205.       {
  206.         bJavaCapable = false;  // Java not included under Windows XP
  207.       }
  208.     }
  209.     else if (Platform == 2)  // Shorthand for Macintosh
  210.     {
  211.       bJavaCapable = false;  // LiveConnect not currently working on Macintosh
  212.     }
  213.     else
  214.     {
  215.       bJavaCapable = false;  // Java doesn't work on IE for UNIX
  216.     }
  217.   }
  218.  
  219.   return bJavaCapable;
  220. }
  221.  
  222. function  WWHSwitch_Switch(ParamFrameSetURL)
  223. {
  224.   var  SwitchURL;
  225.  
  226.  
  227.   // Add parameters to redirect
  228.   //
  229.   SwitchURL = ParamFrameSetURL + this.mParameters;
  230.  
  231.   // Switch to desired frameset
  232.   // Delay required since this page is processing the action
  233.   //
  234.   setTimeout("location.replace(\"" + WWHStringUtilities_EscapeURLForJavaScriptAnchor(SwitchURL) + "\");", 1);
  235. }
  236.