From 6aeccc21cfe3fb1c49a61d8eaf09f38526c756c0 Mon Sep 17 00:00:00 2001 From: timm Date: Thu, 9 Jul 1998 19:22:49 +0000 Subject: [PATCH] some routines from globals1.js git-svn-id: svn://10.0.0.236/trunk@5252 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/cmd/dialup/as_html/connect2.js | 29 +-- mozilla/cmd/dialup/as_html/globals.htm | 6 +- mozilla/cmd/dialup/as_html/globals1.js | 299 ----------------------- mozilla/cmd/dialup/as_html/globals2.js | 4 +- mozilla/cmd/dialup/as_html/util.js | 319 +++++++++++++++++++++++++ 5 files changed, 337 insertions(+), 320 deletions(-) create mode 100644 mozilla/cmd/dialup/as_html/util.js diff --git a/mozilla/cmd/dialup/as_html/connect2.js b/mozilla/cmd/dialup/as_html/connect2.js index a9350ce873b..fd360c55ada 100644 --- a/mozilla/cmd/dialup/as_html/connect2.js +++ b/mozilla/cmd/dialup/as_html/connect2.js @@ -332,12 +332,10 @@ function configureDialer() var thePlatform = parent.parent.globals.getPlatform(); var configFile=""; - if (thePlatform == "Macintosh") { // Macintosh support + if ( thePlatform == "Macintosh" ) // Macintosh support configFile = profileDir + "Configuration"; - } - else { // Windows support + else // Windows support configFile = profileDir + "CONFIG.INI"; - } parent.parent.globals.document.setupPlugin.SetNameValuePair(configFile,"Account", "Account", newProfileName); // parent.parent.globals.document.vars.providername.value); parent.parent.globals.document.setupPlugin.SetNameValuePair(configFile,"Modem", "Modem", parent.parent.globals.document.vars.modem.value); @@ -345,23 +343,20 @@ function configureDialer() // write out default Bookmark file (if one doesn't exist yet) - var currentBookmarkFilename=""; - if (thePlatform == "Macintosh") { // Macintosh support + if ( thePlatform == "Macintosh" ) // Macintosh support currentBookmarkFilename = profileDir + "Bookmarks.html"; - } - else { // Windows support + else // Windows support currentBookmarkFilename = profileDir + "BOOKMARK.HTM"; - } - var bookmarkData = parent.parent.globals.document.setupPlugin.GetNameValuePair(currentBookmarkFilename,null,null); - if ((bookmarkData == null) || (bookmarkData == "") || (bookmarkData.indexOf("HREF")<0)) { - var defaultBookmarkFilename = parent.parent.globals.getConfigFolder(self) + "bookmark.htm"; - bookmarkData = parent.parent.globals.document.setupPlugin.GetNameValuePair(defaultBookmarkFilename,null,null); - if (bookmarkData != null && bookmarkData != "") { - parent.parent.globals.document.setupPlugin.SaveTextToFile(currentBookmarkFilename,bookmarkData,false); - } - } + var bookmarkData = parent.parent.globals.document.setupPlugin.GetFileContents( currentBookmarkFilename ); + if ( ( bookmarkData == null ) || ( bookmarkData == "" ) || ( bookmarkData.indexOf( "HREF" ) < 0 ) ) + { + var defaultBookmarkFilename = parent.parent.globals.getConfigFolder( self ) + "bookmark.htm"; + bookmarkData = parent.parent.globals.document.setupPlugin.GetFileContents( defaultBookmarkFilename ); + if ( bookmarkData != null && bookmarkData != "" ) + parent.parent.globals.document.setupPlugin.SaveTextToFile( currentBookmarkFilename, bookmarkData, false ); + } // copy profile lock file (if one is specified in selected .NCI file) diff --git a/mozilla/cmd/dialup/as_html/globals.htm b/mozilla/cmd/dialup/as_html/globals.htm index 363dae5fe4e..3039bf4ac4e 100644 --- a/mozilla/cmd/dialup/as_html/globals.htm +++ b/mozilla/cmd/dialup/as_html/globals.htm @@ -18,9 +18,11 @@ - - + diff --git a/mozilla/cmd/dialup/as_html/globals1.js b/mozilla/cmd/dialup/as_html/globals1.js index 08fe7dcc415..8b8eba1714b 100644 --- a/mozilla/cmd/dialup/as_html/globals1.js +++ b/mozilla/cmd/dialup/as_html/globals1.js @@ -28,157 +28,6 @@ parent.ondblclick = cancelEvent; var oneStepSemaphore = false; var selectedISP = null; -function cancelEvent( e ) -{ - var retVal = false; - - if ( ( e.which < 2 ) && ( e.type != "dragdrop" ) && ( e.type != "dblclick" ) ) - retVal = routeEvent( e ); - - return retVal; -} - -function debug( theString ) -{ - java.lang.System.out.println( theString ); -} - -function GetNameValuePair( file, section, variable ) -{ - netscape.security.PrivilegeManager.enablePrivilege( "AccountSetup" ); - - var value = parent.globals.document.setupPlugin.GetNameValuePair( file, section, variable ); - if ( value == null ) - value = ""; - return value; -} - -function SetNameValuePair( file, section, variable, data ) -{ - netscape.security.PrivilegeManager.enablePrivilege( "AccountSetup" ); - - parent.globals.document.setupPlugin.SetNameValuePair( file, section, variable, data ); - //debug( "\tSetNameValuePair: [" + section + "] " + variable + "=" + data ); -} - - -// * returns a string representing the path to the folder named "Config" inside the folder "Data" that -// is installed in the Communicator's home directory -function getConfigFolder( object ) -{ - var pathName; - pathName = getFolder( object ) + "Config" + "\\"; - - //debug( "getConfigFolder: " + pathName ); - - return pathName; -} - -// * returns a string representing the path to the file "ACCTSET.INI" inside the folder -// returned from getConfigFolder -function getAcctSetupFilename( object ) -{ - var file; - file = getConfigFolder( object ) + "ACCTSET.INI"; - - //debug( "getAcctSetupFilename: " + file ); - return file; -} - -function getPlatform() -{ - var platform = new String( navigator.userAgent ); - var x = platform.indexOf( "(" ) + 1; - var y = platform.indexOf( ";", x + 1 ); - platform = platform.substring( x, y ); - return platform; -} - -function getBrowserVersionNumber() -{ - var theAgent = navigator.userAgent; - var x = theAgent.indexOf( "/" ); - var theVersion = "unknown"; - if ( x >= 0 ) - var theVersion = theAgent.substring( x + 1, theAgent.length ); - return theVersion; -} - -function getBrowserMajorVersionNumber() -{ - var version = getBrowserVersionNumber(); - if ( version != "unknown" ) - { - var x = theVersion.indexOf( "." ); - if ( x > 0 ) - version = version.substring( 0, x ); - } - return version; -} - -// * returns a canoncial path to the folder containing the document representing the current contents of "window" -function getFolder( window ) -{ - platform = getPlatform(); - - if ( platform == "Macintosh" ) - { // Macintosh support - var path = unescape( window.location.pathname ); - if ( ( x = path.lastIndexOf( "/" ) ) > 0 ) - path = path.substring( 0, x + 1 ); - - //var fileArray = path.split( "/" ); - //var newpath = fileArray.join( ":" ) + ":"; - - //if ( newpath.charAt( 0 ) == ':' ) - // newpath = newpath.substring( 1, newpath.length ); - - newpath = path; - } - else - { // Windows support - - // note: JavaScript returns path with '/' instead of '\' - var path = unescape( window.location.pathname ); - - var drive = "|"; - - // gets the drive letter and directory path - if ( ( x = path.lastIndexOf( "|" ) ) > 0 ) - { - drive = path.substring( path.indexOf( '/' ) + 1, path.indexOf( '|' ) ); - path = path.substring( path.indexOf( '|' ) + 1, path.lastIndexOf( '/' ) + 1 ); - } - - var pathArray = path.split( "/" ); - path = pathArray.join( "\\" ); - - //debug( "drive: " + drive + " path: " + path ); - - // construct newpath - newpath = drive + ":" + path + "\\"; - debug( "path: " + newpath ); - } - return newpath; -} - -function setFocus( theObject ) -{ - theObject.focus(); - theObject.select(); -} - -function message( txt ) -{ - window.status = txt; - setTimeout( "remove_message()", 10000 ); -} - -function remove_message() -{ - window.status = ""; -} - function getSelectedISPName() { netscape.security.PrivilegeManager.enablePrivilege( "AccountSetup" ); @@ -188,46 +37,6 @@ function getSelectedISPName() return ispDisplayName; } -function checkPluginExists( name, generateOutputFlag ) -{ - /* - var myPlugin = navigator.plugins["name"]; - if (myPlugin) { - // do something here - } - else { - document.writeln("
Warning! The '" +name+ "' plug-in is not installed!
\n"); - } - */ - - if ( navigator.javaEnabled() ) - { - var myMimetype = navigator.mimeTypes[ name ] - if ( myMimetype ) - { - return true; - } - else - { - if ( generateOutputFlag == true ) - { - document.writeln( "
The 'Account Setup Plugin' is not installed!

