home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Micro Dingo 7
/
cd.iso
/
Club-internet
/
Installation
/
Netscape
/
NAV40.Z
/
System.js
< prev
next >
Wrap
Text File
|
1998-08-14
|
23KB
|
801 lines
/* ==================================================================
FILE: System.js
DESCR: System class for Netscape Help implementation.
NOTES:
================================================================== */
// Dev. switches.
var TRACE = false
var ASSERT = true
var ERR_DLGS = true
var ERRS_TO_CONSOLE = false
// "Constants."
var VERSION = "2.0"
var LAYERED_TOPICS = false
var JAVA_DEPENDENT = false
var STAMP_CONSOLE = false
var OK_NAV_VERSIONS = ".4."
var CHECK_HREFS = false
var CONTENTS = "CntTool.htm"
var INDEX = "IdxTool.htm"
var SEARCH = "SrhTool.htm"
var NAVUI = "NavUI.htm"
var TOOLUI = "ToolUI.htm"
var STATUS = "Status.htm"
var MESSAGE_BGCOLOR = "#fafad2"
var TOOL_BGCOLOR = "#99ccff"
//trace( "System.js" )
// Runtime error handling.
// window.onerror = errHandler
// Version stamp.
if ( STAMP_CONSOLE && navigator.javaEnabled() ) {
java.lang.System.out.println( "System.js, version " + VERSION )
java.lang.System.out.println( "Client: " + navigator.appVersion )
}
/*
DESCR: Handles the onhelp event.
PARAMS: URL The URL to load.
RETURNS:
NOTES:
*/
function onHelpHandler( URL )
{
//trace( "onHelpHandler(" + URL + ")" )
//alert( "onHelpHandler(" + URL + ")" )
systemObj.loadTopic( URL, false )
}
/*
DESCR: Traces execution to the console.
PARAMS: msg The trace text.
RETURNS:
NOTES:
*/
function trace( msg )
{
if ( TRACE ) java.lang.System.out.println( "System: " + msg )
}
// Create system object.
var systemObj = new system( JAVA_DEPENDENT, OK_NAV_VERSIONS )
assert( ( typeof( systemObj ) == "object" ), SYS_CONSTRUCT )
/*
DESCR: Help implementation system class.
PARAMS: bJavaDependent Pass true if the system is Java dependent,
false if not.
OKNavVersions String representing valid versions of Navigator.
RETURNS:
NOTES:
*/
function system( bJavaDependent, OKNavVersions )
{
//trace( "system constructor" )
this.backStack = new stack()
this.forwardStack = new stack()
this.navVersion
this.topic
this.contents
//this.aSysSecWnds = new Array() // Sys-owned secondary windows.
this.currentTool = CONTENTS // Set default tool.
this.bIdxTitlesPageUp = false
this.currentSubsystem = ""
this.visibleLayerIdx = ""
this.bToolUIloaded = false
this.bNavUIloaded = false
this.bContentsLoaded = false
this.bIndexLoaded = false
this.bStarted = false
this.bNewSubsystem = false
this.preproc = preproc
this.componentCallback = componentCallback
this.idxTitlesUp = idxTitlesUp
this.loadTopic = loadTopic
this.newSubsystem = newSubsystem
this.exit = exit
this.print = print
this.back = back
this.forward = forward
//this.openSecWnd = openSecWnd
this.loadTool = loadTool
this.setToolButton = setToolButton
this.msg = msg
this.manageLayers = manageLayers
this.badURLerror = badURLerror
this.componentsReadyEvt = componentsReadyEvt
this.loadEvt = loadEvt
this.unloadEvt = unloadEvt
this.stashPersistentData = stashPersistentData
this.snatchPersistentData = snatchPersistentData
// Preprocessing.
if ( !this.preproc( bJavaDependent, OKNavVersions ) ) {
return
}
// Load components.
top.StatusFrame.location.replace( STATUS )
top.ToolUIFrame.location.replace( TOOLUI )
top.NavFrame.location.replace( NAVUI )
top.ToolFrame.location.replace( this.currentTool )
}
/*
DESCR: Pre-Help processing.
PARAMS: bJavaDependent Pass true if the system is Java dependent,
false if not.
OKNavVersions String representing valid versions of Navigator.
RETURNS:
NOTES:
*/
function preproc( bJavaDependent, OKNavVersions )
{
//trace( "preproc()" )
// Make sure Java is enabled if needed. Otherwise, abort.
if ( bJavaDependent && !navigator.javaEnabled() ) {
this.msg( NO_JAVA_ERR_MSG, "" )
return false
}
// Validate version of navigator. Render in ".integer." form.
var version = navigator.appVersion
this.navVersion =
"." + version.substring( 0, ( version.indexOf( "." ) + 1 ) )
if ( OKNavVersions.indexOf( this.navVersion ) == -1 ) {
this.msg( WRONG_NAV_VER_ERR_MSG, "" )
return false
}
return true
}
/*
DESCR: Tracks component loading.
PARAMS: componentName The document-name of the component.
RETURNS:
NOTES: Components call this method on load. Triggers ready
event when all loaded.
*/
function componentCallback( componentName )
{
//trace( "componentCallback(" + componentName + ")" )
//alert( "componentCallback(" + componentName + ")" )
// Track component loading.
// Note: for some reason, can't write to status frame until Contents
// is loaded, so we do this later.
//if ( componentName == STATUS ) top.StatusFrame.setStatusWait()
if ( componentName == TOOLUI ) this.bToolUIloaded = true
if ( componentName == NAVUI ) this.bNavUIloaded = true
if ( componentName == CONTENTS ) {
// Keep house.
top.StatusFrame.setStatusWait()
top.ToolUIFrame.bDisableBtnBar = false
this.bContentsLoaded = true
this.bIndexLoaded = false
// Create a Contents object.
this.contents = new top.ToolFrame.contents( TOOL_BGCOLOR )
assert( ( typeof( this.contents ) == "object" ), CNT_CONSTRUCT )
// If this is not a system load and we're just changing to the
// Contents tool, set the Content's dataset and update. Otherwise,
// this will happen when a topic is loaded.
if ( this.bStarted ) {
this.contents.setDataset( this.currentSubsystem )
this.contents.updateTree( this.topic.URL )
top.StatusFrame.setStatusClear()
}
}
if ( componentName == INDEX ) {
top.ToolUIFrame.bDisableBtnBar = false
this.bIndexLoaded = true
this.bContentsLoaded = false
if ( this.bStarted ) top.StatusFrame.setStatusClear()
}
// Set the blender button down for the current tool.
if ( componentName == TOOLUI ) {
this.setToolButton( ( this.currentTool == CONTENTS ? 0 : 1 ), 1 )
}
// Get moving if we're ready, but not already underway.
if ( !this.bStarted &&
this.bToolUIloaded && this.bNavUIloaded &&
( this.bContentsLoaded || this.bIndexLoaded ) ) {
this.bStarted = true
this.componentsReadyEvt()
}
}
/*
DESCR: Handles components ready "event."
PARAMS:
RETURNS:
NOTES:
*/
function componentsReadyEvt()
{
//trace( "componentsReadyEvt()" )
// Set onhelp handler.
top.setOnhelpHandler( "onHelpHandler" )
}
/*
DESCR: Enables external state-setting of the tool UI button bar.
PARAMS: buttonIdx Identifies the button on the bar.
newState The state to set.
RETURNS:
NOTES:
*/
function setToolButton( buttonIdx, newState )
{
//trace( "setToolButton" )
assert( defined( top.ToolUIFrame.btnBar ), TOOLUI )
if ( defined( top.ToolUIFrame.btnBar ) ) {
// Set.
with ( top.ToolUIFrame.btnBar.aButtons[ buttonIdx ] ) {
setState( newState )
bOn = true
}
}
}
/*
DESCR: onload handler.
PARAMS:
RETURNS:
NOTES:
*/
function loadEvt()
{
//trace( "loadEvt()" )
//alert( "loadEvt()" )
// Snatch important data for persistence on reload