[z3-checkins] r27114 - z3/jsonserver/branch/merge/browser
reebalazs at codespeak.net
reebalazs at codespeak.net
Fri May 12 11:17:11 CEST 2006
Author: reebalazs
Date: Fri May 12 11:17:10 2006
New Revision: 27114
Modified:
z3/jsonserver/branch/merge/browser/json.js
Log:
Clean up instantiation of JSONMethod
Modified: z3/jsonserver/branch/merge/browser/json.js
==============================================================================
--- z3/jsonserver/branch/merge/browser/json.js (original)
+++ z3/jsonserver/branch/merge/browser/json.js Fri May 12 11:17:10 2006
@@ -52,21 +52,6 @@
return new json.SupplementWrapper(data, id);
}
-// Direct method creation, by creating an implicit proxy
-// if methodName == '' then the url is taken as full url
-function makeJSONRPCMethod(url, methodName, callback, error, timeout, supplementData,
- requestId, requestManager, user, pass) {
- if (typeof(methodName) == 'undefined' || methodName == null || methodName == '') {
- var pieces = url.split('/');
- methodName = pieces.pop();
- url = pieces.join('/');
- }
- var proxy = new JSONRPC(url);
- proxy.addMethod(methodName, callback, error, timeout, supplementData,
- requestId, requestManager, user, pass);
- return proxy[methodName];
-}
-
function JSONRPC(url) {
this._url = url;
this._methods = new Array();
@@ -79,21 +64,6 @@
}
JSONRPC.prototype.addMethod = function(name, callback, errHandler, timeout, supplementData, requestId, requestManager) {
- if (typeof(errHandler) == 'undefined') {
- errHandler = null;
- }
- if (typeof(timeout) == 'undefined') {
- timeout = null;
- }
- if (typeof(supplementData) == 'undefined') {
- supplementData = null;
- }
- if (typeof(requestId) == 'undefined' || requestId == null) {
- requestId = "jsonRequest";
- }
- if (typeof(requestManager) == 'undefined' || requestManager == null) {
- requestManager = _dummyRequestManager;
- }
var self = this;
if(!self[name]){
var method = new JSONRPCMethod(this._url, name, callback, errHandler, timeout, supplementData, requestId,
@@ -165,6 +135,28 @@
function JSONRPCMethod(url, methodName, callback, errHandler, timeout, supplementData, requestId,
requestManager, user, pass) {
+ // Make it possible to call it with no methodName, and just an url.
+ // if methodName == null, it will be figured out from the url.
+ if (typeof(methodName) == 'undefined' || methodName == null || methodName == '') {
+ var pieces = url.split('/');
+ methodName = pieces.pop();
+ url = pieces.join('/');
+ }
+ if (typeof(errHandler) == 'undefined') {
+ errHandler = null;
+ }
+ if (typeof(timeout) == 'undefined') {
+ timeout = null;
+ }
+ if (typeof(supplementData) == 'undefined') {
+ supplementData = null;
+ }
+ if (typeof(requestId) == 'undefined' || requestId == null) {
+ requestId = "jsonRequest";
+ }
+ if (typeof(requestManager) == 'undefined' || requestManager == null) {
+ requestManager = _dummyRequestManager;
+ }
this.methodName = methodName;
this.callback = callback;
this.errHandler = errHandler;
More information about the z3-checkins
mailing list