Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Toll.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Toll.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Toll.js b/frontend/beta/js/Clipperz/PM/Toll.js index 6d412c1..3a9b48f 100644 --- a/frontend/beta/js/Clipperz/PM/Toll.js +++ b/frontend/beta/js/Clipperz/PM/Toll.js | |||
@@ -1,120 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
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 | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | 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 |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * 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 |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
31 | 28 | ||
32 | //============================================================================= | 29 | //============================================================================= |
33 | 30 | ||
34 | Clipperz.PM.Toll = function(args) { | 31 | Clipperz.PM.Toll = function(args) { |
35 | this._requestType = args.requestType; | 32 | this._requestType = args.requestType; |
36 | this._targetValue = args.targetValue; | 33 | this._targetValue = args.targetValue; |
37 | this._cost = args.cost; | 34 | this._cost = args.cost; |
38 | this._toll = null; | 35 | this._toll = null; |
39 | 36 | ||
40 | return this; | 37 | return this; |
41 | } | 38 | } |
42 | 39 | ||
43 | Clipperz.PM.Toll.prototype = MochiKit.Base.update(null, { | 40 | Clipperz.PM.Toll.prototype = MochiKit.Base.update(null, { |
44 | 41 | ||
45 | 'toString': function() { | 42 | 'toString': function() { |
46 | return "Clipperz.PM.Toll (" + this.requestType() + ": " + this.cost() + " - " + ((this.toll() == null)? 'UNPAID' : 'PAID') + ")"; | 43 | return "Clipperz.PM.Toll (" + this.requestType() + ": " + this.cost() + " - " + ((this.toll() == null)? 'UNPAID' : 'PAID') + ")"; |
47 | }, | 44 | }, |
48 | 45 | ||
49 | //------------------------------------------------------------------------- | 46 | //------------------------------------------------------------------------- |
50 | 47 | ||
51 | 'requestType': function() { | 48 | 'requestType': function() { |
52 | return this._requestType; | 49 | return this._requestType; |
53 | }, | 50 | }, |
54 | 51 | ||
55 | //------------------------------------------------------------------------- | 52 | //------------------------------------------------------------------------- |
56 | 53 | ||
57 | 'targetValue': function() { | 54 | 'targetValue': function() { |
58 | return this._targetValue; | 55 | return this._targetValue; |
59 | }, | 56 | }, |
60 | 57 | ||
61 | //------------------------------------------------------------------------- | 58 | //------------------------------------------------------------------------- |
62 | 59 | ||
63 | 'cost': function() { | 60 | 'cost': function() { |
64 | return this._cost; | 61 | return this._cost; |
65 | }, | 62 | }, |
66 | 63 | ||
67 | //------------------------------------------------------------------------- | 64 | //------------------------------------------------------------------------- |
68 | 65 | ||
69 | 'toll': function() { | 66 | 'toll': function() { |
70 | return this._toll; | 67 | return this._toll; |
71 | }, | 68 | }, |
72 | 69 | ||
73 | //========================================================================= | 70 | //========================================================================= |
74 | 71 | ||
75 | 'prefixMatchingBits': function(aValue1, aValue2) { | 72 | 'prefixMatchingBits': function(aValue1, aValue2) { |
76 | varresult; | 73 | varresult; |
77 | var i,c; | 74 | var i,c; |
78 | 75 | ||
79 | result = 0; | 76 | result = 0; |
80 | 77 | ||
81 | c = Math.min(aValue1.length(), aValue2.length()); | 78 | c = Math.min(aValue1.length(), aValue2.length()); |
82 | i = 0; | 79 | i = 0; |
83 | while (i<c && (aValue1.byteAtIndex(i) == aValue2.byteAtIndex(i))) { | 80 | while (i<c && (aValue1.byteAtIndex(i) == aValue2.byteAtIndex(i))) { |
84 | result += 8; | 81 | result += 8; |
85 | i++; | 82 | i++; |
86 | } | 83 | } |
87 | 84 | ||
88 | if (i<c) { | 85 | if (i<c) { |
89 | varxorValue; | 86 | varxorValue; |
90 | 87 | ||
91 | xorValue = (aValue1.byteAtIndex(i) ^ aValue2.byteAtIndex(i)); | 88 | xorValue = (aValue1.byteAtIndex(i) ^ aValue2.byteAtIndex(i)); |
92 | 89 | ||
93 | if (xorValue >= 128) { | 90 | if (xorValue >= 128) { |
94 | result += 0; | 91 | result += 0; |
95 | } else if (xorValue >= 64) { | 92 | } else if (xorValue >= 64) { |
96 | result += 1; | 93 | result += 1; |
97 | } else if (xorValue >= 32) { | 94 | } else if (xorValue >= 32) { |
98 | result += 2; | 95 | result += 2; |
99 | } else if (xorValue >= 16) { | 96 | } else if (xorValue >= 16) { |
100 | result += 3; | 97 | result += 3; |
101 | } else if (xorValue >= 8) { | 98 | } else if (xorValue >= 8) { |
102 | result += 4; | 99 | result += 4; |
103 | } else if (xorValue >= 4) { | 100 | } else if (xorValue >= 4) { |
104 | result += 5; | 101 | result += 5; |
105 | } else if (xorValue >= 2) { | 102 | } else if (xorValue >= 2) { |
106 | result += 6; | 103 | result += 6; |
107 | } else if (xorValue >= 1) { | 104 | } else if (xorValue >= 1) { |
108 | result += 7; | 105 | result += 7; |
109 | } | 106 | } |
110 | } | 107 | } |
111 | 108 | ||
112 | return result; | 109 | return result; |
113 | }, | 110 | }, |
114 | 111 | ||
115 | //========================================================================= | 112 | //========================================================================= |
116 | 113 | ||
117 | 'pay': function() { | 114 | 'pay': function() { |
118 | varresult; | 115 | varresult; |
119 | vartargetData; | 116 | vartargetData; |
120 | vartargetMatchSize; | 117 | vartargetMatchSize; |