//
// rs.js - Remote Scripting JavaScript Include File
//
// Rewritten from jsrsClient.js, taken from
// http://www.ashleyit.com/rs/jsrs/test.htm (version 2.3)
// Copyright (C) 2001 by Brent Ashley
// Rewrite Copyright (C) 2004 by Alvaro Mendez
//
// Include this file inside your page like this:
// <script language='JavaScript' src='/scripts/rs.js'></script>
//
// This is the object to use, along with the Execute function (below)
var RS = new RemoteScripting();
var calltouse=0;
// Remote Scripting class.
// This class should NOT be instanciated -- use the global RS object.
function RemoteScripting()
{
this.pool = new Array();
this.poolSize = 0;
this.maxPoolSize = 200;
this.usePOST = true;
this.debug = false;
// Sniff the browser
if (document.layers)
this.browser = "NS";
else if (document.all)
{
var agent = navigator.userAgent.toLowerCase();
if (agent.indexOf("opera") != -1)
this.browser = "OPR";
else if (agent.indexOf("konqueror") != -1)
this.browser = "KONQ";
else
this.browser = "IE";
}
else if (document.getElementById)
this.browser = "MOZ";
else
this.browser = "OTHER";
}
// Executes a remote method found on a given URL.
// Usage: Execute(url,method,p1 ... pn,callback,error_callback)
// url : url of file containing method to invoke
// method : name of the Server-side method to be invoked
// p1...pn : any parameters to be passed to the Server-side method
// callback : optional JavaScript function to call on successful return.
// error_callback : optional JavaScript function to call on failed return.
// If not passed and an error occurs, an alert box is shown.
RemoteScripting.prototype.Execute = function(url, method)
{
var call = this.getAvailableCall();
var args = RemoteScripting.prototype.Execute.arguments;
var len = RemoteScripting.prototype.Execute.arguments.length;
var methodArgs = new Array();
for (var i = 2; i < len; i++)
{
if (typeof(args[i]) == 'function')
{
call.callback = args[i];
if (i + 1 < len)
call.error_callback = args[i + 1];
break;
}
methodArgs[i - 2] = args[i];
}
call.showIfDebugging();
if (this.usePOST && ((this.browser == 'IE') || (this.browser == 'MOZ')))
call.POST(url, method, methodArgs);
else
call.GET(url, method, methodArgs);
return this.id;
}
// Pops up a separate window containing Debug information.
// You can attach this to the F1 key for IE with onHelp = "return RS.showDebugInfo() in the body tag.
RemoteScripting.prototype.PopupDebugInfo = function()
{
var doc = window.open().document;
doc.open();
doc.write('<html><body>Pool Size: ' + this.poolSize + '<br><font face = "arial" size = "2"><b>');
for (var i in this.pool)
{
var call = this.pool[i];
doc.write('<hr>' + call.id + ' : ' + (call.busy ? 'busy' : 'available') + '<br>');
doc.write(call.container.document.location.pathname + '<br>');
doc.write(call.container.document.location.search + '<br>');
doc.write('<table border = "1"><tr><td>' + call.container.document.body.innerHTML + '</td></tr></table>');
}
doc.write('</table></body></html>');
doc.close();
return false;
}
// Retrieves an available Call object from the pool.
// This function is used internally and should be treated as private.
RemoteScripting.prototype.getAvailableCall = function()
{
for (var i in this.poolSize)
{
var call = this.pool['C' + (i + 1)];
if (!call.busy)
{
call.busy = true;
return this.pool[call.id];
}
}
// If we got here, there are no existing free calls
if (this.poolSize <= this.maxPoolSize)
{
var callID = "C" + (this.poolSize + 1);
this.pool[callID] = new RemoteScriptingCall(callID);
this.poolSize++;
return this.pool[callID];
}
else
{
var call = this.pool['C' + (calltouse + 1)];
call.busy = true;
return this.pool[call.id];
calltouse=(calltouse+1)%this.maxPoolSize;
}
//alert("RemoteScripting Error: Call pool is full!");
//return null;
}
// Remote Scripting Call class.
// This class should NOT be instanciated -- this is used by the RS object's pool.
function RemoteScriptingCall(callID)
{
this.id = callID;
this.busy = true;
this.callback = null;
this.error_callback = null;
switch (RS.browser)
{
case 'IE':
document.body.insertAdjacentHTML("afterBegin", '<span id = "SPAN' + callID + '"></span>');
var span = document.all("SPAN" + callID);
var html = '<iframe style = "width:800px" name = "' + callID + '" src = ""></iframe>';
span.innerHTML = html;
span.style.display = 'none';
this.container = window.frames[callID];
break;
case 'NS':
this.container = new Layer(100);
this.container.name = callID;
this.container.visibility = 'hidden';
this.container.clip.width = 100;
this.container.clip.height = 100;
break;
case 'MOZ':
case 'OPR':
var span = document.createElement('SPAN');
span.id = "SPAN" + callID;
document.body.appendChild(span);
var iframe = document.createElement('IFRAME');
iframe.id = callID;
iframe.name = callID;
iframe.style.width = 800;
iframe.style.height = 200;
span.appendChild(iframe);
this.container = iframe;
break;
case 'KONQ':
default:
var span = document.createElement('SPAN');
span.id = "SPAN" + callID;
document.body.appendChild(span);
var iframe = document.createElement('IFRAME');
iframe.id = callID;
iframe.name = callID;
iframe.style.width = 800;
iframe.style.height = 200;
span.appendChild(iframe);
this.container = iframe;
// Needs to be hidden for Konqueror, otherwise it'll appear on the page
span.style.display = none;
iframe.style.display = none;
iframe.style.visibility = hidden;
iframe.height = 0;
iframe.width = 0;
}
}
// Posts to the given url to have it invoke the given method.
// This function is used internally and should be treated as private.
RemoteScriptingCall.prototype.POST = function(url, method, args)
{
var d = new Date();
var unique = d.getTime() + '' + Math.floor(1000 * Math.random());
var doc = (RS.browser == "IE") ? this.container.document : this.container.contentDocument;
var paramSep = (url.lastIndexOf('?') < 0 ? '?' : '&');
doc.open();
doc.write('<html><body>');
doc.write('<form name="rsForm" method="post" target=""');
doc.write('action="' + url + paramSep + 'U=' + unique + '">');
doc.write('<input type="hidden" name="RC" value="' + this.id + '">');
// func and args are optional
if (method != null)
{
doc.write('<input type = "hidden" name = "M" value = "' + method + '">');
if (args != null)
{
if (typeof(args) == "string")
{
// single parameter
doc.write('<input type = "hidden" name = "P0" '
+ 'value = "[' + this.escapeParam(args) + ']">');
}
else
{
// assume args is array of strings
for (var i = 0; i < args.length; i++)
{
doc.write('<input type = "hidden" name = "P' + i + '" '
+ 'value = "[' + this.escapeParam(args[i]) + ']">');
}
} // parm type
} // args
} // method
doc.write('</form></body></html>');
doc.close();
doc.forms['rsForm'].submit();
}
// Navigates to the given url to have it invoke the given method.
// This function is used internally and should be treated as private.
RemoteScriptingCall.prototype.GET = function(url, method, args)
{
// build URL to call
var URL = url;
var paramSep = (url.lastIndexOf('?') < 0 ? '?' : '&');
// always send call
URL += paramSep + "RC=" + this.id;
// method and args are optional
if (method != null)
{
URL += "&M=" + escape(method);
if (args != null)
{
if (typeof(args) == "string")
{
// single parameter
URL += "&P0=[" + escape(ar
jfxxi.rar_ASP.NET 聊天
版权申诉
118 浏览量
2022-09-19
22:48:16
上传
评论
收藏 18KB RAR 举报
御道御小黑
- 粉丝: 61
- 资源: 1万+
最新资源
- 基于Javascript和Python的微商城项目设计源码 - MicroMall
- 基于Java的网上订餐系统设计源码 - online ordering system
- 基于Javascript的超级美眉网络资源管理应用模块设计源码
- 基于Typescript和PHP的编程知识储备库设计源码 - study-php
- Screenshot_2024-05-28-11-40-58-177_com.tencent.mm.jpg
- 基于Dart的Flutter小提琴调音器APP设计源码 - violinhelper
- 基于JavaScript和CSS的随寻订购网页设计源码 - web-order
- 基于MATLAB的声纹识别系统设计源码 - VoiceprintRecognition
- 基于Java的微服务插件集合设计源码 - wsy-plugins
- 基于Vue和微信小程序的监理日志系统设计源码 - supervisionLog
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0