From 1dfdcdf1f35d7c7da5925d9ec368aa9fa8ba777f Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Sat, 8 Nov 2008 11:09:54 +0000 Subject: [PATCH] add a bit more documentation to it --- .../ui/webui/templates/ajax/static/js/Rpc.js | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/deluge/ui/webui/templates/ajax/static/js/Rpc.js b/deluge/ui/webui/templates/ajax/static/js/Rpc.js index fe00c2e7d..daeb288df 100644 --- a/deluge/ui/webui/templates/ajax/static/js/Rpc.js +++ b/deluge/ui/webui/templates/ajax/static/js/Rpc.js @@ -1,16 +1,10 @@ /* - * Script: Rpc.js - * A JSON-RPC proxy built ontop of mootools. - * - * Copyright: - * Damien Churchill (c) 2008 - */ +Script: Rpc.js + A JSON-RPC proxy built ontop of mootools. + +Copyright: + Damien Churchill (c) 2008 -/* - * A class that creates a proxy for sending remote procedure calls over JSON - */ - -/* Class: JSON.RPC Class to create a proxy to a json-rpc interface on a server. @@ -21,7 +15,7 @@ alert(result); } }); - alert(client.hello_world({async: true;})); + alert(client.hello_world({async: false;})); client.add_name('Damien', { onSuccess: function(result) { alert(result); @@ -52,6 +46,17 @@ JSON.RPC = new Class({ } }, + /* + Property: _parseargs + Internal method for parsing the arguments given to the method + + Arguments: + args - A list of the methods arguments + + Returns: + An options object with the arguments set as options.params + + */ _parseargs: function(args) { var params = $A(args), options = params.getLast() if ($type(options) == 'object') { @@ -75,6 +80,21 @@ JSON.RPC = new Class({ return options }, + /* + Property: _execute + An internal method to make the call to the rpc page + + Arguements: + method - the name of the method + options - An options dict providing any additional options for the + call. + + Example: + alert(client.hello_world({async: false;})); + + Returns: + If not async returns the json result + */ _execute: function(method, options) { options = $pick(options, {}) options.params = $pick(options.params, [])