summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/Async.js
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2011-10-23 17:36:57 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2011-10-23 17:36:57 (UTC)
commit67455b069c4c9ec493f9cef76017e172a430a7d4 (patch) (unidiff)
tree0b287debfeeb0819b3df9dd02860cd84103e25b3 /frontend/gamma/js/Clipperz/Async.js
parentb312e037ebba7c94abea9661bcf62c52b7d73fbf (diff)
downloadclipperz-67455b069c4c9ec493f9cef76017e172a430a7d4.zip
clipperz-67455b069c4c9ec493f9cef76017e172a430a7d4.tar.gz
clipperz-67455b069c4c9ec493f9cef76017e172a430a7d4.tar.bz2
Integration of PHP backend with /beta and /gamma front ends
Fixed PHP backend and /beta code to handle request and data format compatible with /gamma. At the moment adding/deleting/editing records seem to work fine.
Diffstat (limited to 'frontend/gamma/js/Clipperz/Async.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/Async.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/frontend/gamma/js/Clipperz/Async.js b/frontend/gamma/js/Clipperz/Async.js
index 7c9d783..97d8ecf 100644
--- a/frontend/gamma/js/Clipperz/Async.js
+++ b/frontend/gamma/js/Clipperz/Async.js
@@ -1,216 +1,222 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 it and/or modify it under the terms of the GNU Affero General Public 11 it and/or modify it under the terms of the GNU Affero General Public
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* You should have received a copy of the GNU Affero General Public 20* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24*/ 24*/
25 25
26//Clipperz.Async = MochiKit.Async; 26//Clipperz.Async = MochiKit.Async;
27 27
28 28
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.Async) == 'undefined') { Clipperz.Async = {}; } 30if (typeof(Clipperz.Async) == 'undefined') { Clipperz.Async = {}; }
31 31
32Clipperz.Async.VERSION = "0.1"; 32Clipperz.Async.VERSION = "0.1";
33Clipperz.Async.NAME = "Clipperz.Async"; 33Clipperz.Async.NAME = "Clipperz.Async";
34 34
35Clipperz.Async.Deferred = function(aName, args) { 35Clipperz.Async.Deferred = function(aName, args) {
36 args = args || {}; 36 args = args || {};
37 37
38 Clipperz.Async.Deferred.superclass.constructor.call(this, args.canceller); 38 Clipperz.Async.Deferred.superclass.constructor.call(this, args.canceller);
39 39
40 this._args = args; 40 this._args = args;
41 this._name = aName || "Anonymous deferred"; 41 this._name = aName || "Anonymous deferred";
42 this._count = 0; 42 this._count = 0;
43 this._shouldTrace = ((CLIPPERZ_DEFERRED_TRACING_ENABLED === true) || (args.trace === true)); 43 this._shouldTrace = ((CLIPPERZ_DEFERRED_TRACING_ENABLED === true) || (args.trace === true));
44 this._vars = null; 44 this._vars = null;
45 45
46 return this; 46 return this;
47} 47}
48 48
49//============================================================================= 49//=============================================================================
50 50
51Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, { 51Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, {
52 52
53 'name': function () { 53 'name': function () {
54 return this._name; 54 return this._name;
55 }, 55 },
56 56
57 'args': function () { 57 'args': function () {
58 return this._args; 58 return this._args;
59 }, 59 },
60 60
61 //----------------------------------------------------------------------------- 61 //-----------------------------------------------------------------------------
62 62
63 'callback': function (aValue) { 63 'callback': function (aValue) {
64 if (this._shouldTrace) { 64 if (this._shouldTrace) {
65 Clipperz.log("CALLBACK " + this._name, aValue); 65 //Clipperz.log("CALLBACK " + this._name, aValue);
66 console.log("CALLBACK " + this._name, aValue);
66 } 67 }
67 68
68 if (this.chained == false) { 69 if (this.chained == false) {
69 var message; 70 var message;
70 71
71 message = "ERROR [" + this._name + "]"; 72 message = "ERROR [" + this._name + "]";
72 this.addErrback(function(aResult) { 73 this.addErrback(function(aResult) {
73 if (! (aResult instanceof MochiKit.Async.CancelledError)) { 74 if (! (aResult instanceof MochiKit.Async.CancelledError)) {
74 Clipperz.log(message, aResult); 75 Clipperz.log(message, aResult);
75 } 76 }
76 return aResult; 77 return aResult;
77 }); 78 });
78 79
79 if (this._shouldTrace) { 80 if (this._shouldTrace) {
80 var resultMessage; 81 var resultMessage;
81 82
82 resultMessage = "RESULT " + this._name + " <=="; 83 resultMessage = "RESULT " + this._name + " <==";
83 // this.addCallback(function(aResult) { 84 // this.addCallback(function(aResult) {
84 Clipperz.Async.Deferred.superclass.addCallback.call(this, function(aResult) { 85 Clipperz.Async.Deferred.superclass.addCallback.call(this, function(aResult) {
85 Clipperz.log(resultMessage, aResult); 86 //Clipperz.log(resultMessage, aResult);
87 console.log(resultMessage, aResult);
86 88
87 return aResult; 89 return aResult;
88 }); 90 });
89 } 91 }
90 } 92 }
91 93
92 if (CLIPPERZ_DEFERRED_CALL_LOGGING_ENABLED === true) { 94 if (CLIPPERZ_DEFERRED_CALL_LOGGING_ENABLED === true) {
93 Clipperz.log("callback " + this._name, this); 95 Clipperz.log("callback " + this._name, this);
94 } 96 }
95 97
96 return Clipperz.Async.Deferred.superclass.callback.apply(this, arguments); 98 return Clipperz.Async.Deferred.superclass.callback.apply(this, arguments);
97 }, 99 },
98 100
99 //----------------------------------------------------------------------------- 101 //-----------------------------------------------------------------------------
100 102
101 'addCallback': function () { 103 'addCallback': function () {
102 var message; 104 var message;
103 105
104 if (this._shouldTrace) { 106 if (this._shouldTrace) {
105 this._count ++; 107 this._count ++;
106 message = "[" + this._count + "] " + this._name + " "; 108 message = "[" + this._count + "] " + this._name + " ";
107 // this.addBoth(function(aResult) {Clipperz.log(message + "-->", aResult); return aResult;}); 109 // this.addBoth(function(aResult) {Clipperz.log(message + "-->", aResult); return aResult;});
108 this.addCallbacks( 110 this.addCallbacks(
109 function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, 111 //function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;},
110 function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;} 112 function(aResult) {console.log("-OK- " + message + "-->"/*, aResult*/); return aResult;},
113 //function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;}
114 function(aResult) {console.log("FAIL " + message + "-->"/*, aResult*/); return aResult;}
111 ); 115 );
112 } 116 }
113 117
114 Clipperz.Async.Deferred.superclass.addCallback.apply(this, arguments); 118 Clipperz.Async.Deferred.superclass.addCallback.apply(this, arguments);
115 119
116 if (this._shouldTrace) { 120 if (this._shouldTrace) {
117 // this.addBoth(function(aResult) {Clipperz.log(message + "<--", aResult); return aResult;}); 121 // this.addBoth(function(aResult) {Clipperz.log(message + "<--", aResult); return aResult;});
118 this.addCallbacks( 122 this.addCallbacks(
119 function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;}, 123 //function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;},
120 function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;} 124 function(aResult) {console.log("-OK- " + message + "<--", aResult); return aResult;},
125 //function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;}
126 function(aResult) {console.log("FAIL " + message + "<--", aResult); return aResult;}
121 ); 127 );
122 } 128 }
123 }, 129 },
124 130
125 //============================================================================= 131 //=============================================================================
126 132
127 'addCallbackPass': function() { 133 'addCallbackPass': function() {
128 var passFunction; 134 var passFunction;
129 135
130 passFunction = MochiKit.Base.partial.apply(null, arguments); 136 passFunction = MochiKit.Base.partial.apply(null, arguments);
131 137
132 this.addCallback(function() { 138 this.addCallback(function() {
133 var result; 139 var result;
134 140
135 result = arguments[arguments.length -1]; 141 result = arguments[arguments.length -1];
136 passFunction(); 142 passFunction();
137 143
138 return result; 144 return result;
139 }); 145 });
140 }, 146 },
141 147
142 //----------------------------------------------------------------------------- 148 //-----------------------------------------------------------------------------
143 149
144 'addErrbackPass': function() { 150 'addErrbackPass': function() {
145 var passFunction; 151 var passFunction;
146 152
147 passFunction = MochiKit.Base.partial.apply(null, arguments); 153 passFunction = MochiKit.Base.partial.apply(null, arguments);
148 154
149 this.addErrback(function() { 155 this.addErrback(function() {
150 var result; 156 var result;
151 157
152 result = arguments[arguments.length -1]; 158 result = arguments[arguments.length -1];
153 passFunction(); 159 passFunction();
154 160
155 return result; 161 return result;
156 }); 162 });
157 }, 163 },
158 164
159 //----------------------------------------------------------------------------- 165 //-----------------------------------------------------------------------------
160 166
161 'addBothPass': function() { 167 'addBothPass': function() {
162 var passFunction; 168 var passFunction;
163 169
164 passFunction = MochiKit.Base.partial.apply(null, arguments); 170 passFunction = MochiKit.Base.partial.apply(null, arguments);
165 171
166 this.addBoth(function() { 172 this.addBoth(function() {
167 var result; 173 var result;
168 174
169 result = arguments[arguments.length -1]; 175 result = arguments[arguments.length -1];
170 passFunction(); 176 passFunction();
171 177
172 return result; 178 return result;
173 }); 179 });
174 }, 180 },
175 181
176 //----------------------------------------------------------------------------- 182 //-----------------------------------------------------------------------------
177 183
178 'addIf': function (aThenBlock, anElseBlock) { 184 'addIf': function (aThenBlock, anElseBlock) {
179 this.addCallback(MochiKit.Base.bind(function (aValue) { 185 this.addCallback(MochiKit.Base.bind(function (aValue) {
180 var deferredResult; 186 var deferredResult;
181 187
182 if (!MochiKit.Base.isUndefinedOrNull(aValue) && aValue) { 188 if (!MochiKit.Base.isUndefinedOrNull(aValue) && aValue) {
183 deferredResult = Clipperz.Async.callbacks(this._name + " <then>", aThenBlock, null, aValue); 189 deferredResult = Clipperz.Async.callbacks(this._name + " <then>", aThenBlock, null, aValue);
184 } else { 190 } else {
185 deferredResult = Clipperz.Async.callbacks(this._name + " <else>", anElseBlock, null, aValue); 191 deferredResult = Clipperz.Async.callbacks(this._name + " <else>", anElseBlock, null, aValue);
186 } 192 }
187 193
188 return deferredResult; 194 return deferredResult;
189 })) 195 }))
190 }, 196 },
191 197
192 //----------------------------------------------------------------------------- 198 //-----------------------------------------------------------------------------
193 199
194 'addMethod': function () { 200 'addMethod': function () {
195 this.addCallback(MochiKit.Base.method.apply(this, arguments)); 201 this.addCallback(MochiKit.Base.method.apply(this, arguments));
196 }, 202 },
197 203
198 //----------------------------------------------------------------------------- 204 //-----------------------------------------------------------------------------
199 205
200 'addMethodcaller': function () { 206 'addMethodcaller': function () {
201 this.addCallback(MochiKit.Base.methodcaller.apply(this, arguments)); 207 this.addCallback(MochiKit.Base.methodcaller.apply(this, arguments));
202 }, 208 },
203 209
204 //============================================================================= 210 //=============================================================================
205 211
206 'addLog': function (aLog) { 212 'addLog': function (aLog) {
207 if (CLIPPERZ_DEFERRED_LOGGING_ENABLED) { 213 if (CLIPPERZ_DEFERRED_LOGGING_ENABLED) {
208 this.addBothPass(function(res) {Clipperz.log(aLog + " ", res);}); 214 this.addBothPass(function(res) {Clipperz.log(aLog + " ", res);});
209 // this.addBothPass(function(res) {console.log(aLog + " ", res);}); 215 // this.addBothPass(function(res) {console.log(aLog + " ", res);});
210 } 216 }
211 }, 217 },
212 218
213 //============================================================================= 219 //=============================================================================
214 220
215 'acquireLock': function (aLock) { 221 'acquireLock': function (aLock) {
216 // this.addCallback(function (aResult) { 222 // this.addCallback(function (aResult) {
@@ -313,192 +319,193 @@ Clipperz.Async.DeferredSynchronizer = function(aName, someMethods) {
313 result = MochiKit.Async.fail(someResults); 319 result = MochiKit.Async.fail(someResults);
314 } 320 }
315 } else { 321 } else {
316 result = MochiKit.Async.fail(cancels[0]); 322 result = MochiKit.Async.fail(cancels[0]);
317 } 323 }
318 324
319 return result; 325 return result;
320 }/*, this._methodResults */); 326 }/*, this._methodResults */);
321 327
322 return this; 328 return this;
323} 329}
324 330
325MochiKit.Base.update(Clipperz.Async.DeferredSynchronizer.prototype, { 331MochiKit.Base.update(Clipperz.Async.DeferredSynchronizer.prototype, {
326 332
327 //----------------------------------------------------------------------------- 333 //-----------------------------------------------------------------------------
328 334
329 'name': function() { 335 'name': function() {
330 return this._name; 336 return this._name;
331 }, 337 },
332 338
333 //----------------------------------------------------------------------------- 339 //-----------------------------------------------------------------------------
334 340
335 'methods': function() { 341 'methods': function() {
336 return this._methods; 342 return this._methods;
337 }, 343 },
338 344
339 'methodResults': function() { 345 'methodResults': function() {
340 return this._methodResults; 346 return this._methodResults;
341 }, 347 },
342 348
343 //----------------------------------------------------------------------------- 349 //-----------------------------------------------------------------------------
344 350
345 'result': function() { 351 'result': function() {
346 return this._result; 352 return this._result;
347 }, 353 },
348 354
349 //----------------------------------------------------------------------------- 355 //-----------------------------------------------------------------------------
350 356
351 'numberOfMethodsDone':function() { 357 'numberOfMethodsDone':function() {
352 return this._numberOfMethodsDone; 358 return this._numberOfMethodsDone;
353 }, 359 },
354 360
355 'incrementNumberOfMethodsDone': function() { 361 'incrementNumberOfMethodsDone': function() {
356 this._numberOfMethodsDone ++; 362 this._numberOfMethodsDone ++;
357 }, 363 },
358 364
359 //----------------------------------------------------------------------------- 365 //-----------------------------------------------------------------------------
360 366
361 'run': function(args, aValue) { 367 'run': function(args, aValue) {
362 var deferredResults; 368 var deferredResults;
363 var i, c; 369 var i, c;
364 370
365 deferredResults = []; 371 deferredResults = [];
366 args = args || {}; 372 args = args || {};
367 373
368 c = this.methods().length; 374 c = this.methods().length;
369 for (i=0; i<c; i++) { 375 for (i=0; i<c; i++) {
370 var deferredResult; 376 var deferredResult;
371 varmethodCalls; 377 varmethodCalls;
372 var ii, cc; 378 var ii, cc;
373 379
374//console.log("TYPEOF", typeof(this.methods()[i])); 380//console.log("TYPEOF", typeof(this.methods()[i]));
375 if (typeof(this.methods()[i]) == 'function') { 381 if (typeof(this.methods()[i]) == 'function') {
376 methodCalls = [ this.methods()[i] ]; 382 methodCalls = [ this.methods()[i] ];
377 } else { 383 } else {
378 methodCalls = this.methods()[i]; 384 methodCalls = this.methods()[i];
379 } 385 }
380 386
381 cc = methodCalls.length; 387 cc = methodCalls.length;
382 deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.DeferredSynchronizer.run => " + this.name() + "[" + i + "]", args); 388 deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.DeferredSynchronizer.run => " + this.name() + "[" + i + "]", args);
383 for (ii=0; ii<cc; ii++) { 389 for (ii=0; ii<cc; ii++) {
384 deferredResult.addCallback(methodCalls[ii]); 390 deferredResult.addCallback(methodCalls[ii]);
385 } 391 }
386 deferredResult.addBoth(MochiKit.Base.method(this, 'handleMethodCallDone', i)); 392 deferredResult.addBoth(MochiKit.Base.method(this, 'handleMethodCallDone', i));
387 393
388 deferredResults.push(deferredResult); 394 deferredResults.push(deferredResult);
389 } 395 }
390 396
391 for (i=0; i<c; i++) { 397 for (i=0; i<c; i++) {
392 deferredResults[i].callback(aValue); 398 deferredResults[i].callback(aValue);
393 } 399 }
394 400
395 return this.result(); 401 return this.result();
396 }, 402 },
397 403
398 //----------------------------------------------------------------------------- 404 //-----------------------------------------------------------------------------
399 405
400 'handleMethodCallDone': function(anIndexValue, aResult) { 406 'handleMethodCallDone': function(anIndexValue, aResult) {
401 this.incrementNumberOfMethodsDone(); 407 this.incrementNumberOfMethodsDone();
402 this.methodResults()[anIndexValue] = aResult; 408 this.methodResults()[anIndexValue] = aResult;
403 409
404 if (this.numberOfMethodsDone() < this.methods().length) { 410 if (this.numberOfMethodsDone() < this.methods().length) {
405 //nothing to do here other than possibly log something 411 //nothing to do here other than possibly log something
406 } else if (this.numberOfMethodsDone() == this.methods().length) { 412 } else if (this.numberOfMethodsDone() == this.methods().length) {
407 this.result().callback(); 413 this.result().callback();
408 } else if (this.numberOfMethodsDone() > this.methods().length) { 414 } else if (this.numberOfMethodsDone() > this.methods().length) {
415 alert("Clipperz.Async.Deferred.handleMethodCallDone -> WTF!");
409 //WTF!!! :( 416 //WTF!!! :(
410 } 417 }
411 418
412 }, 419 },
413 420
414 //----------------------------------------------------------------------------- 421 //-----------------------------------------------------------------------------
415 422
416 __syntaxFix__: "syntax fix" 423 __syntaxFix__: "syntax fix"
417}); 424});
418 425
419//############################################################################# 426//#############################################################################
420 427
421MochiKit.Base.update(Clipperz.Async, { 428MochiKit.Base.update(Clipperz.Async, {
422 429
423 'callbacks': function (aName, someFunctions, someArguments, aCallbackValue) { 430 'callbacks': function (aName, someFunctions, someArguments, aCallbackValue) {
424 var deferredResult; 431 var deferredResult;
425 var i, c; 432 var i, c;
426 433
427 deferredResult = new Clipperz.Async.Deferred(aName, someArguments); 434 deferredResult = new Clipperz.Async.Deferred(aName, someArguments);
428 c = someFunctions.length; 435 c = someFunctions.length;
429 for (i=0; i<c; i++) { 436 for (i=0; i<c; i++) {
430 deferredResult.addCallback(someFunctions[i]); 437 deferredResult.addCallback(someFunctions[i]);
431 } 438 }
432 deferredResult.callback(aCallbackValue); 439 deferredResult.callback(aCallbackValue);
433 440
434 return deferredResult; 441 return deferredResult;
435 }, 442 },
436 443
437 //------------------------------------------------------------------------- 444 //-------------------------------------------------------------------------
438 445
439 'forkAndJoin': function (aName, someMethods, args) { 446 'forkAndJoin': function (aName, someMethods, args) {
440 return MochiKit.Base.partial(function (aName, someMethods, args, aValue) { 447 return MochiKit.Base.partial(function (aName, someMethods, args, aValue) {
441 var synchronizer; 448 var synchronizer;
442 varresult; 449 varresult;
443 450
444 args = args || {}; 451 args = args || {};
445 synchronizer = new Clipperz.Async.DeferredSynchronizer(aName, someMethods); 452 synchronizer = new Clipperz.Async.DeferredSynchronizer(aName, someMethods);
446 result = synchronizer.run(args, aValue); 453 result = synchronizer.run(args, aValue);
447 454
448 return result; 455 return result;
449 }, aName, someMethods, args); 456 }, aName, someMethods, args);
450 }, 457 },
451 458
452 //------------------------------------------------------------------------- 459 //-------------------------------------------------------------------------
453 460
454 'collectResults': function(aName, someRequests, args) { 461 'collectResults': function(aName, someRequests, args) {
455 return MochiKit.Base.partial(function(aName, someRequests, args, aValue) { 462 return MochiKit.Base.partial(function(aName, someRequests, args, aValue) {
456 var deferredResult; 463 var deferredResult;
457 var requestKeys; 464 var requestKeys;
458 var methods; 465 var methods;
459 466
460 requestKeys = MochiKit.Base.keys(someRequests); 467 requestKeys = MochiKit.Base.keys(someRequests);
461 methods = MochiKit.Base.values(someRequests); 468 methods = MochiKit.Base.values(someRequests);
462 469
463 deferredResult = new Clipperz.Async.Deferred(aName, args); 470 deferredResult = new Clipperz.Async.Deferred(aName, args);
464 deferredResult.addCallback(Clipperz.Async.forkAndJoin(aName + " [inner forkAndJoin]", methods, args)); 471 deferredResult.addCallback(Clipperz.Async.forkAndJoin(aName + " [inner forkAndJoin]", methods, args));
465 deferredResult.addBoth(function(someResults) { 472 deferredResult.addBoth(function(someResults) {
466 var returnFunction; 473 var returnFunction;
467 var results; 474 var results;
468 var i,c; 475 var i,c;
469 var result; 476 var result;
470 477
471 if (someResults instanceof MochiKit.Async.CancelledError) { 478 if (someResults instanceof MochiKit.Async.CancelledError) {
472 returnFunction = MochiKit.Async.fail; 479 returnFunction = MochiKit.Async.fail;
473 result = someResults; 480 result = someResults;
474 } else { 481 } else {
475 if (someResults instanceof Error) { 482 if (someResults instanceof Error) {
476 returnFunction = MochiKit.Async.fail; 483 returnFunction = MochiKit.Async.fail;
477 results = someResults['message']; 484 results = someResults['message'];
478 } else { 485 } else {
479 returnFunction = MochiKit.Async.succeed; 486 returnFunction = MochiKit.Async.succeed;
480 results = someResults; 487 results = someResults;
481 } 488 }
482 489
483 result = {}; 490 result = {};
484 491
485 c = requestKeys.length; 492 c = requestKeys.length;
486 for (i=0; i<c; i++) { 493 for (i=0; i<c; i++) {
487 result[requestKeys[i]] = results[i]; 494 result[requestKeys[i]] = results[i];
488 } 495 }
489 } 496 }
490 497
491 return returnFunction.call(null, result); 498 return returnFunction.call(null, result);
492 }); 499 });
493 deferredResult.callback(aValue); 500 deferredResult.callback(aValue);
494 501
495 return deferredResult; 502 return deferredResult;
496 }, aName, someRequests, args); 503 }, aName, someRequests, args);
497 }, 504 },
498 505
499 //------------------------------------------------------------------------- 506 //-------------------------------------------------------------------------
500 507
501 'collectAll': function (someDeferredObjects) { 508 'collectAll': function (someDeferredObjects) {
502 var deferredResult; 509 var deferredResult;
503 510
504 deferredResult = new MochiKit.Async.DeferredList(someDeferredObjects, false, false, false); 511 deferredResult = new MochiKit.Async.DeferredList(someDeferredObjects, false, false, false);