Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Proxy/Proxy.JSON.js') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | frontend/beta/js/Clipperz/PM/Proxy/Proxy.JSON.js | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.JSON.js b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.JSON.js new file mode 100755 index 0000000..889e1f1 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.JSON.js | |||
@@ -0,0 +1,100 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer to http://www.clipperz.com | ||
12 | |||
13 | * Javascript Crypto Library is free software: you can redistribute | ||
14 | it and/or modify it under the terms of the GNU Affero General Public | ||
15 | License as published by the Free Software Foundation, either version | ||
16 | 3 of the License, or (at your option) any later version. | ||
17 | |||
18 | * Javascript Crypto Library is distributed in the hope that it will | ||
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | See the GNU Affero General Public License for more details. | ||
22 | |||
23 | * You should have received a copy of the GNU Affero General Public | ||
24 | License along with Javascript Crypto Library. If not, see | ||
25 | <http://www.gnu.org/licenses/>. | ||
26 | |||
27 | */ | ||
28 | |||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | |||
32 | //============================================================================= | ||
33 | |||
34 | Clipperz.PM.Proxy.JSON = function(args) { | ||
35 | Clipperz.PM.Proxy.JSON.superclass.constructor.call(this, args); | ||
36 | |||
37 | this._url = args.url || Clipperz.Base.exception.raise('MandatoryParameter'); | ||
38 | |||
39 | return this; | ||
40 | } | ||
41 | |||
42 | YAHOO.extendX(Clipperz.PM.Proxy.JSON, Clipperz.PM.Proxy, { | ||
43 | |||
44 | 'toString': function() { | ||
45 | return "Clipperz.PM.Proxy.JSON"; | ||
46 | }, | ||
47 | |||
48 | //========================================================================= | ||
49 | |||
50 | 'url': function () { | ||
51 | return this._url; | ||
52 | }, | ||
53 | |||
54 | //========================================================================= | ||
55 | |||
56 | 'sendMessage': function(aFunctionName, someParameters) { | ||
57 | vardeferredResult; | ||
58 | var parameters; | ||
59 | |||
60 | parameters = { | ||
61 | method: aFunctionName, | ||
62 | // version: someParameters['version'], | ||
63 | // message: someParameters['message'], | ||
64 | parameters: Clipperz.Base.serializeJSON(someParameters) | ||
65 | }; | ||
66 | |||
67 | deferredResult = new MochiKit.Async.Deferred(); | ||
68 | deferredResult.addCallback(function (aValue) { | ||
69 | MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'remoteRequestSent'); | ||
70 | return aValue; | ||
71 | }); | ||
72 | deferredResult.addCallback(MochiKit.Async.doXHR, this.url(), { | ||
73 | method:'POST', | ||
74 | sendContent:MochiKit.Base.queryString(parameters), | ||
75 | headers:{"Content-Type":"application/x-www-form-urlencoded"} | ||
76 | }); | ||
77 | deferredResult.addCallback(function (aValue) { | ||
78 | MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'remoteRequestReceived'); | ||
79 | return aValue; | ||
80 | }); | ||
81 | // deferredResult.addCallback(MochiKit.Async.evalJSONRequest); | ||
82 | deferredResult.addCallback(MochiKit.Base.itemgetter('responseText')); | ||
83 | deferredResult.addCallback(Clipperz.Base.evalJSON); | ||
84 | deferredResult.addCallback(function (someValues) { | ||
85 | if (someValues['result'] == 'EXCEPTION') { | ||
86 | throw someValues['message']; | ||
87 | } | ||
88 | |||
89 | return someValues; | ||
90 | }) | ||
91 | // return MochiKit.Base.evalJSON(req.responseText); | ||
92 | deferredResult.callback(); | ||
93 | |||
94 | return deferredResult; | ||
95 | }, | ||
96 | |||
97 | //========================================================================= | ||
98 | __syntaxFix__: "syntax fix" | ||
99 | |||
100 | }); | ||