\n" ); - document.writeln( "Please install the plugin, then run 'Account Setup' again.

\n" ); - } - return false; - } - } - else - { - if ( generateOutputFlag==true ) - { - document.writeln( "
Java support is disabled!

\n" ); - document.writeln( "Choose Options | Network Preferences and enable Java, then try again.

\n" ); - } - return false; - } -} - function forceReboot(pageName) { netscape.security.PrivilegeManager.enablePrivilege( "AccountSetup" ); @@ -877,112 +686,4 @@ function setRegisterMode( numSecondsElapsed ) } } - - -function verifyIPaddress( address ) -{ - var dotCount = 0, dotIndex = 0, net, validFlag = false; - - while ( dotIndex >= 0 ) - { - net = ""; - dotIndex = address.indexOf( "." ); - if ( dotIndex >=0 ) - { - net = address.substring( 0, dotIndex ); - address = address.substring( dotIndex + 1 ); - ++dotCount; - } - else - { - net = address; - if ( net=="" ) - break; - } - - netValue = parseInt( net ); - if ( isNaN( netValue ) ) - break; - if ( netValue < 0 || netValue > 255 ) - break; - - if ( dotCount == 3 && dotIndex < 0 ) - validFlag = true; - } - return validFlag; -} - -function verifyZipCode( zipCode ) -{ - var validFlag = false; - - if ( zipCode.length >= 5 ) - { - validFlag = true; - for ( var x = 0; x < zipCode.length; x++ ) - { - if ( "0123456789-".indexOf( zipCode.charAt( x ) ) < 0 ) - { - validFlag = false; - break; - } - } - } - return validFlag; -} - -function verifyPhoneNumber( phoneNum, minLength ) -{ - var validFlag = false; - - if ( phoneNum.length >= minLength ) - { - validFlag = true; - for ( var x = 0; x < phoneNum.length; x++ ) - { - if ( "0123456789().,-+ ".indexOf( phoneNum.charAt( x ) ) < 0 ) - { - validFlag = false; - break; - } - } - } - return validFlag; -} - -function verifyAreaCode( areaCode ) -{ - var validFlag = false; - - if ( areaCode.length >= 3 ) - { - validFlag = true; - for ( var x = 0; x < areaCode.length; x++ ) - { - if ( "0123456789".indexOf( areaCode.charAt( x ) ) < 0 ) - { - validFlag = false; - break; - } - } - } - return validFlag; -} - -function getAreaCode( tapiPhoneNumber ) -{ - var x = tapiPhoneNumber.indexOf( "(" ); - var y = tapiPhoneNumber.indexOf( ")" ); - var temp = ""; - if ( x >= 0 && y >= 0 ) - { - temp = tapiPhoneNumber.substring( x + 1, y ); - if ( verifyAreaCode( temp ) == false ) - temp = ""; - } - return temp; -} - - - // end hiding contents from old browsers --> diff --git a/mozilla/cmd/dialup/as_html/globals2.js b/mozilla/cmd/dialup/as_html/globals2.js index 6771ac7664f..4dd34b95458 100644 --- a/mozilla/cmd/dialup/as_html/globals2.js +++ b/mozilla/cmd/dialup/as_html/globals2.js @@ -472,7 +472,7 @@ function configureNewAccount() } - var bookmarkData = "" + document.setupPlugin.GetNameValuePair( currentBookmarkFilename, null, null ); + var bookmarkData = "" + document.setupPlugin.GetFileContents( currentBookmarkFilename ); if ( bookmarkData != "" ) { if ( bookmarkData.indexOf( "" ) ==0 ) @@ -578,7 +578,7 @@ function configureNewAccount() var ISPurl = findVariable( "ISP_URL" ); if ( ISPurl != null && ISPurl != "" ) { - bookmarkData = "" + document.setupPlugin.GetNameValuePair( currentBookmarkFilename, null, null ); + bookmarkData = "" + document.setupPlugin.GetFileContents( currentBookmarkFilename ); if ( bookmarkData != null && bookmarkData != "" ) { var lastDLindex = bookmarkData.lastIndexOf( "" ); diff --git a/mozilla/cmd/dialup/as_html/util.js b/mozilla/cmd/dialup/as_html/util.js new file mode 100644 index 00000000000..bc5dbcc8bbb --- /dev/null +++ b/mozilla/cmd/dialup/as_html/util.js @@ -0,0 +1,319 @@ +/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +