//*****************************************************************
// Microsoft Scripting Libary 2.0a
// Remote Scripting utilities for client.
//
// The Remote Scripting utilities for the client consist of
// three public methods and the RSCallObject definition.
// The public methods are RSEnableRemoteScripting, RSExecute
// and RSGetASPObject. The RSCallObject is returned from any
// remote scripting call and provides status and return value.
//
// Copyright 1999 Microsoft Corporation. All Rights Reserved.
//*****************************************************************
//*****************************************************************
// function RSEnableRemoteScripting()
// This function enables the remote scripting proxy.
//*****************************************************************
function RSEnableRemoteScripting(codebase)
{
MSRS = new _MSRS_Object();
MSRS.rsposter = new ActiveXObject("Microsoft.XMLHTTP")
}
//*****************************************************************
// function RSExecute(url,method,p1 ... pn,cb,ecb,context)
// This is the function by which remote scripting calls are made.
// The caller provides the following :
// url : url to the asp file containing remote script
// method : name of the method to be invoked
// p1...pn : any parameters required by the method
// cb : an optional callback routine for async.
// ecb : an optional error callback routine for async.
// context : an optional user context
//*****************************************************************
function RSExecute(url,method)
{
var cb, ecb, context;
var params = new Array;
var pn = 0;
var len = RSExecute.arguments.length;
for (var i=2; i < len; i++)
params[pn++] = RSExecute.arguments[i];
return MSRS.invokeMethod(url,method,params);
}
//*****************************************************************
// function RSGetASPObject(url)
// This function returns a server object for an ASP file
// described by its public_description.
//*****************************************************************
function RSGetASPObject(url)
{
var cb, ecb, context;
var params = new Array;
var request = MSRS.startRequest(url,'GetServerProxy',params,cb,ecb,context);
//alert(request.data); // USED FOR DEBUG
if (request.status == MSRS_COMPLETED)
{
var server = request.return_value;
if (typeof(Function) == 'function')
{
for (var name in server)
server[name] = Function('return MSRS.invokeMethod(this.location,"' + name + '",this.' + name + '.arguments);');
}
else
{ // JavaScript 1.0 does not support Function ( IE3.0 )
for (var name in server)
server[name] = eval('function t(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF) { return MSRS.invokeMethod(this.location,"' + name + '",this.' + name + '.arguments);} t');
}
server.location = url;
return server;
}
alert('Failed to create ASP object for : ' + url);
return null;
}
//*****************************************************************
// function RSCallObject(cb,ecb,context)
//
// The RSCallObject is returned for every remote scripting
// invocation. It contains the return value and status.
//
// id : unique id of request
// status : status of request, one of
// MSRS_COMPLETED
// MSRS_FAIL
// MSRS_PENDING
// MSRS_PARTIAL
// message : message associated with status
// data : raw data returned from server
// return_value : evaluated value returned from server
// callback : user provided callback ( optional )
// error_callback : user provided callback ( optional )
// context : user provided context ( optional )
//
//*****************************************************************
function RSCallObject(cb,ecb,context)
{
this.id = MSRS.nextRequestID++;
this.status = MSRS_COMPLETED;
this.message = '';
this.data = '';
this.return_value = '';
this.callback = cb;
this.error_callback = ecb;
this.context = context;
MSRS.requestList[this.id] = this;
}
//*** PRIVATE IMPLEMENTATION BELOW ********************************
//*** PRIVATE IMPLEMENTATION BELOW ********************************
//*** PRIVATE IMPLEMENTATION BELOW ********************************
//*****************************************************************
//
// Remote Scripting Object -- private implementation
//
// The following code is private glue code that contains the
// implementation of a JSObject to enable remote scripting
// functionality on the client. This private object is utilized
// by the public Remote Scripting methods defined above.
//
//*****************************************************************
//*****************************************************************
//*****************************************************************
// function _MSRS_Object
//
// This is the JSObject that interacts with the RSAspProxy
// applet to synchronously/asynchronously retrieve data via
// an ASP file.
//*****************************************************************
//var MSRS = new _MSRS_Object();
function _MSRS_Object()
{
MSRS_FAIL = -1;
MSRS_COMPLETED = 0;
//MSRS_PENDING = 1;
//MSRS_PARTIAL = 2;
this.REQUEST_MODE_COMPLETE = 0;
this.POLLING_PERIOD = 100;
this.pollID = 0;
this.pollCount = 0;
this.nextRequestID = 1;
this.requestList = new Array;
this.rsposter = null;
this.startRequest = _MSRS_startRequest;
this.invokeMethod = _MSRS_invokeMethod;
this.handleResponse = _MSRS_handleResponse;
this.evaluateRequest = _MSRS_evaluateRequest;
this.buildURL = _MSRS_buildURL;
}
//*****************************************************************
// function _MSRS_startRequest(url,method,args,cb,ecb,context)
//
// This is key function for initiating a request for data.
// The url to the ASP file is required. The callback,
// error_callback, and user context parameters are optional.
//*****************************************************************
function _MSRS_startRequest(url,method,args,cb,ecb,context)
{
var request = new RSCallObject(cb,ecb,context);
if (request.status == MSRS_COMPLETED)
{
var strPost = this.buildURL(method,args);
if(this.rsposter == null)
{
errmsg = 'ERROR:\nCannot locate proxy which supports Remote Scripting.\nWas RSEnableRemoteScripting method invoked?';
request.status = MSRS_FAIL;
request.message = errmsg;
alert(errmsg);
}
else
{
this.rsposter.open("post", url, false)
if(typeof(RSdebug) != 'undefined')
WriteCode(strPost)
this.rsposter.send("
| "); if(typeof(statusText) == 'undefined' || statusText == 'OK') w.document.write(unescape(responseText)) else { w.document.write(responseText) } w.document.write(" |