home *** CD-ROM | disk | FTP | other *** search
/ Micro Dingo 7 / cd.iso / Club-internet / Installation / Netscape / NAV40.Z / System.js < prev    next >
Text File  |  1998-08-14  |  23KB  |  801 lines

  1. /* ==================================================================
  2. FILE:   System.js
  3. DESCR:  System class for Netscape Help implementation.
  4. NOTES:  
  5. ================================================================== */
  6. // Dev. switches.
  7. var TRACE           = false
  8. var ASSERT          = true
  9. var ERR_DLGS        = true
  10. var ERRS_TO_CONSOLE = false
  11.  
  12. // "Constants."
  13. var VERSION         = "2.0"
  14. var LAYERED_TOPICS  = false
  15. var JAVA_DEPENDENT  = false
  16. var STAMP_CONSOLE   = false
  17. var OK_NAV_VERSIONS = ".4."
  18. var CHECK_HREFS     = false
  19. var CONTENTS        = "CntTool.htm"
  20. var INDEX           = "IdxTool.htm"
  21. var SEARCH          = "SrhTool.htm"
  22. var NAVUI           = "NavUI.htm"
  23. var TOOLUI          = "ToolUI.htm"
  24. var STATUS          = "Status.htm"
  25. var MESSAGE_BGCOLOR = "#fafad2"
  26. var TOOL_BGCOLOR    = "#99ccff"
  27.  
  28. //trace( "System.js" )
  29.  
  30. // Runtime error handling.
  31. // window.onerror = errHandler
  32.  
  33. // Version stamp.
  34. if ( STAMP_CONSOLE && navigator.javaEnabled() ) {
  35.    java.lang.System.out.println( "System.js, version " + VERSION )
  36.    java.lang.System.out.println( "Client: " + navigator.appVersion )
  37. }
  38.  
  39. /*
  40. DESCR:   Handles the onhelp event.
  41. PARAMS:  URL  The URL to load.
  42. RETURNS: 
  43. NOTES:   
  44. */
  45. function onHelpHandler( URL )
  46. {
  47.    //trace( "onHelpHandler(" + URL + ")" )
  48.    //alert( "onHelpHandler(" + URL + ")" )
  49.  
  50.    systemObj.loadTopic( URL, false )
  51. }
  52.  
  53. /*
  54. DESCR:   Traces execution to the console.
  55. PARAMS:  msg  The trace text.
  56. RETURNS: 
  57. NOTES:   
  58. */
  59. function trace( msg )
  60. {
  61.    if ( TRACE ) java.lang.System.out.println( "System: " + msg )
  62. }
  63.  
  64. // Create system object.
  65. var systemObj = new system( JAVA_DEPENDENT, OK_NAV_VERSIONS )
  66. assert( ( typeof( systemObj ) == "object" ), SYS_CONSTRUCT )
  67.  
  68. /*
  69. DESCR:   Help implementation system class.
  70. PARAMS:  bJavaDependent  Pass true if the system is Java dependent,
  71.                          false if not.
  72.          OKNavVersions   String representing valid versions of Navigator.
  73. RETURNS: 
  74. NOTES:   
  75. */
  76. function system( bJavaDependent, OKNavVersions )
  77. {
  78.    //trace( "system constructor" )
  79.  
  80.    this.backStack    = new stack()
  81.    this.forwardStack = new stack()
  82.  
  83.    this.navVersion
  84.    this.topic
  85.    this.contents
  86.  
  87.    //this.aSysSecWnds = new Array()  // Sys-owned secondary windows.
  88.  
  89.    this.currentTool       = CONTENTS  // Set default tool.
  90.    this.bIdxTitlesPageUp  = false
  91.    this.currentSubsystem  = ""
  92.    this.visibleLayerIdx   = ""
  93.  
  94.    this.bToolUIloaded   = false
  95.    this.bNavUIloaded    = false
  96.    this.bContentsLoaded = false
  97.    this.bIndexLoaded    = false
  98.    this.bStarted        = false
  99.  
  100.    this.bNewSubsystem = false
  101.  
  102.    this.preproc           = preproc
  103.    this.componentCallback = componentCallback
  104.    this.idxTitlesUp       = idxTitlesUp
  105.    this.loadTopic         = loadTopic
  106.    this.newSubsystem      = newSubsystem
  107.    this.exit              = exit
  108.    this.print             = print
  109.    this.back              = back
  110.    this.forward           = forward
  111.    //this.openSecWnd        = openSecWnd
  112.    this.loadTool          = loadTool
  113.    this.setToolButton     = setToolButton
  114.    this.msg               = msg
  115.    this.manageLayers      = manageLayers
  116.    this.badURLerror       = badURLerror
  117.  
  118.    this.componentsReadyEvt = componentsReadyEvt
  119.    this.loadEvt            = loadEvt
  120.    this.unloadEvt          = unloadEvt
  121.  
  122.    this.stashPersistentData  = stashPersistentData
  123.    this.snatchPersistentData = snatchPersistentData
  124.  
  125.    // Preprocessing.
  126.    if ( !this.preproc( bJavaDependent, OKNavVersions ) ) {
  127.       return
  128.    }
  129.  
  130.    // Load components.
  131.    top.StatusFrame.location.replace( STATUS )
  132.    top.ToolUIFrame.location.replace( TOOLUI )
  133.    top.NavFrame.location.replace( NAVUI )
  134.    top.ToolFrame.location.replace( this.currentTool )
  135. }
  136.  
  137.    /*
  138.    DESCR:   Pre-Help processing.
  139.    PARAMS:  bJavaDependent  Pass true if the system is Java dependent,
  140.                             false if not.
  141.             OKNavVersions   String representing valid versions of Navigator.
  142.    RETURNS: 
  143.    NOTES:   
  144.    */
  145.    function preproc( bJavaDependent, OKNavVersions )
  146.    {
  147.       //trace( "preproc()" )
  148.       
  149.       // Make sure Java is enabled if needed. Otherwise, abort.
  150.       if ( bJavaDependent && !navigator.javaEnabled() ) {
  151.          this.msg( NO_JAVA_ERR_MSG, "" )
  152.          return false
  153.       }
  154.  
  155.       // Validate version of navigator. Render in ".integer." form.
  156.       var version = navigator.appVersion
  157.       this.navVersion =
  158.          "." + version.substring( 0, ( version.indexOf( "." ) + 1 ) )
  159.       if ( OKNavVersions.indexOf( this.navVersion ) == -1 ) {
  160.          this.msg( WRONG_NAV_VER_ERR_MSG, "" )
  161.          return false
  162.       }
  163.  
  164.       return true
  165.    }
  166.  
  167.    /*
  168.    DESCR:   Tracks component loading.
  169.    PARAMS:  componentName  The document-name of the component.
  170.    RETURNS: 
  171.    NOTES:   Components call this method on load. Triggers ready
  172.             event when all loaded.
  173.    */
  174.    function componentCallback( componentName )
  175.    {
  176.       //trace( "componentCallback(" + componentName + ")" )
  177.       //alert( "componentCallback(" + componentName + ")" )
  178.  
  179.       // Track component loading.
  180.  
  181.       // Note: for some reason, can't write to status frame until Contents
  182.       // is loaded, so we do this later.
  183.       //if ( componentName == STATUS ) top.StatusFrame.setStatusWait()
  184.  
  185.       if ( componentName == TOOLUI ) this.bToolUIloaded = true
  186.  
  187.       if ( componentName == NAVUI ) this.bNavUIloaded = true
  188.  
  189.       if ( componentName == CONTENTS ) {
  190.  
  191.          // Keep house.
  192.          top.StatusFrame.setStatusWait()
  193.          top.ToolUIFrame.bDisableBtnBar = false
  194.          this.bContentsLoaded = true
  195.          this.bIndexLoaded = false
  196.  
  197.          // Create a Contents object.
  198.          this.contents = new top.ToolFrame.contents( TOOL_BGCOLOR )
  199.          assert( ( typeof( this.contents ) == "object" ), CNT_CONSTRUCT )
  200.  
  201.          // If this is not a system load and we're just changing to the
  202.          // Contents tool, set the Content's dataset and update. Otherwise,
  203.          // this will happen when a topic is loaded.
  204.          if ( this.bStarted ) {
  205.            this.contents.setDataset( this.currentSubsystem )
  206.            this.contents.updateTree( this.topic.URL )
  207.  
  208.            top.StatusFrame.setStatusClear()
  209.          }
  210.       }
  211.  
  212.       if ( componentName == INDEX ) {
  213.          top.ToolUIFrame.bDisableBtnBar = false
  214.          this.bIndexLoaded = true
  215.          this.bContentsLoaded = false
  216.  
  217.          if ( this.bStarted ) top.StatusFrame.setStatusClear()
  218.       }
  219.  
  220.       // Set the blender button down for the current tool.
  221.       if ( componentName == TOOLUI ) {
  222.          this.setToolButton( ( this.currentTool == CONTENTS ? 0 : 1 ), 1 )
  223.       }
  224.  
  225.       // Get moving if we're ready, but not already underway.
  226.       if ( !this.bStarted &&
  227.            this.bToolUIloaded && this.bNavUIloaded &&
  228.            ( this.bContentsLoaded || this.bIndexLoaded ) ) {
  229.          this.bStarted = true
  230.          this.componentsReadyEvt()   
  231.       }
  232.    }
  233.  
  234.    /*
  235.    DESCR:   Handles components ready "event."
  236.    PARAMS:  
  237.    RETURNS: 
  238.    NOTES:   
  239.    */
  240.    function componentsReadyEvt()
  241.    {
  242.       //trace( "componentsReadyEvt()" )
  243.  
  244.       // Set onhelp handler.
  245.       top.setOnhelpHandler( "onHelpHandler" )
  246.    }
  247.  
  248.    /*
  249.    DESCR:   Enables external state-setting of the tool UI button bar.
  250.    PARAMS:  buttonIdx  Identifies the button on the bar.
  251.             newState   The state to set.
  252.    RETURNS: 
  253.    NOTES:   
  254.    */
  255.    function setToolButton( buttonIdx, newState )
  256.    {
  257.       //trace( "setToolButton" )
  258.  
  259.       assert( defined( top.ToolUIFrame.btnBar ), TOOLUI )
  260.       if ( defined( top.ToolUIFrame.btnBar ) ) {
  261.  
  262.          // Set.
  263.          with ( top.ToolUIFrame.btnBar.aButtons[ buttonIdx ] ) {
  264.             setState( newState )
  265.             bOn = true
  266.          }
  267.       }
  268.    }
  269.  
  270.    /*
  271.    DESCR:   onload handler.
  272.    PARAMS:  
  273.    RETURNS: 
  274.    NOTES:   
  275.    */
  276.    function loadEvt()
  277.    {
  278.       //trace( "loadEvt()" )
  279.       //alert( "loadEvt()" )
  280.  
  281.       // Snatch important data for persistence on reload