summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/Async.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/Async.js') (more/less context) (show whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/Async.js50
1 files changed, 20 insertions, 30 deletions
diff --git a/frontend/gamma/js/Clipperz/Async.js b/frontend/gamma/js/Clipperz/Async.js
index f7a9517..d525453 100644
--- a/frontend/gamma/js/Clipperz/Async.js
+++ b/frontend/gamma/js/Clipperz/Async.js
@@ -1,28 +1,26 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer to http://www.clipperz.com.
9 8
10* Clipperz Community Edition is free software: you can redistribute 9* Clipperz is free software: you can redistribute it and/or modify it
11 it and/or modify it under the terms of the GNU Affero General Public 10 under the terms of the GNU Affero General Public License as published
12 License as published by the Free Software Foundation, either version 11 by the Free Software Foundation, either version 3 of the License, or
13 3 of the License, or (at your option) any later version. 12 (at your option) any later version.
14 13
15* Clipperz Community Edition is distributed in the hope that it will 14* Clipperz is distributed in the hope that it will be useful, but
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 15 WITHOUT ANY WARRANTY; without even the implied warranty of
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 17 See the GNU Affero General Public License for more details.
19 18
20* You should have received a copy of the GNU Affero General Public 19* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see 20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
22 <http://www.gnu.org/licenses/>.
23 21
24*/ 22*/
25 23
26//Clipperz.Async = MochiKit.Async; 24//Clipperz.Async = MochiKit.Async;
27 25
28 26
@@ -59,14 +57,13 @@ Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, {
59 }, 57 },
60 58
61 //----------------------------------------------------------------------------- 59 //-----------------------------------------------------------------------------
62 60
63 'callback': function (aValue) { 61 'callback': function (aValue) {
64 if (this._shouldTrace) { 62 if (this._shouldTrace) {
65 //Clipperz.log("CALLBACK " + this._name, aValue); 63 Clipperz.log("CALLBACK " + this._name, aValue);
66 console.log("CALLBACK " + this._name, aValue);
67 } 64 }
68 65
69 if (this.chained == false) { 66 if (this.chained == false) {
70 var message; 67 var message;
71 68
72 message = "ERROR [" + this._name + "]"; 69 message = "ERROR [" + this._name + "]";
@@ -80,15 +77,13 @@ Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, {
80 if (this._shouldTrace) { 77 if (this._shouldTrace) {
81 var resultMessage; 78 var resultMessage;
82 79
83 resultMessage = "RESULT " + this._name + " <=="; 80 resultMessage = "RESULT " + this._name + " <==";
84 // this.addCallback(function(aResult) { 81 // this.addCallback(function(aResult) {
85 Clipperz.Async.Deferred.superclass.addCallback.call(this, function(aResult) { 82 Clipperz.Async.Deferred.superclass.addCallback.call(this, function(aResult) {
86 //Clipperz.log(resultMessage, aResult); 83 Clipperz.log(resultMessage, aResult);
87 console.log(resultMessage, aResult);
88
89 return aResult; 84 return aResult;
90 }); 85 });
91 } 86 }
92 } 87 }
93 88
94 if (CLIPPERZ_DEFERRED_CALL_LOGGING_ENABLED === true) { 89 if (CLIPPERZ_DEFERRED_CALL_LOGGING_ENABLED === true) {
@@ -105,28 +100,24 @@ Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, {
105 100
106 if (this._shouldTrace) { 101 if (this._shouldTrace) {
107 this._count ++; 102 this._count ++;
108 message = "[" + this._count + "] " + this._name + " "; 103 message = "[" + this._count + "] " + this._name + " ";
109 // this.addBoth(function(aResult) {Clipperz.log(message + "-->", aResult); return aResult;}); 104 // this.addBoth(function(aResult) {Clipperz.log(message + "-->", aResult); return aResult;});
110 this.addCallbacks( 105 this.addCallbacks(
111 //function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, 106 function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;},
112 function(aResult) {console.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, 107 function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;}
113 //function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;}
114 function(aResult) {console.log("FAIL " + message + "-->"/*, aResult*/); return aResult;}
115 ); 108 );
116 } 109 }
117 110
118 Clipperz.Async.Deferred.superclass.addCallback.apply(this, arguments); 111 Clipperz.Async.Deferred.superclass.addCallback.apply(this, arguments);
119 112
120 if (this._shouldTrace) { 113 if (this._shouldTrace) {
121 // this.addBoth(function(aResult) {Clipperz.log(message + "<--", aResult); return aResult;}); 114 // this.addBoth(function(aResult) {Clipperz.log(message + "<--", aResult); return aResult;});
122 this.addCallbacks( 115 this.addCallbacks(
123 //function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;}, 116 function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;},
124 function(aResult) {console.log("-OK- " + message + "<--", aResult); return aResult;}, 117 function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;}
125 //function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;}
126 function(aResult) {console.log("FAIL " + message + "<--", aResult); return aResult;}
127 ); 118 );
128 } 119 }
129 }, 120 },
130 121
131 //============================================================================= 122 //=============================================================================
132 123
@@ -209,13 +200,12 @@ Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, {
209 200
210 //============================================================================= 201 //=============================================================================
211 202
212 'addLog': function (aLog) { 203 'addLog': function (aLog) {
213 if (CLIPPERZ_DEFERRED_LOGGING_ENABLED) { 204 if (CLIPPERZ_DEFERRED_LOGGING_ENABLED) {
214 this.addBothPass(function(res) {Clipperz.log(aLog + " ", res);}); 205 this.addBothPass(function(res) {Clipperz.log(aLog + " ", res);});
215 // this.addBothPass(function(res) {console.log(aLog + " ", res);});
216 } 206 }
217 }, 207 },
218 208
219 //============================================================================= 209 //=============================================================================
220 210
221 'acquireLock': function (aLock) { 211 'acquireLock': function (aLock) {
@@ -234,13 +224,13 @@ Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, {
234 // return Clipperz.Async.callbacks("Clipperz.Async.release <ok>", [ 224 // return Clipperz.Async.callbacks("Clipperz.Async.release <ok>", [
235 // MochiKit.Base.method(aLock, 'release'), 225 // MochiKit.Base.method(aLock, 'release'),
236 // MochiKit.Base.partial(MochiKit.Async.succeed, aResult) 226 // MochiKit.Base.partial(MochiKit.Async.succeed, aResult)
237 // ], {trace:false}); 227 // ], {trace:false});
238 // }); 228 // });
239 // this.addErrback(function (aResult) { 229 // this.addErrback(function (aResult) {
240///console.log("releaseLock.addErrback:", aResult); 230///Clipperz.log("releaseLock.addErrback:", aResult);
241 // return Clipperz.Async.callbacks("Clipperz.Async.release <fail>", [ 231 // return Clipperz.Async.callbacks("Clipperz.Async.release <fail>", [
242 // MochiKit.Base.method(aLock, 'release'), 232 // MochiKit.Base.method(aLock, 'release'),
243 // MochiKit.Base.partial(MochiKit.Async.fail, aResult) 233 // MochiKit.Base.partial(MochiKit.Async.fail, aResult)
244 // ], {trace:false}); 234 // ], {trace:false});
245 // }); 235 // });
246 236
@@ -374,13 +364,13 @@ MochiKit.Base.update(Clipperz.Async.DeferredSynchronizer.prototype, {
374 c = this.methods().length; 364 c = this.methods().length;
375 for (i=0; i<c; i++) { 365 for (i=0; i<c; i++) {
376 var deferredResult; 366 var deferredResult;
377 varmethodCalls; 367 varmethodCalls;
378 var ii, cc; 368 var ii, cc;
379 369
380//console.log("TYPEOF", typeof(this.methods()[i])); 370//Clipperz.log("TYPEOF", typeof(this.methods()[i]));
381 if (typeof(this.methods()[i]) == 'function') { 371 if (typeof(this.methods()[i]) == 'function') {
382 methodCalls = [ this.methods()[i] ]; 372 methodCalls = [ this.methods()[i] ];
383 } else { 373 } else {
384 methodCalls = this.methods()[i]; 374 methodCalls = this.methods()[i];
385 } 375 }
386 376
@@ -634,13 +624,13 @@ MochiKit.Base.update(Clipperz.Async, {
634 624
635 deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredSort", {trace:false}); 625 deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredSort", {trace:false});
636 c = someObjects.length; 626 c = someObjects.length;
637 for (i=0; i<c; i++) { 627 for (i=0; i<c; i++) {
638 deferredResult.addCallback(Clipperz.Async.insertIntoSortedArray, someObjects[i], aDeferredComparator); 628 deferredResult.addCallback(Clipperz.Async.insertIntoSortedArray, someObjects[i], aDeferredComparator);
639 if ((i % 50) == 0) { 629 if ((i % 50) == 0) {
640 //console.log("######### sort wait ##########"); 630 //Clipperz.log("######### sort wait ##########");
641 deferredResult.addCallback(MochiKit.Async.wait, 0.5); 631 deferredResult.addCallback(MochiKit.Async.wait, 0.5);
642 } 632 }
643 } 633 }
644 deferredResult.callback([]); 634 deferredResult.callback([]);
645 635
646 return deferredResult; 636 return deferredResult;
@@ -685,13 +675,13 @@ MochiKit.Base.update(Clipperz.Async, {
685 //========================================================================= 675 //=========================================================================
686 676
687 'or': function (someValues) { 677 'or': function (someValues) {
688 return Clipperz.Async.callbacks("Clipperz.Async.or", [ 678 return Clipperz.Async.callbacks("Clipperz.Async.or", [
689 MochiKit.Base.values, 679 MochiKit.Base.values,
690 MochiKit.Base.flattenArguments, 680 MochiKit.Base.flattenArguments,
691//function (aValue) { console.log("Record.hasAnyCleanTextData - flatten", aValue); return aValue; }, 681//function (aValue) { Clipperz.log("Record.hasAnyCleanTextData - flatten", aValue); return aValue; },
692 function(someInnerValues) { 682 function(someInnerValues) {
693 return MochiKit.Iter.some(someInnerValues, MochiKit.Base.operator.identity); 683 return MochiKit.Iter.some(someInnerValues, MochiKit.Base.operator.identity);
694 } 684 }
695 ], {trace:false}, someValues); 685 ], {trace:false}, someValues);
696 }, 686 },
697 687