📄 rs.htm
字号:
else
{
errmsg = 'ERROR:\nCannot locate proxy which supports Remote Scripting.\nWas RSEnableRemoteScripting method invoked?';
request.status = MSRS_FAIL;
request.message = errmsg;
alert(errmsg);
}
}
if (request.status != MSRS_FAIL)
{
url = this.buildURL(url,method,args);
url_context = window.location.href; // May not be 'window.location.pathname'
this.rsapplet.startRequest(request.id,url_context,url,this.REQUEST_MODE_COMPLETE);
if (typeof(cb)== 'function')
{
if (this.pollCount++ == 0)
this.setRequestPoll();
}
else
{ // wait synchronously for response
request.wait();
}
}
//return aRecs+"/"+request+"/";
return request;
}
//*****************************************************************
// function _MSRS_invokeMethod(url,method,args)
// This is the function by which remote scripting calls are
// via a server object retrieved with the GetASPObject call.
// The caller provides the following :
// url : url to the asp
// method : name of the method to be invoked
// args : an array containing method parameters
// and the optional cb, ecb, context parameters
//*****************************************************************
function _MSRS_invokeMethod(url,method,args)
{
var cb, ecb, context;
var params = new Array;
var pn = 0;
var i = 0;
for (var i=0; i < args.length; i++)
{
if (typeof(args[i]) == 'function')
{
pn = -1; // no more params
if (typeof(cb) == 'undefined')
cb = args[i];
else
ecb = args[i];
}
else if (pn != -1)
{
params[pn++] = args[i];
}
else
context = args[i];
}
return MSRS.startRequest(url,method,params,cb,ecb,context);
}
//*****************************************************************
// function _MSRS_handleResponse(requestid)
//
// This function will handle the response for a given request.
// If the response is complete or failed, then the associated
// request object will be updated and the appropriate callback
// invoked, if provided.
// NOTE: incremental data retrieval is not yet supported
//*****************************************************************
function _MSRS_handleResponse(requestid)
{
var request = this.requestList[requestid];
if (typeof(request) == 'undefined')
{
alert('Unknown request id.');
return;
}
request.status = this.rsapplet.getStatus();
if (request.status == MSRS_COMPLETED)
{
request.data = this.rsapplet.getData();
request.message = this.rsapplet.getMessage();
this.evaluateRequest(request);
if (request.status == MSRS_FAIL)
{
if (typeof(request.error_callback) == 'function')
{
this.pollCount--;
request.error_callback(request);
}
else
alert('Remote Scripting Error\n' + request.message);
}
else
{
if (typeof(request.callback) == 'function')
{
this.pollCount--;
request.callback(request);
}
}
this.rsapplet.endResponse();
this.requestList[request.id] = null;
}
else if (request.status == MSRS_FAIL)
{
request.message = this.rsapplet.getMessage();
if (typeof(request.error_callback) == 'function')
{
this.pollCount--;
request.error_callback(request);
}
this.rsapplet.endResponse();
this.requestList[request.id] = null;
}
else if (request.status == MSRS_PARTIAL)
{ // not handling partial data retrieval yet
}
else if (request.status == MSRS_PENDING)
{ // do nothing
}
}
//*****************************************************************
// function _MSRS_evaluateRequest(request)
//
// This function evaluates the data returned to the request.
// Marshalled jscript objects are re-evaluated on the client.
//*****************************************************************
function _MSRS_evaluateRequest(request)
{
var data = request.data;
var start_index = 0;
var end_index = 0;
var start_key = '<' + 'RETURN_VALUE';
var end_key = '<' + '/RETURN_VALUE>';
if ((start_index = data.indexOf(start_key)) != -1)
{
var data_start_index = data.indexOf('>',start_index) + 1;
end_index = data.indexOf(end_key,data_start_index);
if (end_index == -1)
end_index = data.length;
var metatag = data.substring(start_index,data_start_index);
if (metatag.indexOf('TYPE=SIMPLE') != -1)
{
request.return_value = unescape(data.substring(data_start_index,end_index));
}
else if (metatag.indexOf('TYPE=EVAL_OBJECT') != -1)
{
request.return_value = data.substring(data_start_index,end_index);
request.return_value = eval(unescape(request.return_value));
}
else if (metatag.indexOf('TYPE=ERROR') != -1)
{
request.status = MSRS_FAIL;
request.message = unescape(data.substring(data_start_index,end_index));
}
}
else
{
request.status = MSRS_FAIL;
request.message = 'REMOTE SCRIPTING ERROR: Page invoked does not support remote scripting.';
}
}
//*****************************************************************
// function _MSRS_setRequestPoll()
//
// Due to limitations in calling back into JScript from a worker
// thread of an applet, a polling mechanism is used to determine
// when a request has been completed. This function sets up
// a timer to kick the requestPollHandler at a later time.
//*****************************************************************
function _MSRS_setRequestPoll()
{
this.pollID = window.setTimeout('MSRS.requestPollHandler()',this.POLLING_PERIOD,'javascript');
}
//*****************************************************************
// function _MSRS_requestPollHandler()
//
// Due to limitations in calling back into JScript from a worker
// thread of an applet, a polling mechanism is used to determine
// when a request has been completed. This function is the
// handler which is kicked by a timer. It polls the applet to
// see if a response to a prior request is available.
//*****************************************************************
function _MSRS_requestPollHandler()
{
while (this.rsapplet.hasResponse())
{
this.handleResponse(this.rsapplet.getRequestID());
}
if (this.pollCount != 0)
this.setRequestPoll();
}
//*****************************************************************
// function _MSRS_escapePlus(value)
//
// This replaces all occurances of '+' with ''%2B' in the supplied
// string.
//*****************************************************************
function _MSRS__escapePlus(value)
{
for (var i = 0, newValue = ''; i < value.length; i++)
newValue += (value.charAt(i) == '+' ? '%2B' : value.charAt(i));
return newValue;
}
//*****************************************************************
// function _MSRS_buildURL(url,method,args)
//
// This builds the proper url entry point into the ASP page
// such that the intended server method with parameters gets
// invoked.
//*****************************************************************
function _MSRS_buildURL(url,method,args)
{
if (url == '') url = window.location.pathname;
if (typeof(method) == 'string')
{
url += '?_method=' + method;
url += '&_mtype=execute';
var params = '&pcount=0';
if (typeof(args) != 'undefined' && args.length)
{ // add parameters
params = '&pcount=' + args.length
for (var i = 0; i < args.length; i++)
{
var arg = args[i];
params += '&p' + i + '=' + _MSRS__escapePlus(escape(arg));
}
}
url += params;
}
return url;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -