|
|
/*++
Copyright (c) 1999-2000 Microsoft Corporation
Module Name:
RAClient.js
Abstract:
Contains Javascript code common to both client and server side UI
Author:
Rajesh Soy 10/00
Revision History:
Rajesh Soy - created 10/25/2000
--*/
#include "debug_decl.inc" #include "constants.inc"
/* * Localizable Constants, text and messages */ var L_SAYS_Text = " says: "; var L_INITIALHELPERCHAT1_Text = "----------<BR>Welcome to Remote Assistance.<BR>To explore your options, click Help.<P>"; var L_INITIALHELPERCHAT2_Text = " is connected to <BR>"; var L_RCCTL_Text = "Remote Assistance failed. Please try again. "; var L_NOIP_Text = "There is no Internet connection. To use Remote Assistance, please connect to the Internet. ";
// // Configuration stuff // #ifdef _VOIPENABLED var g_bVoIPEnabled = true; // JPEREZ: Enabled March 1, 2001 - // ADHOC, Disabling VoIP for the moment. #else var g_bVoIPEnabled = false; #endif
// // Globals // var g_szLocalUser = null; var g_oShell = null; var g_oEnv = null;
#ifdef _BVT var g_szExpertComputer = null; var g_szNoviceComputer = null; var g_szNoviceCredentials = null; var g_szBVTDir = null;
var g_iTest = 0; var g_szBuild = null;
var g_bBVT = false;
function TestInfo() { this.TEST = null; this.BUILD = null; this.MACHINE = null; this.RESULT = null; this.CONTACT = null; this.MGR_CONTACT = null; this.DEV_PRIME = null; this.DEV_ALT = null; this.TEST_PRIME = null; this.TEST_ALT = null; this.START_TIME = null; this.END_TIME = null; }
#define szCONTACT "David Holcomb (dholcomb), x6-9764" #define szMGR_CONTACT "Mazhar Mohammad (mazharm), x6-7103" #define szDEV_PRIME "Rajesh Soy (nsoy), x3-9938" #define szDEV_ALT "Steve Shih (steveshi), x3-3498" #define szTEST_PRIME "Miguel Lacouture-Amaya (miguell), x5-3510" #define szTEST_ALT "Dave Ferguson (WIMME) (dferg), 5-7079"
var g_oBVT = new Array( 7 );
function InitBVT() { var iRetVal = 0; try { if( null == g_oShell) { g_oShell = new ActiveXObject("WScript.Shell"); } if(null == g_oEnv) { g_oEnv = g_oShell.Environment("process"); } g_szNoviceComputer = g_oEnv("NOVICECOMPUTER"); g_szNoviceCredentials = g_oEnv("NOVICEUSERID"); g_szBVTDir = g_oEnv("RABVTDIR"); g_szExpertComputer = g_oEnv("COMPUTERNAME"); g_szBuild = g_oEnv( "BUILD" );
for( var i = 0; i < 7; i++) { g_oBVT[ i ] = new TestInfo(); g_oBVT[ i ].BUILD = g_szBuild; g_oBVT[ i ].MACHINE = g_szExpertComputer; g_oBVT[ i ].CONTACT = szCONTACT; g_oBVT[ i ].MGR_CONTACT = szMGR_CONTACT; g_oBVT[ i ].DEV_PRIME = szDEV_PRIME; g_oBVT[ i ].DEV_ALT = szDEV_ALT; g_oBVT[ i ].TEST_PRIME = szTEST_PRIME; g_oBVT[ i ].TEST_ALT = szTEST_ALT; }
g_bBVT = true; } catch(error) { iRetVal = error.number; }
return iRetVal; }
function ReportBVTResult( szResult ) { var iRetVal = 0; try { var oDate = new Date(); g_oBVT[ g_iTest ].END_TIME = oDate.toLocaleString();
if( szResult == c_szBVTPASS ) { g_oBVT[ g_iTest ].RESULT = c_szPASS; } else { g_oBVT[ g_iTest ].RESULT = c_szFAIL; }
g_iTest++; } catch(error) { iRetVal = error.number; }
return iRetVal; }
function ShutDownBVT() { try {
var Fso = new ActiveXObject("Scripting.FileSystemObject"); var FileName = g_szBVTDir + "\\RABVTResult.txt"; var fileHandle = Fso.OpenTextFile( FileName, 2, -2 );
for (var i=0; i < 7; i++) { if( null != g_oBVT[ i ].TEST ) { fileHandle.WriteLine( "[TESTRESULT]"); fileHandle.WriteLine( " "); fileHandle.WriteLine( "TEST: " + g_oBVT[ i ].TEST ); fileHandle.WriteLine( "BUILD: " + g_oBVT[ i ].BUILD ); fileHandle.WriteLine( "MACHINE: " + g_oBVT[ i ].MACHINE ); fileHandle.WriteLine( "RESULT: " + g_oBVT[i].RESULT ); fileHandle.WriteLine( "CONTACT: " + g_oBVT[ i ].CONTACT); fileHandle.WriteLine( "MGR CONTACT: " + g_oBVT[ i ].MGR_CONTACT ); fileHandle.WriteLine( "DEV PRIME: " + g_oBVT[ i ].DEV_PRIME ); fileHandle.WriteLine( "DEV ALT: " + g_oBVT[ i ].DEV_ALT ); fileHandle.WriteLine( "TEST PRIME: " + g_oBVT[ i ].TEST_PRIME ); fileHandle.WriteLine( "TEST ALT: " + g_oBVT[ i ].TEST_ALT ); fileHandle.WriteLine( "START TIME: " + g_oBVT[ i ].START_TIME); fileHandle.WriteLine( "END TIME: " + g_oBVT[ i ].END_TIME ); fileHandle.WriteLine( " "); fileHandle.WriteLine( "[/TESTRESULT]"); fileHandle.WriteLine( " "); fileHandle.WriteLine( " "); fileHandle.WriteLine( " "); } }
fileHandle.Close(); } catch(error) { alert("Error: " + error.description); } }
#endif
function DisplayMessage( szMsg ) { TraceFunctEnter( "DisplayMessage" );
try { var vArgs = new Array(1); vArgs[0] = szMsg; // Message var vRetVal = window.showModelessDialog( c_szMsgURL, vArgs, c_szMsgSpecs ); } catch(error) { FatalError( error.description, error ); }
TraceFunctLeave(); }
function SoundBeep() { TraceFunctEnter("SoundBeep"); #ifdef _BEEP try { if( null == g_oShell) { g_oShell = new ActiveXObject("WScript.Shell"); } g_oShell.SendKeys("%c"); } catch(error) { FatalError( error.description ); } #endif TraceFunctLeave(); return g_szLocalUser; }
// // GetLocalUser: Obtains the domain\username of local user // function GetLocalUser() { TraceFunctEnter("GetLocalUser"); try { if( null == g_oShell) { g_oShell = new ActiveXObject("WScript.Shell"); } if(null == g_oEnv) { g_oEnv = g_oShell.Environment("process"); } var szTmp = g_oEnv("USERNAME"); if( szTmp.length < 20 ) { g_szLocalUser = szTmp; } else { g_szLocalUser = szTmp.slice(0, 20) + "..."; }
g_szLocalUser = EscapedName( g_szLocalUser ); } catch(error) { FatalError( error.description ); } TraceFunctLeave(); return g_szLocalUser; }
// // GetLocalIPAddr: Fetch the IP address of the local machine // function GetLocalIPAddr() { var oSetting = null; var ip = null;
try { oSetting = new ActiveXObject( szProgIDEscalationSetting ); ip = oSetting.GetIPAddress; if (ip.length == 0) { alert(L_NOIP_Text); return ip; } oSetting = null; } catch(e) { FatalError(L_RCCTL_Text, e); return ip; }
return ip; }
// // ChangeHCToKioskMode: Changes from full HC view to kiosk mode view // function ChangeHCToKioskMode(left, top, width, height) { TraceFunctEnter("ChangeHCToKioskMode"); try { DebugTrace("Changing to kioskmode");
// // In order to use this, include the following in your HTM file: // <HTML XMLNS:helpcenter> // <style> // helpcenter\:context // { // behavior : url(#default#pch_context); // } // </style> // // <helpcenter:context id=idCtx /> // idCtx.ChangeContext( "kioskmode", ""); idCtx.setWindowDimensions( left, top, width, height); } catch(error) { FatalError( L_RCCTL_Text, error ); } TraceFunctLeave(); }
// // GetWinDir: Returns path to SystemRoot // function GetWinDir() { TraceFunctEnter("GetWinDir"); var szWinDir = null;
try { if( null == g_oShell) { g_oShell = new ActiveXObject("WScript.Shell"); } if(null == g_oEnv) { g_oEnv = g_oShell.Environment("process"); } szWinDir = g_oEnv("SystemRoot"); } catch(error) { FatalError(error.description, error); }
TraceFunctLeave(); return szWinDir; }
// // LaunchHelp: Launches Help topic in kioskmode Helpctr // function LaunchHelp( nTopicId ) { TraceFunctEnter("LaunchHelp");
try { var szURL = 'hcp://CN=Microsoft%20Corporation,L=Redmond,S=Washington,C=US/Remote%20Assistance/Common/RAHelp.htm?' + nTopicId; var szWinDir = GetWinDir(); window.showModelessDialog( szURL, szWinDir, "dialogHeight:400px;dialogWidth:550px;status:no;resizable:yes;help:no" ); } catch(error) { FatalError(error.description, error); }
TraceFunctLeave();
return; }
function LaunchHelpEx( nTopicId ) { TraceFunctEnter("LaunchHelp");
try { var szURL = 'hcp://system/Remote%20Assistance/Common/RAHelp.htm?' + nTopicId; var szWinDir = GetWinDir(); window.showModelessDialog( szURL, szWinDir, "dialogHeight:440px;dialogWidth:385px;status:no;resizable:no;help:no" ); } catch(error) { FatalError(error.description, error); }
TraceFunctLeave();
return; }
function FatalError( szMessage, error, bClose) { try { var szMsg = null;
#ifdef _BVT
if( true == g_bBVT ) { if( (szMessage == null) || (szMessage.length < 5)) { szMessage = L_RCCTL_Text; }
var vArgs = new Array(1); vArgs[0] = szMessage; DebugTrace( "Function: " + g_szFuncName + "\nError Message: " + szMessage + "\nError Description: " + error.description + "\nError Number: " + error.number);
var vRetVal = window.showModalDialog( c_szMsgURL + '?' + szMessage, vArgs, c_szMsgSpecs ); AddOpenSubWin( vRetVal );
ShutDownBVT(); } else { if( (szMessage == null) || (szMessage.length < 5)) { szMessage = L_RCCTL_Text; }
var vArgs = new Array(1); vArgs[0] = szMessage; DebugTrace( "Function: " + g_szFuncName + "\nError Message: " + szMessage + "\nError Description: " + error.description + "\nError Number: " + error.number);
var vRetVal = window.showModalDialog( c_szMsgURL + '?' + szMessage, vArgs, c_szMsgSpecs ); AddOpenSubWin( vRetVal ); } #else if( (szMessage == null) || (szMessage.length < 5)) { szMessage = L_RCCTL_Text; }
var vArgs = new Array(1); vArgs[0] = szMessage; DebugTrace( "Function: " + g_szFuncName + "\nError Message: " + szMessage + "\nError Description: " + error.description + "\nError Number: " + error.number);
var vRetVal = window.showModalDialog( c_szMsgURL + '?' + szMessage, vArgs, c_szMsgSpecs ); AddOpenSubWin( vRetVal ); #endif } catch(x) { // ... } }
// // Collection of open sub-windows // var openWins = new Array(10); // Hope not to open more than 10 sub-windows at any given time var openWinCnt = 0; // Count of open windows
function AddOpenSubWin( win ) { try { openWins[openWinCnt%10] = win; openWinCnt++; } catch(error) { // Ignore } }
function CloseOpenSubWin() { var i = 0;
for ( i=0; i< 10; i++) { if(null != openWins[i]) { try { if(openWins[i].closed == false) { openWins[i].close(); } } catch(error) { // Ignore } } } }
// // Chat Stuff // function FormatChatMsg( szMsg ) { var szNewText = '<BR><font id="MsgTxt" name="MsgTxt" class="sys-font-body sys-color-body-helper">' + szMsg + '</font><P>'; return szNewText; }
function CreateChatGreeting( szLocalUser, szRemoteUser ) { szLocalUser = EscapedName( szLocalUser ); szRemoteUser = EscapedName( szRemoteUser ); var szNewText = FormatChatMsg( L_INITIALHELPERCHAT1_Text + "<P>" + szLocalUser + L_INITIALHELPERCHAT2_Text + szRemoteUser + ".<P>" + L_INITIALHELPERCHAT3_Text ); return szNewText; }
function FormatSendChatText( szUser, szChatText ) { var szNewText = '<BR><font id="MsgTxt" name="MsgTxt" class="styChatColorBlue styText">' + szUser + L_SAYS_Text + '</font><BR> <font class="styText styBlack">' + szChatText + '</font>'; return szNewText; }
// // Key tracking // var iKeyCode = new Array(3); var iKeyCnt = 0;
function IsAlpha( keyCode ) { var fRetVal = false;
alert("keyCode: " + keyCode); if( ( 64 < keyCode) && ( keyCode < 91) ) { fRetVal = true; }
return fRetVal; }
// // Escape funny characters in name // var L_DOTS_Text = "...";
function EscapedName( szName ) { TraceFunctEnter("EscapeName"); try { var szTmp = new String( szName ); var re = /&/g; var szEscapedName = szTmp.replace( re, "&" ); var re = /</g; szEscapedName = szEscapedName.replace( re, "<" ); re = />/g; szEscapedName = szEscapedName.replace( re, ">" ); #if 0 if( szEscapedName.length > 60 ) { szEscapedName = szEscapedName.slice(0, 60) + L_DOTS_Text; } #endif } catch(error) { alert(parent.parent.L_RCCTL_Text); return; } TraceFunctLeave(); return szEscapedName; }
|