Diffstat (limited to 'frontend/gamma/js/Clipperz/Base.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/Base.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/Base.js b/frontend/gamma/js/Clipperz/Base.js index 76b2c3f..9d399d9 100644 --- a/frontend/gamma/js/Clipperz/Base.js +++ b/frontend/gamma/js/Clipperz/Base.js | |||
@@ -32,96 +32,101 @@ Clipperz.Base.NAME = "Clipperz.Base"; | |||
32 | MochiKit.Base.update(Clipperz.Base, { | 32 | MochiKit.Base.update(Clipperz.Base, { |
33 | 33 | ||
34 | //------------------------------------------------------------------------- | 34 | //------------------------------------------------------------------------- |
35 | 35 | ||
36 | '__repr__': function () { | 36 | '__repr__': function () { |
37 | return "[" + this.NAME + " " + this.VERSION + "]"; | 37 | return "[" + this.NAME + " " + this.VERSION + "]"; |
38 | }, | 38 | }, |
39 | 39 | ||
40 | //------------------------------------------------------------------------- | 40 | //------------------------------------------------------------------------- |
41 | 41 | ||
42 | 'toString': function () { | 42 | 'toString': function () { |
43 | return this.__repr__(); | 43 | return this.__repr__(); |
44 | }, | 44 | }, |
45 | 45 | ||
46 | //------------------------------------------------------------------------- | 46 | //------------------------------------------------------------------------- |
47 | 47 | ||
48 | 'itemgetter': function (aKeyPath) { | 48 | 'itemgetter': function (aKeyPath) { |
49 | // return MochiKit.Base.compose.apply(null, [MochiKit.Base.itemgetter('key3')]); | 49 | // return MochiKit.Base.compose.apply(null, [MochiKit.Base.itemgetter('key3')]); |
50 | return MochiKit.Base.compose.apply(null, | 50 | return MochiKit.Base.compose.apply(null, |
51 | MochiKit.Base.map( | 51 | MochiKit.Base.map( |
52 | MochiKit.Base.itemgetter, | 52 | MochiKit.Base.itemgetter, |
53 | MochiKit.Iter.reversed( | 53 | MochiKit.Iter.reversed( |
54 | aKeyPath.split('.') | 54 | aKeyPath.split('.') |
55 | ) | 55 | ) |
56 | ) | 56 | ) |
57 | ); | 57 | ); |
58 | }, | 58 | }, |
59 | 59 | ||
60 | //------------------------------------------------------------------------- | 60 | //------------------------------------------------------------------------- |
61 | 61 | ||
62 | 'isUrl': function (aValue) { | 62 | 'isUrl': function (aValue) { |
63 | return (MochiKit.Base.urlRegExp.test(aValue)); | 63 | return (MochiKit.Base.urlRegExp.test(aValue)); |
64 | }, | 64 | }, |
65 | 65 | ||
66 | 'isEmail': function (aValue) { | 66 | 'isEmail': function (aValue) { |
67 | return (MochiKit.Base.emailRegExp.test(aValue)); | 67 | return (MochiKit.Base.emailRegExp.test(aValue)); |
68 | }, | 68 | }, |
69 | 69 | ||
70 | //------------------------------------------------------------------------- | 70 | //------------------------------------------------------------------------- |
71 | 71 | ||
72 | 'caseInsensitiveCompare': function (a, b) { | 72 | 'caseInsensitiveCompare': function (a, b) { |
73 | return MochiKit.Base.compare(a.toLowerCase(), b.toLowerCase()); | 73 | return MochiKit.Base.compare(a.toLowerCase(), b.toLowerCase()); |
74 | }, | 74 | }, |
75 | 75 | ||
76 | 'reverseComparator': function (aComparator) { | 76 | 'reverseComparator': function (aComparator) { |
77 | return MochiKit.Base.compose(function(aResult) { return -aResult; }, aComparator); | 77 | return MochiKit.Base.compose(function(aResult) { return -aResult; }, aComparator); |
78 | }, | 78 | }, |
79 | 79 | ||
80 | 'caseInsensitiveKeyComparator': function (aKey) { | ||
81 | return function (a, b) { | ||
82 | return MochiKit.Base.compare(a[aKey].toLowerCase(), b[aKey].toLowerCase()); | ||
83 | } | ||
84 | }, | ||
80 | //------------------------------------------------------------------------- | 85 | //------------------------------------------------------------------------- |
81 | /* | 86 | /* |
82 | 'dependsOn': function(module, deps) { | 87 | 'dependsOn': function(module, deps) { |
83 | if (!(module in Clipperz)) { | 88 | if (!(module in Clipperz)) { |
84 | MochiKit[module] = {}; | 89 | MochiKit[module] = {}; |
85 | } | 90 | } |
86 | 91 | ||
87 | if (typeof(dojo) != 'undefined') { | 92 | if (typeof(dojo) != 'undefined') { |
88 | dojo.provide('Clipperz.' + module); | 93 | dojo.provide('Clipperz.' + module); |
89 | } | 94 | } |
90 | for (var i = 0; i < deps.length; i++) { | 95 | for (var i = 0; i < deps.length; i++) { |
91 | if (typeof(dojo) != 'undefined') { | 96 | if (typeof(dojo) != 'undefined') { |
92 | dojo.require('Clipperz.' + deps[i]); | 97 | dojo.require('Clipperz.' + deps[i]); |
93 | } | 98 | } |
94 | if (typeof(JSAN) != 'undefined') { | 99 | if (typeof(JSAN) != 'undefined') { |
95 | JSAN.use('Clipperz.' + deps[i], []); | 100 | JSAN.use('Clipperz.' + deps[i], []); |
96 | } | 101 | } |
97 | if (!(deps[i] in Clipperz)) { | 102 | if (!(deps[i] in Clipperz)) { |
98 | throw 'Clipperz.' + module + ' depends on Clipperz.' + deps[i] + '!' | 103 | throw 'Clipperz.' + module + ' depends on Clipperz.' + deps[i] + '!' |
99 | } | 104 | } |
100 | } | 105 | } |
101 | }, | 106 | }, |
102 | */ | 107 | */ |
103 | //------------------------------------------------------------------------- | 108 | //------------------------------------------------------------------------- |
104 | 109 | ||
105 | 'trim': function (aValue) { | 110 | 'trim': function (aValue) { |
106 | return aValue.replace(/^\s+|\s+$/g, ""); | 111 | return aValue.replace(/^\s+|\s+$/g, ""); |
107 | }, | 112 | }, |
108 | 113 | ||
109 | //------------------------------------------------------------------------- | 114 | //------------------------------------------------------------------------- |
110 | 115 | ||
111 | 'stringToByteArray': function (aValue) { | 116 | 'stringToByteArray': function (aValue) { |
112 | varresult; | 117 | varresult; |
113 | var i, c; | 118 | var i, c; |
114 | 119 | ||
115 | result = []; | 120 | result = []; |
116 | 121 | ||
117 | c = aValue.length; | 122 | c = aValue.length; |
118 | for (i=0; i<c; i++) { | 123 | for (i=0; i<c; i++) { |
119 | result[i] = aValue.charCodeAt(i); | 124 | result[i] = aValue.charCodeAt(i); |
120 | } | 125 | } |
121 | 126 | ||
122 | return result; | 127 | return result; |
123 | }, | 128 | }, |
124 | 129 | ||
125 | //......................................................................... | 130 | //......................................................................... |
126 | 131 | ||
127 | 'byteArrayToString': function (anArrayOfBytes) { | 132 | 'byteArrayToString': function (anArrayOfBytes) { |