| 1 | | /*** |
|---|
| 2 | | |
|---|
| 3 | | MochiKit.MochiKit 1.3 : PACKED VERSION |
|---|
| 4 | | |
|---|
| 5 | | THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please |
|---|
| 6 | | diff against the source tree, not this file. |
|---|
| 7 | | |
|---|
| 8 | | See <http://mochikit.com/> for documentation, downloads, license, etc. |
|---|
| 9 | | |
|---|
| 10 | | (c) 2005 Bob Ippolito. All rights Reserved. |
|---|
| 11 | | |
|---|
| 12 | | ***/ |
|---|
| 13 | | |
|---|
| 14 | | if(typeof (dojo)!="undefined"){ |
|---|
| 15 | | dojo.provide("MochiKit.Base"); |
|---|
| 16 | | } |
|---|
| 17 | | if(typeof (MochiKit)=="undefined"){ |
|---|
| 18 | | MochiKit={}; |
|---|
| 19 | | } |
|---|
| 20 | | if(typeof (MochiKit.Base)=="undefined"){ |
|---|
| 21 | | MochiKit.Base={}; |
|---|
| 22 | | } |
|---|
| 23 | | MochiKit.Base.VERSION="1.3"; |
|---|
| 24 | | MochiKit.Base.NAME="MochiKit.Base"; |
|---|
| 25 | | MochiKit.Base.update=function(_1,_2){ |
|---|
| 26 | | if(_1==null){ |
|---|
| 27 | | _1={}; |
|---|
| 28 | | } |
|---|
| 29 | | for(var i=1;i<arguments.length;i++){ |
|---|
| 30 | | var o=arguments[i]; |
|---|
| 31 | | if(typeof (o)!="undefined"&&o!=null){ |
|---|
| 32 | | for(var k in o){ |
|---|
| 33 | | _1[k]=o[k]; |
|---|
| 34 | | } |
|---|
| 35 | | } |
|---|
| 36 | | } |
|---|
| 37 | | return _1; |
|---|
| 38 | | }; |
|---|
| 39 | | MochiKit.Base.update(MochiKit.Base,{__repr__:function(){ |
|---|
| 40 | | return "["+this.NAME+" "+this.VERSION+"]"; |
|---|
| 41 | | },toString:function(){ |
|---|
| 42 | | return this.__repr__(); |
|---|
| 43 | | },counter:function(n){ |
|---|
| 44 | | if(arguments.length==0){ |
|---|
| 45 | | n=1; |
|---|
| 46 | | } |
|---|
| 47 | | return function(){ |
|---|
| 48 | | return n++; |
|---|
| 49 | | }; |
|---|
| 50 | | },clone:function(_7){ |
|---|
| 51 | | var me=arguments.callee; |
|---|
| 52 | | if(arguments.length==1){ |
|---|
| 53 | | me.prototype=_7; |
|---|
| 54 | | return new me(); |
|---|
| 55 | | } |
|---|
| 56 | | },flattenArguments:function(_9){ |
|---|
| 57 | | var res=[]; |
|---|
| 58 | | var m=MochiKit.Base; |
|---|
| 59 | | var _12=m.extend(null,arguments); |
|---|
| 60 | | while(_12.length){ |
|---|
| 61 | | var o=_12.shift(); |
|---|
| 62 | | if(o&&typeof (o)=="object"&&typeof (o.length)=="number"){ |
|---|
| 63 | | for(var i=o.length-1;i>=0;i--){ |
|---|
| 64 | | _12.unshift(o[i]); |
|---|
| 65 | | } |
|---|
| 66 | | }else{ |
|---|
| 67 | | res.push(o); |
|---|
| 68 | | } |
|---|
| 69 | | } |
|---|
| 70 | | return res; |
|---|
| 71 | | },extend:function(_13,obj,_15){ |
|---|
| 72 | | if(!_15){ |
|---|
| 73 | | _15=0; |
|---|
| 74 | | } |
|---|
| 75 | | if(obj){ |
|---|
| 76 | | var l=obj.length; |
|---|
| 77 | | if(typeof (l)!="number"){ |
|---|
| 78 | | if(typeof (MochiKit.Iter)!="undefined"){ |
|---|
| 79 | | obj=MochiKit.Iter.list(obj); |
|---|
| 80 | | l=obj.length; |
|---|
| 81 | | }else{ |
|---|
| 82 | | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
|---|
| 83 | | } |
|---|
| 84 | | } |
|---|
| 85 | | if(!_13){ |
|---|
| 86 | | _13=[]; |
|---|
| 87 | | } |
|---|
| 88 | | for(var i=_15;i<l;i++){ |
|---|
| 89 | | _13.push(obj[i]); |
|---|
| 90 | | } |
|---|
| 91 | | } |
|---|
| 92 | | return _13; |
|---|
| 93 | | },updatetree:function(_17,obj){ |
|---|
| 94 | | if(_17==null){ |
|---|
| 95 | | _17={}; |
|---|
| 96 | | } |
|---|
| 97 | | for(var i=1;i<arguments.length;i++){ |
|---|
| 98 | | var o=arguments[i]; |
|---|
| 99 | | if(typeof (o)!="undefined"&&o!=null){ |
|---|
| 100 | | for(var k in o){ |
|---|
| 101 | | var v=o[k]; |
|---|
| 102 | | if(typeof (_17[k])=="object"&&typeof (v)=="object"){ |
|---|
| 103 | | arguments.callee(_17[k],v); |
|---|
| 104 | | }else{ |
|---|
| 105 | | _17[k]=v; |
|---|
| 106 | | } |
|---|
| 107 | | } |
|---|
| 108 | | } |
|---|
| 109 | | } |
|---|
| 110 | | return _17; |
|---|
| 111 | | },setdefault:function(_19,obj){ |
|---|
| 112 | | if(_19==null){ |
|---|
| 113 | | _19={}; |
|---|
| 114 | | } |
|---|
| 115 | | for(var i=1;i<arguments.length;i++){ |
|---|
| 116 | | var o=arguments[i]; |
|---|
| 117 | | for(var k in o){ |
|---|
| 118 | | if(!(k in _19)){ |
|---|
| 119 | | _19[k]=o[k]; |
|---|
| 120 | | } |
|---|
| 121 | | } |
|---|
| 122 | | } |
|---|
| 123 | | return _19; |
|---|
| 124 | | },keys:function(obj){ |
|---|
| 125 | | var _20=[]; |
|---|
| 126 | | for(var _21 in obj){ |
|---|
| 127 | | _20.push(_21); |
|---|
| 128 | | } |
|---|
| 129 | | return _20; |
|---|
| 130 | | },items:function(obj){ |
|---|
| 131 | | var _22=[]; |
|---|
| 132 | | var e; |
|---|
| 133 | | for(var _24 in obj){ |
|---|
| 134 | | var v; |
|---|
| 135 | | try{ |
|---|
| 136 | | v=obj[_24]; |
|---|
| 137 | | } |
|---|
| 138 | | catch(e){ |
|---|
| 139 | | continue; |
|---|
| 140 | | } |
|---|
| 141 | | _22.push([_24,v]); |
|---|
| 142 | | } |
|---|
| 143 | | return _22; |
|---|
| 144 | | },_newNamedError:function(_25,_26,_27){ |
|---|
| 145 | | _27.prototype=new MochiKit.Base.NamedError(_25.NAME+"."+_26); |
|---|
| 146 | | _25[_26]=_27; |
|---|
| 147 | | },operator:{truth:function(a){ |
|---|
| 148 | | return !!a; |
|---|
| 149 | | },lognot:function(a){ |
|---|
| 150 | | return !a; |
|---|
| 151 | | },identity:function(a){ |
|---|
| 152 | | return a; |
|---|
| 153 | | },not:function(a){ |
|---|
| 154 | | return ~a; |
|---|
| 155 | | },neg:function(a){ |
|---|
| 156 | | return -a; |
|---|
| 157 | | },add:function(a,b){ |
|---|
| 158 | | return a+b; |
|---|
| 159 | | },sub:function(a,b){ |
|---|
| 160 | | return a-b; |
|---|
| 161 | | },div:function(a,b){ |
|---|
| 162 | | return a/b; |
|---|
| 163 | | },mod:function(a,b){ |
|---|
| 164 | | return a%b; |
|---|
| 165 | | },mul:function(a,b){ |
|---|
| 166 | | return a*b; |
|---|
| 167 | | },and:function(a,b){ |
|---|
| 168 | | return a&b; |
|---|
| 169 | | },or:function(a,b){ |
|---|
| 170 | | return a|b; |
|---|
| 171 | | },xor:function(a,b){ |
|---|
| 172 | | return a^b; |
|---|
| 173 | | },lshift:function(a,b){ |
|---|
| 174 | | return a<<b; |
|---|
| 175 | | },rshift:function(a,b){ |
|---|
| 176 | | return a>>b; |
|---|
| 177 | | },zrshift:function(a,b){ |
|---|
| 178 | | return a>>>b; |
|---|
| 179 | | },eq:function(a,b){ |
|---|
| 180 | | return a==b; |
|---|
| 181 | | },ne:function(a,b){ |
|---|
| 182 | | return a!=b; |
|---|
| 183 | | },gt:function(a,b){ |
|---|
| 184 | | return a>b; |
|---|
| 185 | | },ge:function(a,b){ |
|---|
| 186 | | return a>=b; |
|---|
| 187 | | },lt:function(a,b){ |
|---|
| 188 | | return a<b; |
|---|
| 189 | | },le:function(a,b){ |
|---|
| 190 | | return a<=b; |
|---|
| 191 | | },ceq:function(a,b){ |
|---|
| 192 | | return MochiKit.Base.compare(a,b)==0; |
|---|
| 193 | | },cne:function(a,b){ |
|---|
| 194 | | return MochiKit.Base.compare(a,b)!=0; |
|---|
| 195 | | },cgt:function(a,b){ |
|---|
| 196 | | return MochiKit.Base.compare(a,b)==1; |
|---|
| 197 | | },cge:function(a,b){ |
|---|
| 198 | | return MochiKit.Base.compare(a,b)!=-1; |
|---|
| 199 | | },clt:function(a,b){ |
|---|
| 200 | | return MochiKit.Base.compare(a,b)==-1; |
|---|
| 201 | | },cle:function(a,b){ |
|---|
| 202 | | return MochiKit.Base.compare(a,b)!=1; |
|---|
| 203 | | },logand:function(a,b){ |
|---|
| 204 | | return a&&b; |
|---|
| 205 | | },logor:function(a,b){ |
|---|
| 206 | | return a||b; |
|---|
| 207 | | },contains:function(a,b){ |
|---|
| 208 | | return b in a; |
|---|
| 209 | | }},forwardCall:function(_30){ |
|---|
| 210 | | return function(){ |
|---|
| 211 | | return this[_30].apply(this,arguments); |
|---|
| 212 | | }; |
|---|
| 213 | | },itemgetter:function(_31){ |
|---|
| 214 | | return function(arg){ |
|---|
| 215 | | return arg[_31]; |
|---|
| 216 | | }; |
|---|
| 217 | | },typeMatcher:function(){ |
|---|
| 218 | | var _33={}; |
|---|
| 219 | | for(var i=0;i<arguments.length;i++){ |
|---|
| 220 | | var typ=arguments[i]; |
|---|
| 221 | | _33[typ]=typ; |
|---|
| 222 | | } |
|---|
| 223 | | return function(){ |
|---|
| 224 | | for(var i=0;i<arguments.length;i++){ |
|---|
| 225 | | if(!(typeof (arguments[i]) in _33)){ |
|---|
| 226 | | return false; |
|---|
| 227 | | } |
|---|
| 228 | | } |
|---|
| 229 | | return true; |
|---|
| 230 | | }; |
|---|
| 231 | | },isNull:function(){ |
|---|
| 232 | | for(var i=0;i<arguments.length;i++){ |
|---|
| 233 | | if(arguments[i]!==null){ |
|---|
| 234 | | return false; |
|---|
| 235 | | } |
|---|
| 236 | | } |
|---|
| 237 | | return true; |
|---|
| 238 | | },isUndefinedOrNull:function(){ |
|---|
| 239 | | for(var i=0;i<arguments.length;i++){ |
|---|
| 240 | | var o=arguments[i]; |
|---|
| 241 | | if(!(typeof (o)=="undefined"||o==null)){ |
|---|
| 242 | | return false; |
|---|
| 243 | | } |
|---|
| 244 | | } |
|---|
| 245 | | return true; |
|---|
| 246 | | },isNotEmpty:function(obj){ |
|---|
| 247 | | for(var i=0;i<arguments.length;i++){ |
|---|
| 248 | | var o=arguments[i]; |
|---|
| 249 | | if(!(o&&o.length)){ |
|---|
| 250 | | return false; |
|---|
| 251 | | } |
|---|
| 252 | | } |
|---|
| 253 | | return true; |
|---|
| 254 | | },isArrayLike:function(){ |
|---|
| 255 | | for(var i=0;i<arguments.length;i++){ |
|---|
| 256 | | var o=arguments[i]; |
|---|
| 257 | | var typ=typeof (o); |
|---|
| 258 | | if((typ!="object"&&!(typ=="function"&&typeof (o.item)=="function"))||o==null||typeof (o.length)!="number"){ |
|---|
| 259 | | return false; |
|---|
| 260 | | } |
|---|
| 261 | | } |
|---|
| 262 | | return true; |
|---|
| 263 | | },isDateLike:function(){ |
|---|
| 264 | | for(var i=0;i<arguments.length;i++){ |
|---|
| 265 | | var o=arguments[i]; |
|---|
| 266 | | if(typeof (o)!="object"||o==null||typeof (o.getTime)!="function"){ |
|---|
| 267 | | return false; |
|---|
| 268 | | } |
|---|
| 269 | | } |
|---|
| 270 | | return true; |
|---|
| 271 | | },xmap:function(fn){ |
|---|
| 272 | | if(fn==null){ |
|---|
| 273 | | return MochiKit.Base.extend(null,arguments,1); |
|---|
| 274 | | } |
|---|
| 275 | | var _36=[]; |
|---|
| 276 | | for(var i=1;i<arguments.length;i++){ |
|---|
| 277 | | _36.push(fn(arguments[i])); |
|---|
| 278 | | } |
|---|
| 279 | | return _36; |
|---|
| 280 | | },map:function(fn,lst){ |
|---|
| 281 | | var m=MochiKit.Base; |
|---|
| 282 | | var _38=m.isArrayLike; |
|---|
| 283 | | if(arguments.length<=2){ |
|---|
| 284 | | if(!_38(lst)){ |
|---|
| 285 | | if(MochiKit.Iter){ |
|---|
| 286 | | lst=MochiKit.Iter.list(lst); |
|---|
| 287 | | if(fn==null){ |
|---|
| 288 | | return lst; |
|---|
| 289 | | } |
|---|
| 290 | | }else{ |
|---|
| 291 | | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
|---|
| 292 | | } |
|---|
| 293 | | } |
|---|
| 294 | | if(fn==null){ |
|---|
| 295 | | return m.extend(null,lst); |
|---|
| 296 | | } |
|---|
| 297 | | var _39=[]; |
|---|
| 298 | | for(var i=0;i<lst.length;i++){ |
|---|
| 299 | | _39.push(fn(lst[i])); |
|---|
| 300 | | } |
|---|
| 301 | | return _39; |
|---|
| 302 | | }else{ |
|---|
| 303 | | if(fn==null){ |
|---|
| 304 | | fn=Array; |
|---|
| 305 | | } |
|---|
| 306 | | var _40=null; |
|---|
| 307 | | for(i=1;i<arguments.length;i++){ |
|---|
| 308 | | if(!_38(arguments[i])){ |
|---|
| 309 | | if(MochiKit.Iter){ |
|---|
| 310 | | arguments[i]=MochiKit.Iter.list(arguments[i]); |
|---|
| 311 | | }else{ |
|---|
| 312 | | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
|---|
| 313 | | } |
|---|
| 314 | | } |
|---|
| 315 | | var l=arguments[i].length; |
|---|
| 316 | | if(_40==null||_40>l){ |
|---|
| 317 | | _40=l; |
|---|
| 318 | | } |
|---|
| 319 | | } |
|---|
| 320 | | _39=[]; |
|---|
| 321 | | for(i=0;i<_40;i++){ |
|---|
| 322 | | var _41=[]; |
|---|
| 323 | | for(var j=1;j<arguments.length;j++){ |
|---|
| 324 | | _41.push(arguments[j][i]); |
|---|
| 325 | | } |
|---|
| 326 | | _39.push(fn.apply(this,_41)); |
|---|
| 327 | | } |
|---|
| 328 | | return _39; |
|---|
| 329 | | } |
|---|
| 330 | | },xfilter:function(fn){ |
|---|
| 331 | | var _43=[]; |
|---|
| 332 | | if(fn==null){ |
|---|
| 333 | | fn=MochiKit.Base.operator.truth; |
|---|
| 334 | | } |
|---|
| 335 | | for(var i=1;i<arguments.length;i++){ |
|---|
| 336 | | var o=arguments[i]; |
|---|
| 337 | | if(fn(o)){ |
|---|
| 338 | | _43.push(o); |
|---|
| 339 | | } |
|---|
| 340 | | } |
|---|
| 341 | | return _43; |
|---|
| 342 | | },filter:function(fn,lst,_44){ |
|---|
| 343 | | var _45=[]; |
|---|
| 344 | | var m=MochiKit.Base; |
|---|
| 345 | | if(!m.isArrayLike(lst)){ |
|---|
| 346 | | if(MochiKit.Iter){ |
|---|
| 347 | | lst=MochiKit.Iter.list(lst); |
|---|
| 348 | | }else{ |
|---|
| 349 | | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
|---|
| 350 | | } |
|---|
| 351 | | } |
|---|
| 352 | | if(fn==null){ |
|---|
| 353 | | fn=m.operator.truth; |
|---|
| 354 | | } |
|---|
| 355 | | if(typeof (Array.prototype.filter)=="function"){ |
|---|
| 356 | | return Array.prototype.filter.call(lst,fn,_44); |
|---|
| 357 | | }else{ |
|---|
| 358 | | if(typeof (_44)=="undefined"||_44==null){ |
|---|
| 359 | | for(var i=0;i<lst.length;i++){ |
|---|
| 360 | | var o=lst[i]; |
|---|
| 361 | | if(fn(o)){ |
|---|
| 362 | | _45.push(o); |
|---|
| 363 | | } |
|---|
| 364 | | } |
|---|
| 365 | | }else{ |
|---|
| 366 | | for(i=0;i<lst.length;i++){ |
|---|
| 367 | | o=lst[i]; |
|---|
| 368 | | if(fn.call(_44,o)){ |
|---|
| 369 | | _45.push(o); |
|---|
| 370 | | } |
|---|
| 371 | | } |
|---|
| 372 | | } |
|---|
| 373 | | } |
|---|
| 374 | | return _45; |
|---|
| 375 | | },_wrapDumbFunction:function(_46){ |
|---|
| 376 | | return function(){ |
|---|
| 377 | | switch(arguments.length){ |
|---|
| 378 | | case 0: |
|---|
| 379 | | return _46(); |
|---|
| 380 | | case 1: |
|---|
| 381 | | return _46(arguments[0]); |
|---|
| 382 | | case 2: |
|---|
| 383 | | return _46(arguments[0],arguments[1]); |
|---|
| 384 | | case 3: |
|---|
| 385 | | return _46(arguments[0],arguments[1],arguments[2]); |
|---|
| 386 | | } |
|---|
| 387 | | var _47=[]; |
|---|
| 388 | | for(var i=0;i<arguments.length;i++){ |
|---|
| 389 | | _47.push("arguments["+i+"]"); |
|---|
| 390 | | } |
|---|
| 391 | | return eval("(func("+_47.join(",")+"))"); |
|---|
| 392 | | }; |
|---|
| 393 | | },bind:function(_48,_49){ |
|---|
| 394 | | if(typeof (_48)=="string"){ |
|---|
| 395 | | _48=_49[_48]; |
|---|
| 396 | | } |
|---|
| 397 | | var _50=_48.im_func; |
|---|
| 398 | | var _51=_48.im_preargs; |
|---|
| 399 | | var _52=_48.im_self; |
|---|
| 400 | | var m=MochiKit.Base; |
|---|
| 401 | | if(typeof (_48)=="function"&&typeof (_48.apply)=="undefined"){ |
|---|
| 402 | | _48=m._wrapDumbFunction(_48); |
|---|
| 403 | | } |
|---|
| 404 | | if(typeof (_50)!="function"){ |
|---|
| 405 | | _50=_48; |
|---|
| 406 | | } |
|---|
| 407 | | if(typeof (_49)!="undefined"){ |
|---|
| 408 | | _52=_49; |
|---|
| 409 | | } |
|---|
| 410 | | if(typeof (_51)=="undefined"){ |
|---|
| 411 | | _51=[]; |
|---|
| 412 | | }else{ |
|---|
| 413 | | _51=_51.slice(); |
|---|
| 414 | | } |
|---|
| 415 | | m.extend(_51,arguments,2); |
|---|
| 416 | | var _53=function(){ |
|---|
| 417 | | var _54=arguments; |
|---|
| 418 | | var me=arguments.callee; |
|---|
| 419 | | if(me.im_preargs.length>0){ |
|---|
| 420 | | _54=m.concat(me.im_preargs,_54); |
|---|
| 421 | | } |
|---|
| 422 | | var _49=me.im_self; |
|---|
| 423 | | if(!_49){ |
|---|
| 424 | | _49=this; |
|---|
| 425 | | } |
|---|
| 426 | | return me.im_func.apply(_49,_54); |
|---|
| 427 | | }; |
|---|
| 428 | | _53.im_self=_52; |
|---|
| 429 | | _53.im_func=_50; |
|---|
| 430 | | _53.im_preargs=_51; |
|---|
| 431 | | return _53; |
|---|
| 432 | | },bindMethods:function(_55){ |
|---|
| 433 | | var _56=MochiKit.Base.bind; |
|---|
| 434 | | for(var k in _55){ |
|---|
| 435 | | var _57=_55[k]; |
|---|
| 436 | | if(typeof (_57)=="function"){ |
|---|
| 437 | | _55[k]=_56(_57,_55); |
|---|
| 438 | | } |
|---|
| 439 | | } |
|---|
| 440 | | },registerComparator:function(_58,_59,_60,_61){ |
|---|
| 441 | | MochiKit.Base.comparatorRegistry.register(_58,_59,_60,_61); |
|---|
| 442 | | },_primitives:{"bool":true,"string":true,"number":true},compare:function(a,b){ |
|---|
| 443 | | if(a==b){ |
|---|
| 444 | | return 0; |
|---|
| 445 | | } |
|---|
| 446 | | var _62=(typeof (a)=="undefined"||a==null); |
|---|
| 447 | | var _63=(typeof (b)=="undefined"||b==null); |
|---|
| 448 | | if(_62&&_63){ |
|---|
| 449 | | return 0; |
|---|
| 450 | | }else{ |
|---|
| 451 | | if(_62){ |
|---|
| 452 | | return -1; |
|---|
| 453 | | }else{ |
|---|
| 454 | | if(_63){ |
|---|
| 455 | | return 1; |
|---|
| 456 | | } |
|---|
| 457 | | } |
|---|
| 458 | | } |
|---|
| 459 | | var m=MochiKit.Base; |
|---|
| 460 | | var _64=m._primitives; |
|---|
| 461 | | if(!(typeof (a) in _64&&typeof (b) in _64)){ |
|---|
| 462 | | try{ |
|---|
| 463 | | return m.comparatorRegistry.match(a,b); |
|---|
| 464 | | } |
|---|
| 465 | | catch(e){ |
|---|
| 466 | | if(e!=m.NotFound){ |
|---|
| 467 | | throw e; |
|---|
| 468 | | } |
|---|
| 469 | | } |
|---|
| 470 | | } |
|---|
| 471 | | if(a<b){ |
|---|
| 472 | | return -1; |
|---|
| 473 | | }else{ |
|---|
| 474 | | if(a>b){ |
|---|
| 475 | | return 1; |
|---|
| 476 | | } |
|---|
| 477 | | } |
|---|
| 478 | | var _65=m.repr; |
|---|
| 479 | | throw new TypeError(_65(a)+" and "+_65(b)+" can not be compared"); |
|---|
| 480 | | },compareDateLike:function(a,b){ |
|---|
| 481 | | return MochiKit.Base.compare(a.getTime(),b.getTime()); |
|---|
| 482 | | },compareArrayLike:function(a,b){ |
|---|
| 483 | | var _66=MochiKit.Base.compare; |
|---|
| 484 | | var _67=a.length; |
|---|
| 485 | | var _68=0; |
|---|
| 486 | | if(_67>b.length){ |
|---|
| 487 | | _68=1; |
|---|
| 488 | | _67=b.length; |
|---|
| 489 | | }else{ |
|---|
| 490 | | if(_67<b.length){ |
|---|
| 491 | | _68=-1; |
|---|
| 492 | | } |
|---|
| 493 | | } |
|---|
| 494 | | for(var i=0;i<_67;i++){ |
|---|
| 495 | | var cmp=_66(a[i],b[i]); |
|---|
| 496 | | if(cmp){ |
|---|
| 497 | | return cmp; |
|---|
| 498 | | } |
|---|
| 499 | | } |
|---|
| 500 | | return _68; |
|---|
| 501 | | },registerRepr:function(_70,_71,_72,_73){ |
|---|
| 502 | | MochiKit.Base.reprRegistry.register(_70,_71,_72,_73); |
|---|
| 503 | | },repr:function(o){ |
|---|
| 504 | | if(typeof (o)=="undefined"){ |
|---|
| 505 | | return "undefined"; |
|---|
| 506 | | }else{ |
|---|
| 507 | | if(o===null){ |
|---|
| 508 | | return "null"; |
|---|
| 509 | | } |
|---|
| 510 | | } |
|---|
| 511 | | try{ |
|---|
| 512 | | if(typeof (o.__repr__)=="function"){ |
|---|
| 513 | | return o.__repr__(); |
|---|
| 514 | | }else{ |
|---|
| 515 | | if(typeof (o.repr)=="function"&&o.repr!=arguments.callee){ |
|---|
| 516 | | return o.repr(); |
|---|
| 517 | | } |
|---|
| 518 | | } |
|---|
| 519 | | return MochiKit.Base.reprRegistry.match(o); |
|---|
| 520 | | } |
|---|
| 521 | | catch(e){ |
|---|
| 522 | | if(typeof (o.NAME)=="string"&&(o.toString==Function.prototype.toString||o.toString==Object.prototype.toString)){ |
|---|
| 523 | | return o.NAME; |
|---|
| 524 | | } |
|---|
| 525 | | } |
|---|
| 526 | | try{ |
|---|
| 527 | | var _74=(o+""); |
|---|
| 528 | | } |
|---|
| 529 | | catch(e){ |
|---|
| 530 | | return "["+typeof (o)+"]"; |
|---|
| 531 | | } |
|---|
| 532 | | if(typeof (o)=="function"){ |
|---|
| 533 | | o=_74.replace(/^\s+/,""); |
|---|
| 534 | | var idx=o.indexOf("{"); |
|---|
| 535 | | if(idx!=-1){ |
|---|
| 536 | | o=o.substr(0,idx)+"{...}"; |
|---|
| 537 | | } |
|---|
| 538 | | } |
|---|
| 539 | | return _74; |
|---|
| 540 | | },reprArrayLike:function(o){ |
|---|
| 541 | | var m=MochiKit.Base; |
|---|
| 542 | | return "["+m.map(m.repr,o).join(", ")+"]"; |
|---|
| 543 | | },reprString:function(o){ |
|---|
| 544 | | return ("\""+o.replace(/(["\\])/g,"\\$1")+"\"").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r"); |
|---|
| 545 | | },reprNumber:function(o){ |
|---|
| 546 | | return o+""; |
|---|
| 547 | | },registerJSON:function(_76,_77,_78,_79){ |
|---|
| 548 | | MochiKit.Base.jsonRegistry.register(_76,_77,_78,_79); |
|---|
| 549 | | },evalJSON:function(){ |
|---|
| 550 | | return eval("("+arguments[0]+")"); |
|---|
| 551 | | },serializeJSON:function(o){ |
|---|
| 552 | | var _80=typeof (o); |
|---|
| 553 | | if(_80=="undefined"){ |
|---|
| 554 | | return "undefined"; |
|---|
| 555 | | }else{ |
|---|
| 556 | | if(_80=="number"||_80=="boolean"){ |
|---|
| 557 | | return o+""; |
|---|
| 558 | | }else{ |
|---|
| 559 | | if(o===null){ |
|---|
| 560 | | return "null"; |
|---|
| 561 | | } |
|---|
| 562 | | } |
|---|
| 563 | | } |
|---|
| 564 | | var m=MochiKit.Base; |
|---|
| 565 | | var _81=m.reprString; |
|---|
| 566 | | if(_80=="string"){ |
|---|
| 567 | | return _81(o); |
|---|
| 568 | | } |
|---|
| 569 | | var me=arguments.callee; |
|---|
| 570 | | var _82; |
|---|
| 571 | | if(typeof (o.__json__)=="function"){ |
|---|
| 572 | | _82=o.__json__(); |
|---|
| 573 | | if(o!==_82){ |
|---|
| 574 | | return me(_82); |
|---|
| 575 | | } |
|---|
| 576 | | } |
|---|
| 577 | | if(typeof (o.json)=="function"){ |
|---|
| 578 | | _82=o.json(); |
|---|
| 579 | | if(o!==_82){ |
|---|
| 580 | | return me(_82); |
|---|
| 581 | | } |
|---|
| 582 | | } |
|---|
| 583 | | if(_80!="function"&&typeof (o.length)=="number"){ |
|---|
| 584 | | var res=[]; |
|---|
| 585 | | for(var i=0;i<o.length;i++){ |
|---|
| 586 | | var val=me(o[i]); |
|---|
| 587 | | if(typeof (val)!="string"){ |
|---|
| 588 | | val="undefined"; |
|---|
| 589 | | } |
|---|
| 590 | | res.push(val); |
|---|
| 591 | | } |
|---|
| 592 | | return "["+res.join(", ")+"]"; |
|---|
| 593 | | } |
|---|
| 594 | | try{ |
|---|
| 595 | | _82=m.jsonRegistry.match(o); |
|---|
| 596 | | return me(_82); |
|---|
| 597 | | } |
|---|
| 598 | | catch(e){ |
|---|
| 599 | | if(e!=m.NotFound){ |
|---|
| 600 | | throw e; |
|---|
| 601 | | } |
|---|
| 602 | | } |
|---|
| 603 | | if(_80=="function"){ |
|---|
| 604 | | return null; |
|---|
| 605 | | } |
|---|
| 606 | | res=[]; |
|---|
| 607 | | for(var k in o){ |
|---|
| 608 | | var _84; |
|---|
| 609 | | if(typeof (k)=="number"){ |
|---|
| 610 | | _84="\""+k+"\""; |
|---|
| 611 | | }else{ |
|---|
| 612 | | if(typeof (k)=="string"){ |
|---|
| 613 | | _84=_81(k); |
|---|
| 614 | | }else{ |
|---|
| 615 | | continue; |
|---|
| 616 | | } |
|---|
| 617 | | } |
|---|
| 618 | | val=me(o[k]); |
|---|
| 619 | | if(typeof (val)!="string"){ |
|---|
| 620 | | continue; |
|---|
| 621 | | } |
|---|
| 622 | | res.push(_84+":"+val); |
|---|
| 623 | | } |
|---|
| 624 | | return "{"+res.join(", ")+"}"; |
|---|
| 625 | | },objEqual:function(a,b){ |
|---|
| 626 | | return (MochiKit.Base.compare(a,b)==0); |
|---|
| 627 | | },arrayEqual:function(_85,arr){ |
|---|
| 628 | | if(_85.length!=arr.length){ |
|---|
| 629 | | return false; |
|---|
| 630 | | } |
|---|
| 631 | | return (MochiKit.Base.compare(_85,arr)==0); |
|---|
| 632 | | },concat:function(){ |
|---|
| 633 | | var _87=[]; |
|---|
| 634 | | var _88=MochiKit.Base.extend; |
|---|
| 635 | | for(var i=0;i<arguments.length;i++){ |
|---|
| 636 | | _88(_87,arguments[i]); |
|---|
| 637 | | } |
|---|
| 638 | | return _87; |
|---|
| 639 | | },keyComparator:function(key){ |
|---|
| 640 | | var m=MochiKit.Base; |
|---|
| 641 | | var _90=m.compare; |
|---|
| 642 | | if(arguments.length==1){ |
|---|
| 643 | | return function(a,b){ |
|---|
| 644 | | return _90(a[key],b[key]); |
|---|
| 645 | | }; |
|---|
| 646 | | } |
|---|
| 647 | | var _91=m.extend(null,arguments); |
|---|
| 648 | | return function(a,b){ |
|---|
| 649 | | var _92=0; |
|---|
| 650 | | for(var i=0;(_92==0)&&(i<_91.length);i++){ |
|---|
| 651 | | var key=_91[i]; |
|---|
| 652 | | _92=_90(a[key],b[key]); |
|---|
| 653 | | } |
|---|
| 654 | | return _92; |
|---|
| 655 | | }; |
|---|
| 656 | | },reverseKeyComparator:function(key){ |
|---|
| 657 | | var _93=MochiKit.Base.keyComparator.apply(this,arguments); |
|---|
| 658 | | return function(a,b){ |
|---|
| 659 | | return _93(b,a); |
|---|
| 660 | | }; |
|---|
| 661 | | },partial:function(_94){ |
|---|
| 662 | | var m=MochiKit.Base; |
|---|
| 663 | | return m.bind.apply(this,m.extend([_94,undefined],arguments,1)); |
|---|
| 664 | | },listMinMax:function(_95,lst){ |
|---|
| 665 | | if(lst.length==0){ |
|---|
| 666 | | return null; |
|---|
| 667 | | } |
|---|
| 668 | | var cur=lst[0]; |
|---|
| 669 | | var _97=MochiKit.Base.compare; |
|---|
| 670 | | for(var i=1;i<lst.length;i++){ |
|---|
| 671 | | var o=lst[i]; |
|---|
| 672 | | if(_97(o,cur)==_95){ |
|---|
| 673 | | cur=o; |
|---|
| 674 | | } |
|---|
| 675 | | } |
|---|
| 676 | | return cur; |
|---|
| 677 | | },objMax:function(){ |
|---|
| 678 | | return MochiKit.Base.listMinMax(1,arguments); |
|---|
| 679 | | },objMin:function(){ |
|---|
| 680 | | return MochiKit.Base.listMinMax(-1,arguments); |
|---|
| 681 | | },findIdentical:function(lst,_98,_99,end){ |
|---|
| 682 | | if(typeof (end)=="undefined"||end==null){ |
|---|
| 683 | | end=lst.length; |
|---|
| 684 | | } |
|---|
| 685 | | for(var i=(_99||0);i<end;i++){ |
|---|
| 686 | | if(lst[i]===_98){ |
|---|
| 687 | | return i; |
|---|
| 688 | | } |
|---|
| 689 | | } |
|---|
| 690 | | return -1; |
|---|
| 691 | | },findValue:function(lst,_101,_102,end){ |
|---|
| 692 | | if(typeof (end)=="undefined"||end==null){ |
|---|
| 693 | | end=lst.length; |
|---|
| 694 | | } |
|---|
| 695 | | var cmp=MochiKit.Base.compare; |
|---|
| 696 | | for(var i=(_102||0);i<end;i++){ |
|---|
| 697 | | if(cmp(lst[i],_101)==0){ |
|---|
| 698 | | return i; |
|---|
| 699 | | } |
|---|
| 700 | | } |
|---|
| 701 | | return -1; |
|---|
| 702 | | },nodeWalk:function(node,_104){ |
|---|
| 703 | | var _105=[node]; |
|---|
| 704 | | var _106=MochiKit.Base.extend; |
|---|
| 705 | | while(_105.length){ |
|---|
| 706 | | var res=_104(_105.shift()); |
|---|
| 707 | | if(res){ |
|---|
| 708 | | _106(_105,res); |
|---|
| 709 | | } |
|---|
| 710 | | } |
|---|
| 711 | | },nameFunctions:function(_107){ |
|---|
| 712 | | var base=_107.NAME; |
|---|
| 713 | | if(typeof (base)=="undefined"){ |
|---|
| 714 | | base=""; |
|---|
| 715 | | }else{ |
|---|
| 716 | | base=base+"."; |
|---|
| 717 | | } |
|---|
| 718 | | for(var name in _107){ |
|---|
| 719 | | var o=_107[name]; |
|---|
| 720 | | if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){ |
|---|
| 721 | | try{ |
|---|
| 722 | | o.NAME=base+name; |
|---|
| 723 | | } |
|---|
| 724 | | catch(e){ |
|---|
| 725 | | } |
|---|
| 726 | | } |
|---|
| 727 | | } |
|---|
| 728 | | },queryString:function(_110,_111){ |
|---|
| 729 | | if(typeof (MochiKit.DOM)!="undefined"&&arguments.length==1&&(typeof (_110)=="string"||(typeof (_110.nodeType)!="undefined"&&_110.nodeType>0))){ |
|---|
| 730 | | var kv=MochiKit.DOM.formContents(_110); |
|---|
| 731 | | _110=kv[0]; |
|---|
| 732 | | _111=kv[1]; |
|---|
| 733 | | }else{ |
|---|
| 734 | | if(arguments.length==1){ |
|---|
| 735 | | var o=_110; |
|---|
| 736 | | _110=[]; |
|---|
| 737 | | _111=[]; |
|---|
| 738 | | for(var k in o){ |
|---|
| 739 | | var v=o[k]; |
|---|
| 740 | | if(typeof (v)!="function"){ |
|---|
| 741 | | _110.push(k); |
|---|
| 742 | | _111.push(v); |
|---|
| 743 | | } |
|---|
| 744 | | } |
|---|
| 745 | | } |
|---|
| 746 | | } |
|---|
| 747 | | var rval=[]; |
|---|
| 748 | | var len=Math.min(_110.length,_111.length); |
|---|
| 749 | | var _115=MochiKit.Base.urlEncode; |
|---|
| 750 | | for(var i=0;i<len;i++){ |
|---|
| 751 | | v=_111[i]; |
|---|
| 752 | | if(typeof (v)!="undefined"&&v!=null){ |
|---|
| 753 | | rval.push(_115(_110[i])+"="+_115(v)); |
|---|
| 754 | | } |
|---|
| 755 | | } |
|---|
| 756 | | return rval.join("&"); |
|---|
| 757 | | },parseQueryString:function(_116,_117){ |
|---|
| 758 | | var _118=_116.replace(/\+/g,"%20").split("&"); |
|---|
| 759 | | var o={}; |
|---|
| 760 | | var _119; |
|---|
| 761 | | if(typeof (decodeURIComponent)!="undefined"){ |
|---|
| 762 | | _119=decodeURIComponent; |
|---|
| 763 | | }else{ |
|---|
| 764 | | _119=unescape; |
|---|
| 765 | | } |
|---|
| 766 | | if(_117){ |
|---|
| 767 | | for(var i=0;i<_118.length;i++){ |
|---|
| 768 | | var pair=_118[i].split("="); |
|---|
| 769 | | var name=_119(pair[0]); |
|---|
| 770 | | var arr=o[name]; |
|---|
| 771 | | if(!(arr instanceof Array)){ |
|---|
| 772 | | arr=[]; |
|---|
| 773 | | o[name]=arr; |
|---|
| 774 | | } |
|---|
| 775 | | arr.push(_119(pair[1])); |
|---|
| 776 | | } |
|---|
| 777 | | }else{ |
|---|
| 778 | | for(i=0;i<_118.length;i++){ |
|---|
| 779 | | pair=_118[i].split("="); |
|---|
| 780 | | o[_119(pair[0])]=_119(pair[1]); |
|---|
| 781 | | } |
|---|
| 782 | | } |
|---|
| 783 | | return o; |
|---|
| 784 | | }}); |
|---|
| 785 | | MochiKit.Base.AdapterRegistry=function(){ |
|---|
| 786 | | this.pairs=[]; |
|---|
| 787 | | }; |
|---|
| 788 | | MochiKit.Base.AdapterRegistry.prototype={register:function(name,_121,wrap,_123){ |
|---|
| 789 | | if(_123){ |
|---|
| 790 | | this.pairs.unshift([name,_121,wrap]); |
|---|
| 791 | | }else{ |
|---|
| 792 | | this.pairs.push([name,_121,wrap]); |
|---|
| 793 | | } |
|---|
| 794 | | },match:function(){ |
|---|
| 795 | | for(var i=0;i<this.pairs.length;i++){ |
|---|
| 796 | | var pair=this.pairs[i]; |
|---|
| 797 | | if(pair[1].apply(this,arguments)){ |
|---|
| 798 | | return pair[2].apply(this,arguments); |
|---|
| 799 | | } |
|---|
| 800 | | } |
|---|
| 801 | | throw MochiKit.Base.NotFound; |
|---|
| 802 | | },unregister:function(name){ |
|---|
| 803 | | for(var i=0;i<this.pairs.length;i++){ |
|---|
| 804 | | var pair=this.pairs[i]; |
|---|
| 805 | | if(pair[0]==name){ |
|---|
| 806 | | this.pairs.splice(i,1); |
|---|
| 807 | | return true; |
|---|
| 808 | | } |
|---|
| 809 | | } |
|---|
| 810 | | return false; |
|---|
| 811 | | }}; |
|---|
| 812 | | MochiKit.Base.EXPORT=["counter","clone","extend","update","updatetree","setdefault","keys","items","NamedError","operator","forwardCall","itemgetter","typeMatcher","isCallable","isUndefined","isUndefinedOrNull","isNull","isNotEmpty","isArrayLike","isDateLike","xmap","map","xfilter","filter","bind","bindMethods","NotFound","AdapterRegistry","registerComparator","compare","registerRepr","repr","objEqual","arrayEqual","concat","keyComparator","reverseKeyComparator","partial","merge","listMinMax","listMax","listMin","objMax","objMin","nodeWalk","zip","urlEncode","queryString","serializeJSON","registerJSON","evalJSON","parseQueryString","findValue","findIdentical","flattenArguments"]; |
|---|
| 813 | | MochiKit.Base.EXPORT_OK=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"]; |
|---|
| 814 | | MochiKit.Base._exportSymbols=function(_124,_125){ |
|---|
| 815 | | if(typeof (MochiKit.__export__)=="undefined"){ |
|---|
| 816 | | MochiKit.__export__=(MochiKit.__compat__||(typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")); |
|---|
| 817 | | } |
|---|
| 818 | | if(!MochiKit.__export__){ |
|---|
| 819 | | return; |
|---|
| 820 | | } |
|---|
| 821 | | var all=_125.EXPORT_TAGS[":all"]; |
|---|
| 822 | | for(var i=0;i<all.length;i++){ |
|---|
| 823 | | _124[all[i]]=_125[all[i]]; |
|---|
| 824 | | } |
|---|
| 825 | | }; |
|---|
| 826 | | MochiKit.Base.__new__=function(){ |
|---|
| 827 | | var m=this; |
|---|
| 828 | | m.forward=m.forwardCall; |
|---|
| 829 | | m.find=m.findValue; |
|---|
| 830 | | if(typeof (encodeURIComponent)!="undefined"){ |
|---|
| 831 | | m.urlEncode=function(_127){ |
|---|
| 832 | | return encodeURIComponent(_127).replace(/\'/g,"%27"); |
|---|
| 833 | | }; |
|---|
| 834 | | }else{ |
|---|
| 835 | | m.urlEncode=function(_128){ |
|---|
| 836 | | return escape(_128).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval.replace(/\'/g,"%27"); |
|---|
| 837 | | }; |
|---|
| 838 | | } |
|---|
| 839 | | m.NamedError=function(name){ |
|---|
| 840 | | this.message=name; |
|---|
| 841 | | this.name=name; |
|---|
| 842 | | }; |
|---|
| 843 | | m.NamedError.prototype=new Error(); |
|---|
| 844 | | m.update(m.NamedError.prototype,{repr:function(){ |
|---|
| 845 | | if(this.message&&this.message!=this.name){ |
|---|
| 846 | | return this.name+"("+m.repr(this.message)+")"; |
|---|
| 847 | | }else{ |
|---|
| 848 | | return this.name+"()"; |
|---|
| 849 | | } |
|---|
| 850 | | },toString:m.forwardCall("repr")}); |
|---|
| 851 | | m.NotFound=new m.NamedError("MochiKit.Base.NotFound"); |
|---|
| 852 | | m.listMax=m.partial(m.listMinMax,1); |
|---|
| 853 | | m.listMin=m.partial(m.listMinMax,-1); |
|---|
| 854 | | m.isCallable=m.typeMatcher("function"); |
|---|
| 855 | | m.isUndefined=m.typeMatcher("undefined"); |
|---|
| 856 | | m.merge=m.partial(m.update,null); |
|---|
| 857 | | m.zip=m.partial(m.map,null); |
|---|
| 858 | | m.comparatorRegistry=new m.AdapterRegistry(); |
|---|
| 859 | | m.registerComparator("dateLike",m.isDateLike,m.compareDateLike); |
|---|
| 860 | | m.registerComparator("arrayLike",m.isArrayLike,m.compareArrayLike); |
|---|
| 861 | | m.reprRegistry=new m.AdapterRegistry(); |
|---|
| 862 | | m.registerRepr("arrayLike",m.isArrayLike,m.reprArrayLike); |
|---|
| 863 | | m.registerRepr("string",m.typeMatcher("string"),m.reprString); |
|---|
| 864 | | m.registerRepr("numbers",m.typeMatcher("number","boolean"),m.reprNumber); |
|---|
| 865 | | m.jsonRegistry=new m.AdapterRegistry(); |
|---|
| 866 | | var all=m.concat(m.EXPORT,m.EXPORT_OK); |
|---|
| 867 | | m.EXPORT_TAGS={":common":m.concat(m.EXPORT_OK),":all":all}; |
|---|
| 868 | | m.nameFunctions(this); |
|---|
| 869 | | }; |
|---|
| 870 | | MochiKit.Base.__new__(); |
|---|
| 871 | | compare=MochiKit.Base.compare; |
|---|
| 872 | | MochiKit.Base._exportSymbols(this,MochiKit.Base); |
|---|
| 873 | | if(typeof (dojo)!="undefined"){ |
|---|
| 874 | | dojo.provide("MochiKit.Iter"); |
|---|
| 875 | | dojo.require("MochiKit.Base"); |
|---|
| 876 | | } |
|---|
| 877 | | if(typeof (JSAN)!="undefined"){ |
|---|
| 878 | | JSAN.use("MochiKit.Base",[]); |
|---|
| 879 | | } |
|---|
| 880 | | try{ |
|---|
| 881 | | if(typeof (MochiKit.Base)=="undefined"){ |
|---|
| 882 | | throw ""; |
|---|
| 883 | | } |
|---|
| 884 | | } |
|---|
| 885 | | catch(e){ |
|---|
| 886 | | throw "MochiKit.Iter depends on MochiKit.Base!"; |
|---|
| 887 | | } |
|---|
| 888 | | if(typeof (MochiKit.Iter)=="undefined"){ |
|---|
| 889 | | MochiKit.Iter={}; |
|---|
| 890 | | } |
|---|
| 891 | | MochiKit.Iter.NAME="MochiKit.Iter"; |
|---|
| 892 | | MochiKit.Iter.VERSION="1.3"; |
|---|
| 893 | | MochiKit.Base.update(MochiKit.Iter,{__repr__:function(){ |
|---|
| 894 | | return "["+this.NAME+" "+this.VERSION+"]"; |
|---|
| 895 | | },toString:function(){ |
|---|
| 896 | | return this.__repr__(); |
|---|
| 897 | | },registerIteratorFactory:function(name,_129,_130,_131){ |
|---|
| 898 | | MochiKit.Iter.iteratorRegistry.register(name,_129,_130,_131); |
|---|
| 899 | | },iter:function(_132,_133){ |
|---|
| 900 | | var self=MochiKit.Iter; |
|---|
| 901 | | if(arguments.length==2){ |
|---|
| 902 | | return self.takewhile(function(a){ |
|---|
| 903 | | return a!=_133; |
|---|
| 904 | | },_132); |
|---|
| 905 | | } |
|---|
| 906 | | if(typeof (_132.next)=="function"){ |
|---|
| 907 | | return _132; |
|---|
| 908 | | }else{ |
|---|
| 909 | | if(typeof (_132.iter)=="function"){ |
|---|
| 910 | | return _132.iter(); |
|---|
| 911 | | } |
|---|
| 912 | | } |
|---|
| 913 | | try{ |
|---|
| 914 | | return self.iteratorRegistry.match(_132); |
|---|
| 915 | | } |
|---|
| 916 | | catch(e){ |
|---|
| 917 | | var m=MochiKit.Base; |
|---|
| 918 | | if(e==m.NotFound){ |
|---|
| 919 | | e=new TypeError(typeof (_132)+": "+m.repr(_132)+" is not iterable"); |
|---|
| 920 | | } |
|---|
| 921 | | throw e; |
|---|
| 922 | | } |
|---|
| 923 | | },count:function(n){ |
|---|
| 924 | | if(!n){ |
|---|
| 925 | | n=0; |
|---|
| 926 | | } |
|---|
| 927 | | var m=MochiKit.Base; |
|---|
| 928 | | return {repr:function(){ |
|---|
| 929 | | return "count("+n+")"; |
|---|
| 930 | | },toString:m.forwardCall("repr"),next:m.counter(n)}; |
|---|
| 931 | | },cycle:function(p){ |
|---|
| 932 | | var self=MochiKit.Iter; |
|---|
| 933 | | var m=MochiKit.Base; |
|---|
| 934 | | var lst=[]; |
|---|
| 935 | | var _136=self.iter(p); |
|---|
| 936 | | return {repr:function(){ |
|---|
| 937 | | return "cycle(...)"; |
|---|
| 938 | | },toString:m.forwardCall("repr"),next:function(){ |
|---|
| 939 | | try{ |
|---|
| 940 | | var rval=_136.next(); |
|---|
| 941 | | lst.push(rval); |
|---|
| 942 | | return rval; |
|---|
| 943 | | } |
|---|
| 944 | | catch(e){ |
|---|
| 945 | | if(e!=self.StopIteration){ |
|---|
| 946 | | throw e; |
|---|
| 947 | | } |
|---|
| 948 | | if(lst.length==0){ |
|---|
| 949 | | this.next=function(){ |
|---|
| 950 | | throw self.StopIteration; |
|---|
| 951 | | }; |
|---|
| 952 | | }else{ |
|---|
| 953 | | var i=-1; |
|---|
| 954 | | this.next=function(){ |
|---|
| 955 | | i=(i+1)%lst.length; |
|---|
| 956 | | return lst[i]; |
|---|
| 957 | | }; |
|---|
| 958 | | } |
|---|
| 959 | | return this.next(); |
|---|
| 960 | | } |
|---|
| 961 | | }}; |
|---|
| 962 | | },repeat:function(elem,n){ |
|---|
| 963 | | var m=MochiKit.Base; |
|---|
| 964 | | if(typeof (n)=="undefined"){ |
|---|
| 965 | | return {repr:function(){ |
|---|
| 966 | | return "repeat("+m.repr(elem)+")"; |
|---|
| 967 | | },toString:m.forwardCall("repr"),next:function(){ |
|---|
| 968 | | return elem; |
|---|
| 969 | | }}; |
|---|
| 970 | | } |
|---|
| 971 | | return {repr:function(){ |
|---|
| 972 | | return "repeat("+m.repr(elem)+", "+n+")"; |
|---|
| 973 | | },toString:m.forwardCall("repr"),next:function(){ |
|---|
| 974 | | if(n<=0){ |
|---|
| 975 | | throw MochiKit.Iter.StopIteration; |
|---|
| 976 | | } |
|---|
| 977 | | n-=1; |
|---|
| 978 | | return elem; |
|---|
| 979 | | }}; |
|---|
| 980 | | },next:function(_138){ |
|---|
| 981 | | return _138.next(); |
|---|
| 982 | | },izip:function(p,q){ |
|---|
| 983 | | var m=MochiKit.Base; |
|---|
| 984 | | var next=MochiKit.Iter.next; |
|---|
| 985 | | var _141=m.map(iter,arguments); |
|---|
| 986 | | return {repr:function(){ |
|---|
| 987 | | return "izip(...)"; |
|---|
| 988 | | },toString:m.forwardCall("repr"),next:function(){ |
|---|
| 989 | | return m.map(next,_141); |
|---|
| 990 | | }}; |
|---|
| 991 | | },ifilter:function(pred,seq){ |
|---|
| 992 | | var m=MochiKit.Base; |
|---|
| 993 | | seq=MochiKit.Iter.iter(seq); |
|---|
| 994 | | if(pred==null){ |
|---|
| 995 | | pred=m.operator.truth; |
|---|
| 996 | | } |
|---|
| 997 | | return {repr:function(){ |
|---|
| 998 | | return "ifilter(...)"; |
|---|
| 999 | | },toString:m.forwardCall("repr"),next:function(){ |
|---|
| 1000 | | while(true){ |
|---|
| 1001 | | var rval=seq.next(); |
|---|
| 1002 | | if(pred(rval)){ |
|---|
| 1003 | | return rval; |
|---|
| 1004 | | } |
|---|
| 1005 | | } |
|---|
| 1006 | | return undefined; |
|---|
| 1007 | | }}; |
|---|
| 1008 | | },ifilterfalse:function(pred,seq){ |
|---|
| 1009 | | var m=MochiKit.Base; |
|---|
| 1010 | | seq=MochiKit.Iter.iter(seq); |
|---|
| 1011 | | if(pred==null){ |
|---|
| 1012 | | pred=m.operator.truth; |
|---|
| 1013 | | } |
|---|
| 1014 | | return {repr:function(){ |
|---|
| 1015 | | return "ifilterfalse(...)"; |
|---|
| 1016 | | },toString:m.forwardCall("repr"),next:function(){ |
|---|
| 1017 | | while(true){ |
|---|
| 1018 | | var rval=seq.next(); |
|---|
| 1019 | | if(!pred(rval)){ |
|---|
| 1020 | | return rval; |
|---|
| 1021 | | } |
|---|
| 1022 | | } |
|---|
| 1023 | | return undefined; |
|---|
| 1024 | | }}; |
|---|
| 1025 | | },islice:function(seq){ |
|---|
| 1026 | | var self=MochiKit.Iter; |
|---|
| 1027 | | var m=MochiKit.Base; |
|---|
| 1028 | | seq=self.iter(seq); |
|---|
| 1029 | | var _144=0; |
|---|
| 1030 | | var stop=0; |
|---|
| 1031 | | var step=1; |
|---|
| 1032 | | var i=-1; |
|---|
| 1033 | | if(arguments.length==2){ |
|---|
| 1034 | | stop=arguments[1]; |
|---|
| 1035 | | }else{ |
|---|
| 1036 | | if(arguments.length==3){ |
|---|
| 1037 | | _144=arguments[1]; |
|---|
| 1038 | | stop=arguments[2]; |
|---|
| 1039 | | }else{ |
|---|
| 1040 | | _144=arguments[1]; |
|---|
| 1041 | | stop=arguments[2]; |
|---|
| 1042 | | step=arguments[3]; |
|---|
| 1043 | | } |
|---|
| 1044 | | } |
|---|
| 1045 | | return {repr:function(){ |
|---|
| 1046 | | return "islice("+["...",_144,stop,step].join(", ")+")"; |
|---|
| 1047 | | },toString:m.forwardCall("repr"),next:function(){ |
|---|
| 1048 | | var rval; |
|---|
| 1049 | | while(i<_144){ |
|---|
| 1050 | | rval=seq.next(); |
|---|
| 1051 | | i++; |
|---|
| 1052 | | } |
|---|
| 1053 | | if(_144>=stop){ |
|---|
| 1054 | | throw self.StopIteration; |
|---|
| 1055 | | } |
|---|
| 1056 | | _144+=step; |
|---|
| 1057 | | return rval; |
|---|
| 1058 | | }}; |
|---|
| 1059 | | },imap:function(fun,p,q){ |
|---|
| 1060 | | var m=MochiKit.Base; |
|---|
| 1061 | | var self=MochiKit.Iter; |
|---|
| 1062 | | var _148=m.map(self.iter,m.extend(null,arguments,1)); |
|---|
| 1063 | | var map=m.map; |
|---|
| 1064 | | var next=self.next; |
|---|
| 1065 | | return {repr:function(){ |
|---|
| 1066 | | return "imap(...)"; |
|---|
| 1067 | | },toString:m.forwardCall("repr"),next:function(){ |
|---|
| 1068 | | return fun.apply(this,map(next,_148)); |
|---|
| 1069 | | }}; |
|---|
| 1070 | | },applymap:function(fun,seq,self){ |
|---|
| 1071 | | seq=MochiKit.Iter.iter(seq); |
|---|
| 1072 | | var m=MochiKit.Base; |
|---|
| 1073 | | return {repr:function(){ |
|---|
| 1074 | | return "applymap(...)"; |
|---|
| 1075 | | },toString:m.forwardCall("repr"),next:function(){ |
|---|
| 1076 | | return fun.apply(self,seq.next()); |
|---|
| 1077 | | }}; |
|---|
| 1078 | | },chain:function(p,q){ |
|---|
| 1079 | | var self=MochiKit.Iter; |
|---|
| 1080 | | var m=MochiKit.Base; |
|---|
| 1081 | | if(arguments.length==1){ |
|---|
| 1082 | | return self.iter(arguments[0]); |
|---|
| 1083 | | } |
|---|
| 1084 | | var _150=m.map(self.iter,arguments); |
|---|
| 1085 | | return {repr:function(){ |
|---|
| 1086 | | return "chain(...)"; |
|---|
| 1087 | | },toString:m.forwardCall("repr"),next:function(){ |
|---|
| 1088 | | while(_150.length>1){ |
|---|
| 1089 | | try{ |
|---|
| 1090 | | return _150[0].next(); |
|---|
| 1091 | | } |
|---|
| 1092 | | catch(e){ |
|---|
| 1093 | | if(e!=self.StopIteration){ |
|---|
| 1094 | | throw e; |
|---|
| 1095 | | } |
|---|
| 1096 | | _150.shift(); |
|---|
| 1097 | | } |
|---|
| 1098 | | } |
|---|
| 1099 | | if(_150.length==1){ |
|---|
| 1100 | | var arg=_150.shift(); |
|---|
| 1101 | | this.next=m.bind("next",arg); |
|---|
| 1102 | | return this.next(); |
|---|
| 1103 | | } |
|---|
| 1104 | | throw self.StopIteration; |
|---|
| 1105 | | }}; |
|---|
| 1106 | | },takewhile:function(pred,seq){ |
|---|
| 1107 | | var self=MochiKit.Iter; |
|---|
| 1108 | | seq=self.iter(seq); |
|---|
| 1109 | | return {repr:function(){ |
|---|
| 1110 | | return "takewhile(...)"; |
|---|
| 1111 | | },toString:MochiKit.Base.forwardCall("repr"),next:function(){ |
|---|
| 1112 | | var rval=seq.next(); |
|---|
| 1113 | | if(!pred(rval)){ |
|---|
| 1114 | | this.next=function(){ |
|---|
| 1115 | | throw self.StopIteration; |
|---|
| 1116 | | }; |
|---|
| 1117 | | this.next(); |
|---|
| 1118 | | } |
|---|
| 1119 | | return rval; |
|---|
| 1120 | | }}; |
|---|
| 1121 | | },dropwhile:function(pred,seq){ |
|---|
| 1122 | | seq=MochiKit.Iter.iter(seq); |
|---|
| 1123 | | var m=MochiKit.Base; |
|---|
| 1124 | | var bind=m.bind; |
|---|
| 1125 | | return {"repr":function(){ |
|---|
| 1126 | | return "dropwhile(...)"; |
|---|
| 1127 | | },"toString":m.forwardCall("repr"),"next":function(){ |
|---|
| 1128 | | while(true){ |
|---|
| 1129 | | var rval=seq.next(); |
|---|
| 1130 | | if(!pred(rval)){ |
|---|
| 1131 | | break; |
|---|
| 1132 | | } |
|---|
| 1133 | | } |
|---|
| 1134 | | this.next=bind("next",seq); |
|---|
| 1135 | | return rval; |
|---|
| 1136 | | }}; |
|---|
| 1137 | | },_tee:function(_152,sync,_154){ |
|---|
| 1138 | | sync.pos[_152]=-1; |
|---|
| 1139 | | var m=MochiKit.Base; |
|---|
| 1140 | | var _155=m.listMin; |
|---|
| 1141 | | return {repr:function(){ |
|---|
| 1142 | | return "tee("+_152+", ...)"; |
|---|
| 1143 | | },toString:m.forwardCall("repr"),next:function(){ |
|---|
| 1144 | | var rval; |
|---|
| 1145 | | var i=sync.pos[_152]; |
|---|
| 1146 | | if(i==sync.max){ |
|---|
| 1147 | | rval=_154.next(); |
|---|
| 1148 | | sync.deque.push(rval); |
|---|
| 1149 | | sync.max+=1; |
|---|
| 1150 | | sync.pos[_152]+=1; |
|---|
| 1151 | | }else{ |
|---|
| 1152 | | rval=sync.deque[i-sync.min]; |
|---|
| 1153 | | sync.pos[_152]+=1; |
|---|
| 1154 | | if(i==sync.min&&_155(sync.pos)!=sync.min){ |
|---|
| 1155 | | sync.min+=1; |
|---|
| 1156 | | sync.deque.shift(); |
|---|
| 1157 | | } |
|---|
| 1158 | | } |
|---|
| 1159 | | return rval; |
|---|
| 1160 | | }}; |
|---|
| 1161 | | },tee:function(_156,n){ |
|---|
| 1162 | | var rval=[]; |
|---|
| 1163 | | var sync={"pos":[],"deque":[],"max":-1,"min":-1}; |
|---|
| 1164 | | if(arguments.length==1){ |
|---|
| 1165 | | n=2; |
|---|
| 1166 | | } |
|---|
| 1167 | | var self=MochiKit.Iter; |
|---|
| 1168 | | _156=self.iter(_156); |
|---|
| 1169 | | var _tee=self._tee; |
|---|
| 1170 | | for(var i=0;i<n;i++){ |
|---|
| 1171 | | rval.push(_tee(i,sync,_156)); |
|---|
| 1172 | | } |
|---|
| 1173 | | return rval; |
|---|
| 1174 | | },list:function(_158){ |
|---|
| 1175 | | var m=MochiKit.Base; |
|---|
| 1176 | | if(typeof (_158.slice)=="function"){ |
|---|
| 1177 | | return _158.slice(); |
|---|
| 1178 | | }else{ |
|---|
| 1179 | | if(m.isArrayLike(_158)){ |
|---|
| 1180 | | return m.concat(_158); |
|---|
| 1181 | | } |
|---|
| 1182 | | } |
|---|
| 1183 | | var self=MochiKit.Iter; |
|---|
| 1184 | | _158=self.iter(_158); |
|---|
| 1185 | | var rval=[]; |
|---|
| 1186 | | try{ |
|---|
| 1187 | | while(true){ |
|---|
| 1188 | | rval.push(_158.next()); |
|---|
| 1189 | | } |
|---|
| 1190 | | } |
|---|
| 1191 | | catch(e){ |
|---|
| 1192 | | if(e!=self.StopIteration){ |
|---|
| 1193 | | throw e; |
|---|
| 1194 | | } |
|---|
| 1195 | | return rval; |
|---|
| 1196 | | } |
|---|
| 1197 | | return undefined; |
|---|
| 1198 | | },reduce:function(fn,_159,_160){ |
|---|
| 1199 | | var i=0; |
|---|
| 1200 | | var x=_160; |
|---|
| 1201 | | var self=MochiKit.Iter; |
|---|
| 1202 | | _159=self.iter(_159); |
|---|
| 1203 | | if(arguments.length<3){ |
|---|
| 1204 | | try{ |
|---|
| 1205 | | x=_159.next(); |
|---|
| 1206 | | } |
|---|
| 1207 | | catch(e){ |
|---|
| 1208 | | if(e==self.StopIteration){ |
|---|
| 1209 | | e=new TypeError("reduce() of empty sequence with no initial value"); |
|---|
| 1210 | | } |
|---|
| 1211 | | throw e; |
|---|
| 1212 | | } |
|---|
| 1213 | | i++; |
|---|
| 1214 | | } |
|---|
| 1215 | | try{ |
|---|
| 1216 | | while(true){ |
|---|
| 1217 | | x=fn(x,_159.next()); |
|---|
| 1218 | | } |
|---|
| 1219 | | } |
|---|
| 1220 | | catch(e){ |
|---|
| 1221 | | if(e!=self.StopIteration){ |
|---|
| 1222 | | throw e; |
|---|
| 1223 | | } |
|---|
| 1224 | | } |
|---|
| 1225 | | return x; |
|---|
| 1226 | | },range:function(){ |
|---|
| 1227 | | var _162=0; |
|---|
| 1228 | | var stop=0; |
|---|
| 1229 | | var step=1; |
|---|
| 1230 | | if(arguments.length==1){ |
|---|
| 1231 | | stop=arguments[0]; |
|---|
| 1232 | | }else{ |
|---|
| 1233 | | if(arguments.length==2){ |
|---|
| 1234 | | _162=arguments[0]; |
|---|
| 1235 | | stop=arguments[1]; |
|---|
| 1236 | | }else{ |
|---|
| 1237 | | if(arguments.length==3){ |
|---|
| 1238 | | _162=arguments[0]; |
|---|
| 1239 | | stop=arguments[1]; |
|---|
| 1240 | | step=arguments[2]; |
|---|
| 1241 | | }else{ |
|---|
| 1242 | | throw new TypeError("range() takes 1, 2, or 3 arguments!"); |
|---|
| 1243 | | } |
|---|
| 1244 | | } |
|---|
| 1245 | | } |
|---|
| 1246 | | if(step==0){ |
|---|
| 1247 | | throw new TypeError("range() step must not be 0"); |
|---|
| 1248 | | } |
|---|
| 1249 | | return {next:function(){ |
|---|
| 1250 | | if((step>0&&_162>=stop)||(step<0&&_162<=stop)){ |
|---|
| 1251 | | throw MochiKit.Iter.StopIteration; |
|---|
| 1252 | | } |
|---|
| 1253 | | var rval=_162; |
|---|
| 1254 | | _162+=step; |
|---|
| 1255 | | return rval; |
|---|
| 1256 | | },repr:function(){ |
|---|
| 1257 | | return "range("+[_162,stop,step].join(", ")+")"; |
|---|
| 1258 | | },toString:MochiKit.Base.forwardCall("repr")}; |
|---|
| 1259 | | },sum:function(_163,_164){ |
|---|
| 1260 | | var x=_164||0; |
|---|
| 1261 | | var self=MochiKit.Iter; |
|---|
| 1262 | | _163=self.iter(_163); |
|---|
| 1263 | | try{ |
|---|
| 1264 | | while(true){ |
|---|
| 1265 | | x+=_163.next(); |
|---|
| 1266 | | } |
|---|
| 1267 | | } |
|---|
| 1268 | | catch(e){ |
|---|
| 1269 | | if(e!=self.StopIteration){ |
|---|
| 1270 | | throw e; |
|---|
| 1271 | | } |
|---|
| 1272 | | } |
|---|
| 1273 | | return x; |
|---|
| 1274 | | },exhaust:function(_165){ |
|---|
| 1275 | | var self=MochiKit.Iter; |
|---|
| 1276 | | _165=self.iter(_165); |
|---|
| 1277 | | try{ |
|---|
| 1278 | | while(true){ |
|---|
| 1279 | | _165.next(); |
|---|
| 1280 | | } |
|---|
| 1281 | | } |
|---|
| 1282 | | catch(e){ |
|---|
| 1283 | | if(e!=self.StopIteration){ |
|---|
| 1284 | | throw e; |
|---|
| 1285 | | } |
|---|
| 1286 | | } |
|---|
| 1287 | | },forEach:function(_166,func,self){ |
|---|
| 1288 | | var m=MochiKit.Base; |
|---|
| 1289 | | if(arguments.length>2){ |
|---|
| 1290 | | func=m.bind(func,self); |
|---|
| 1291 | | } |
|---|
| 1292 | | if(m.isArrayLike(_166)){ |
|---|
| 1293 | | try{ |
|---|
| 1294 | | for(var i=0;i<_166.length;i++){ |
|---|
| 1295 | | func(_166[i]); |
|---|
| 1296 | | } |
|---|
| 1297 | | } |
|---|
| 1298 | | catch(e){ |
|---|
| 1299 | | if(e!=MochiKit.Iter.StopIteration){ |
|---|
| 1300 | | throw e; |
|---|
| 1301 | | } |
|---|
| 1302 | | } |
|---|
| 1303 | | }else{ |
|---|
| 1304 | | self=MochiKit.Iter; |
|---|
| 1305 | | self.exhaust(self.imap(func,_166)); |
|---|
| 1306 | | } |
|---|
| 1307 | | },every:function(_168,func){ |
|---|
| 1308 | | var self=MochiKit.Iter; |
|---|
| 1309 | | try{ |
|---|
| 1310 | | self.ifilterfalse(func,_168).next(); |
|---|
| 1311 | | return false; |
|---|
| 1312 | | } |
|---|
| 1313 | | catch(e){ |
|---|
| 1314 | | if(e!=self.StopIteration){ |
|---|
| 1315 | | throw e; |
|---|
| 1316 | | } |
|---|
| 1317 | | return true; |
|---|
| 1318 | | } |
|---|
| 1319 | | },sorted:function(_169,cmp){ |
|---|
| 1320 | | var rval=MochiKit.Iter.list(_169); |
|---|
| 1321 | | if(arguments.length==1){ |
|---|
| 1322 | | cmp=MochiKit.Base.compare; |
|---|
| 1323 | | } |
|---|
| 1324 | | rval.sort(cmp); |
|---|
| 1325 | | return rval; |
|---|
| 1326 | | },reversed:function(_170){ |
|---|
| 1327 | | var rval=MochiKit.Iter.list(_170); |
|---|
| 1328 | | rval.reverse(); |
|---|
| 1329 | | return rval; |
|---|
| 1330 | | },some:function(_171,func){ |
|---|
| 1331 | | var self=MochiKit.Iter; |
|---|
| 1332 | | try{ |
|---|
| 1333 | | self.ifilter(func,_171).next(); |
|---|
| 1334 | | return true; |
|---|
| 1335 | | } |
|---|
| 1336 | | catch(e){ |
|---|
| 1337 | | if(e!=self.StopIteration){ |
|---|
| 1338 | | throw e; |
|---|
| 1339 | | } |
|---|
| 1340 | | return false; |
|---|
| 1341 | | } |
|---|
| 1342 | | },iextend:function(lst,_172){ |
|---|
| 1343 | | if(MochiKit.Base.isArrayLike(_172)){ |
|---|
| 1344 | | for(var i=0;i<_172.length;i++){ |
|---|
| 1345 | | lst.push(_172[i]); |
|---|
| 1346 | | } |
|---|
| 1347 | | }else{ |
|---|
| 1348 | | var self=MochiKit.Iter; |
|---|
| 1349 | | _172=self.iter(_172); |
|---|
| 1350 | | try{ |
|---|
| 1351 | | while(true){ |
|---|
| 1352 | | lst.push(_172.next()); |
|---|
| 1353 | | } |
|---|
| 1354 | | } |
|---|