| | 559 | |
|---|
| | 560 | /*** |
|---|
| | 561 | |
|---|
| | 562 | MochiKit.MochiKit 1.3 : PACKED VERSION |
|---|
| | 563 | |
|---|
| | 564 | THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please |
|---|
| | 565 | diff against the source tree, not this file. |
|---|
| | 566 | |
|---|
| | 567 | See <http://mochikit.com/> for documentation, downloads, license, etc. |
|---|
| | 568 | |
|---|
| | 569 | (c) 2005 Bob Ippolito. All rights Reserved. |
|---|
| | 570 | |
|---|
| | 571 | ***/ |
|---|
| | 572 | |
|---|
| | 573 | if(typeof (dojo)!="undefined"){ |
|---|
| | 574 | dojo.provide("MochiKit.Base"); |
|---|
| | 575 | } |
|---|
| | 576 | if(typeof (MochiKit)=="undefined"){ |
|---|
| | 577 | MochiKit={}; |
|---|
| | 578 | } |
|---|
| | 579 | if(typeof (MochiKit.Base)=="undefined"){ |
|---|
| | 580 | MochiKit.Base={}; |
|---|
| | 581 | } |
|---|
| | 582 | MochiKit.Base.VERSION="1.3"; |
|---|
| | 583 | MochiKit.Base.NAME="MochiKit.Base"; |
|---|
| | 584 | MochiKit.Base.update=function(_1,_2){ |
|---|
| | 585 | if(_1==null){ |
|---|
| | 586 | _1={}; |
|---|
| | 587 | } |
|---|
| | 588 | for(var i=1;i<arguments.length;i++){ |
|---|
| | 589 | var o=arguments[i]; |
|---|
| | 590 | if(typeof (o)!="undefined"&&o!=null){ |
|---|
| | 591 | for(var k in o){ |
|---|
| | 592 | _1[k]=o[k]; |
|---|
| | 593 | } |
|---|
| | 594 | } |
|---|
| | 595 | } |
|---|
| | 596 | return _1; |
|---|
| | 597 | }; |
|---|
| | 598 | MochiKit.Base.update(MochiKit.Base,{__repr__:function(){ |
|---|
| | 599 | return "["+this.NAME+" "+this.VERSION+"]"; |
|---|
| | 600 | },toString:function(){ |
|---|
| | 601 | return this.__repr__(); |
|---|
| | 602 | },counter:function(n){ |
|---|
| | 603 | if(arguments.length==0){ |
|---|
| | 604 | n=1; |
|---|
| | 605 | } |
|---|
| | 606 | return function(){ |
|---|
| | 607 | return n++; |
|---|
| | 608 | }; |
|---|
| | 609 | },clone:function(_7){ |
|---|
| | 610 | var me=arguments.callee; |
|---|
| | 611 | if(arguments.length==1){ |
|---|
| | 612 | me.prototype=_7; |
|---|
| | 613 | return new me(); |
|---|
| | 614 | } |
|---|
| | 615 | },flattenArguments:function(_9){ |
|---|
| | 616 | var res=[]; |
|---|
| | 617 | var m=MochiKit.Base; |
|---|
| | 618 | var _12=m.extend(null,arguments); |
|---|
| | 619 | while(_12.length){ |
|---|
| | 620 | var o=_12.shift(); |
|---|
| | 621 | if(o&&typeof (o)=="object"&&typeof (o.length)=="number"){ |
|---|
| | 622 | for(var i=o.length-1;i>=0;i--){ |
|---|
| | 623 | _12.unshift(o[i]); |
|---|
| | 624 | } |
|---|
| | 625 | }else{ |
|---|
| | 626 | res.push(o); |
|---|
| | 627 | } |
|---|
| | 628 | } |
|---|
| | 629 | return res; |
|---|
| | 630 | },extend:function(_13,obj,_15){ |
|---|
| | 631 | if(!_15){ |
|---|
| | 632 | _15=0; |
|---|
| | 633 | } |
|---|
| | 634 | if(obj){ |
|---|
| | 635 | var l=obj.length; |
|---|
| | 636 | if(typeof (l)!="number"){ |
|---|
| | 637 | if(typeof (MochiKit.Iter)!="undefined"){ |
|---|
| | 638 | obj=MochiKit.Iter.list(obj); |
|---|
| | 639 | l=obj.length; |
|---|
| | 640 | }else{ |
|---|
| | 641 | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
|---|
| | 642 | } |
|---|
| | 643 | } |
|---|
| | 644 | if(!_13){ |
|---|
| | 645 | _13=[]; |
|---|
| | 646 | } |
|---|
| | 647 | for(var i=_15;i<l;i++){ |
|---|
| | 648 | _13.push(obj[i]); |
|---|
| | 649 | } |
|---|
| | 650 | } |
|---|
| | 651 | return _13; |
|---|
| | 652 | },updatetree:function(_17,obj){ |
|---|
| | 653 | if(_17==null){ |
|---|
| | 654 | _17={}; |
|---|
| | 655 | } |
|---|
| | 656 | for(var i=1;i<arguments.length;i++){ |
|---|
| | 657 | var o=arguments[i]; |
|---|
| | 658 | if(typeof (o)!="undefined"&&o!=null){ |
|---|
| | 659 | for(var k in o){ |
|---|
| | 660 | var v=o[k]; |
|---|
| | 661 | if(typeof (_17[k])=="object"&&typeof (v)=="object"){ |
|---|
| | 662 | arguments.callee(_17[k],v); |
|---|
| | 663 | }else{ |
|---|
| | 664 | _17[k]=v; |
|---|
| | 665 | } |
|---|
| | 666 | } |
|---|
| | 667 | } |
|---|
| | 668 | } |
|---|
| | 669 | return _17; |
|---|
| | 670 | },setdefault:function(_19,obj){ |
|---|
| | 671 | if(_19==null){ |
|---|
| | 672 | _19={}; |
|---|
| | 673 | } |
|---|
| | 674 | for(var i=1;i<arguments.length;i++){ |
|---|
| | 675 | var o=arguments[i]; |
|---|
| | 676 | for(var k in o){ |
|---|
| | 677 | if(!(k in _19)){ |
|---|
| | 678 | _19[k]=o[k]; |
|---|
| | 679 | } |
|---|
| | 680 | } |
|---|
| | 681 | } |
|---|
| | 682 | return _19; |
|---|
| | 683 | },keys:function(obj){ |
|---|
| | 684 | var _20=[]; |
|---|
| | 685 | for(var _21 in obj){ |
|---|
| | 686 | _20.push(_21); |
|---|
| | 687 | } |
|---|
| | 688 | return _20; |
|---|
| | 689 | },items:function(obj){ |
|---|
| | 690 | var _22=[]; |
|---|
| | 691 | var e; |
|---|
| | 692 | for(var _24 in obj){ |
|---|
| | 693 | var v; |
|---|
| | 694 | try{ |
|---|
| | 695 | v=obj[_24]; |
|---|
| | 696 | } |
|---|
| | 697 | catch(e){ |
|---|
| | 698 | continue; |
|---|
| | 699 | } |
|---|
| | 700 | _22.push([_24,v]); |
|---|
| | 701 | } |
|---|
| | 702 | return _22; |
|---|
| | 703 | },_newNamedError:function(_25,_26,_27){ |
|---|
| | 704 | _27.prototype=new MochiKit.Base.NamedError(_25.NAME+"."+_26); |
|---|
| | 705 | _25[_26]=_27; |
|---|
| | 706 | },operator:{truth:function(a){ |
|---|
| | 707 | return !!a; |
|---|
| | 708 | },lognot:function(a){ |
|---|
| | 709 | return !a; |
|---|
| | 710 | },identity:function(a){ |
|---|
| | 711 | return a; |
|---|
| | 712 | },not:function(a){ |
|---|
| | 713 | return ~a; |
|---|
| | 714 | },neg:function(a){ |
|---|
| | 715 | return -a; |
|---|
| | 716 | },add:function(a,b){ |
|---|
| | 717 | return a+b; |
|---|
| | 718 | },sub:function(a,b){ |
|---|
| | 719 | return a-b; |
|---|
| | 720 | },div:function(a,b){ |
|---|
| | 721 | return a/b; |
|---|
| | 722 | },mod:function(a,b){ |
|---|
| | 723 | return a%b; |
|---|
| | 724 | },mul:function(a,b){ |
|---|
| | 725 | return a*b; |
|---|
| | 726 | },and:function(a,b){ |
|---|
| | 727 | return a&b; |
|---|
| | 728 | },or:function(a,b){ |
|---|
| | 729 | return a|b; |
|---|
| | 730 | },xor:function(a,b){ |
|---|
| | 731 | return a^b; |
|---|
| | 732 | },lshift:function(a,b){ |
|---|
| | 733 | return a<<b; |
|---|
| | 734 | },rshift:function(a,b){ |
|---|
| | 735 | return a>>b; |
|---|
| | 736 | },zrshift:function(a,b){ |
|---|
| | 737 | return a>>>b; |
|---|
| | 738 | },eq:function(a,b){ |
|---|
| | 739 | return a==b; |
|---|
| | 740 | },ne:function(a,b){ |
|---|
| | 741 | return a!=b; |
|---|
| | 742 | },gt:function(a,b){ |
|---|
| | 743 | return a>b; |
|---|
| | 744 | },ge:function(a,b){ |
|---|
| | 745 | return a>=b; |
|---|
| | 746 | },lt:function(a,b){ |
|---|
| | 747 | return a<b; |
|---|
| | 748 | },le:function(a,b){ |
|---|
| | 749 | return a<=b; |
|---|
| | 750 | },ceq:function(a,b){ |
|---|
| | 751 | return MochiKit.Base.compare(a,b)==0; |
|---|
| | 752 | },cne:function(a,b){ |
|---|
| | 753 | return MochiKit.Base.compare(a,b)!=0; |
|---|
| | 754 | },cgt:function(a,b){ |
|---|
| | 755 | return MochiKit.Base.compare(a,b)==1; |
|---|
| | 756 | },cge:function(a,b){ |
|---|
| | 757 | return MochiKit.Base.compare(a,b)!=-1; |
|---|
| | 758 | },clt:function(a,b){ |
|---|
| | 759 | return MochiKit.Base.compare(a,b)==-1; |
|---|
| | 760 | },cle:function(a,b){ |
|---|
| | 761 | return MochiKit.Base.compare(a,b)!=1; |
|---|
| | 762 | },logand:function(a,b){ |
|---|
| | 763 | return a&&b; |
|---|
| | 764 | },logor:function(a,b){ |
|---|
| | 765 | return a||b; |
|---|
| | 766 | },contains:function(a,b){ |
|---|
| | 767 | return b in a; |
|---|
| | 768 | }},forward:function(_30){ |
|---|
| | 769 | return function(){ |
|---|
| | 770 | return this[_30].apply(this,arguments); |
|---|
| | 771 | }; |
|---|
| | 772 | },itemgetter:function(_31){ |
|---|
| | 773 | return function(arg){ |
|---|
| | 774 | return arg[_31]; |
|---|
| | 775 | }; |
|---|
| | 776 | },typeMatcher:function(){ |
|---|
| | 777 | var _33={}; |
|---|
| | 778 | for(var i=0;i<arguments.length;i++){ |
|---|
| | 779 | var typ=arguments[i]; |
|---|
| | 780 | _33[typ]=typ; |
|---|
| | 781 | } |
|---|
| | 782 | return function(){ |
|---|
| | 783 | for(var i=0;i<arguments.length;i++){ |
|---|
| | 784 | if(!(typeof (arguments[i]) in _33)){ |
|---|
| | 785 | return false; |
|---|
| | 786 | } |
|---|
| | 787 | } |
|---|
| | 788 | return true; |
|---|
| | 789 | }; |
|---|
| | 790 | },isNull:function(){ |
|---|
| | 791 | for(var i=0;i<arguments.length;i++){ |
|---|
| | 792 | if(arguments[i]!==null){ |
|---|
| | 793 | return false; |
|---|
| | 794 | } |
|---|
| | 795 | } |
|---|
| | 796 | return true; |
|---|
| | 797 | },isUndefinedOrNull:function(){ |
|---|
| | 798 | for(var i=0;i<arguments.length;i++){ |
|---|
| | 799 | var o=arguments[i]; |
|---|
| | 800 | if(!(typeof (o)=="undefined"||o==null)){ |
|---|
| | 801 | return false; |
|---|
| | 802 | } |
|---|
| | 803 | } |
|---|
| | 804 | return true; |
|---|
| | 805 | },isNotEmpty:function(obj){ |
|---|
| | 806 | for(var i=0;i<arguments.length;i++){ |
|---|
| | 807 | var o=arguments[i]; |
|---|
| | 808 | if(!(o&&o.length)){ |
|---|
| | 809 | return false; |
|---|
| | 810 | } |
|---|
| | 811 | } |
|---|
| | 812 | return true; |
|---|
| | 813 | },isArrayLike:function(){ |
|---|
| | 814 | for(var i=0;i<arguments.length;i++){ |
|---|
| | 815 | var o=arguments[i]; |
|---|
| | 816 | var typ=typeof (o); |
|---|
| | 817 | if((typ!="object"&&!(typ=="function"&&typeof (o.item)=="function"))||o==null||typeof (o.length)!="number"){ |
|---|
| | 818 | return false; |
|---|
| | 819 | } |
|---|
| | 820 | } |
|---|
| | 821 | return true; |
|---|
| | 822 | },isDateLike:function(){ |
|---|
| | 823 | for(var i=0;i<arguments.length;i++){ |
|---|
| | 824 | var o=arguments[i]; |
|---|
| | 825 | if(typeof (o)!="object"||o==null||typeof (o.getTime)!="function"){ |
|---|
| | 826 | return false; |
|---|
| | 827 | } |
|---|
| | 828 | } |
|---|
| | 829 | return true; |
|---|
| | 830 | },xmap:function(fn){ |
|---|
| | 831 | if(fn==null){ |
|---|
| | 832 | return MochiKit.Base.extend(null,arguments,1); |
|---|
| | 833 | } |
|---|
| | 834 | var _36=[]; |
|---|
| | 835 | for(var i=1;i<arguments.length;i++){ |
|---|
| | 836 | _36.push(fn(arguments[i])); |
|---|
| | 837 | } |
|---|
| | 838 | return _36; |
|---|
| | 839 | },map:function(fn,lst){ |
|---|
| | 840 | var m=MochiKit.Base; |
|---|
| | 841 | var _38=m.isArrayLike; |
|---|
| | 842 | if(arguments.length<=2){ |
|---|
| | 843 | if(!_38(lst)){ |
|---|
| | 844 | if(MochiKit.Iter){ |
|---|
| | 845 | lst=MochiKit.Iter.list(lst); |
|---|
| | 846 | if(fn==null){ |
|---|
| | 847 | return lst; |
|---|
| | 848 | } |
|---|
| | 849 | }else{ |
|---|
| | 850 | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
|---|
| | 851 | } |
|---|
| | 852 | } |
|---|
| | 853 | if(fn==null){ |
|---|
| | 854 | return m.extend(null,lst); |
|---|
| | 855 | } |
|---|
| | 856 | var _39=[]; |
|---|
| | 857 | for(var i=0;i<lst.length;i++){ |
|---|
| | 858 | _39.push(fn(lst[i])); |
|---|
| | 859 | } |
|---|
| | 860 | return _39; |
|---|
| | 861 | }else{ |
|---|
| | 862 | if(fn==null){ |
|---|
| | 863 | fn=Array; |
|---|
| | 864 | } |
|---|
| | 865 | var _40=null; |
|---|
| | 866 | for(i=1;i<arguments.length;i++){ |
|---|
| | 867 | if(!_38(arguments[i])){ |
|---|
| | 868 | if(MochiKit.Iter){ |
|---|
| | 869 | arguments[i]=MochiKit.Iter.list(arguments[i]); |
|---|
| | 870 | }else{ |
|---|
| | 871 | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
|---|
| | 872 | } |
|---|
| | 873 | } |
|---|
| | 874 | var l=arguments[i].length; |
|---|
| | 875 | if(_40==null||_40>l){ |
|---|
| | 876 | _40=l; |
|---|
| | 877 | } |
|---|
| | 878 | } |
|---|
| | 879 | _39=[]; |
|---|
| | 880 | for(i=0;i<_40;i++){ |
|---|
| | 881 | var _41=[]; |
|---|
| | 882 | for(var j=1;j<arguments.length;j++){ |
|---|
| | 883 | _41.push(arguments[j][i]); |
|---|
| | 884 | } |
|---|
| | 885 | _39.push(fn.apply(this,_41)); |
|---|
| | 886 | } |
|---|
| | 887 | return _39; |
|---|
| | 888 | } |
|---|
| | 889 | },xfilter:function(fn){ |
|---|
| | 890 | var _43=[]; |
|---|
| | 891 | if(fn==null){ |
|---|
| | 892 | fn=MochiKit.Base.operator.truth; |
|---|
| | 893 | } |
|---|
| | 894 | for(var i=1;i<arguments.length;i++){ |
|---|
| | 895 | var o=arguments[i]; |
|---|
| | 896 | if(fn(o)){ |
|---|
| | 897 | _43.push(o); |
|---|
| | 898 | } |
|---|
| | 899 | } |
|---|
| | 900 | return _43; |
|---|
| | 901 | },filter:function(fn,lst,_44){ |
|---|
| | 902 | var _45=[]; |
|---|
| | 903 | var m=MochiKit.Base; |
|---|
| | 904 | if(!m.isArrayLike(lst)){ |
|---|
| | 905 | if(MochiKit.Iter){ |
|---|
| | 906 | lst=MochiKit.Iter.list(lst); |
|---|
| | 907 | }else{ |
|---|
| | 908 | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
|---|
| | 909 | } |
|---|
| | 910 | } |
|---|
| | 911 | if(fn==null){ |
|---|
| | 912 | fn=m.operator.truth; |
|---|
| | 913 | } |
|---|
| | 914 | if(typeof (Array.prototype.filter)=="function"){ |
|---|
| | 915 | return Array.prototype.filter.call(lst,fn,_44); |
|---|
| | 916 | }else{ |
|---|
| | 917 | if(typeof (_44)=="undefined"||_44==null){ |
|---|
| | 918 | for(var i=0;i<lst.length;i++){ |
|---|
| | 919 | var o=lst[i]; |
|---|
| | 920 | if(fn(o)){ |
|---|
| | 921 | _45.push(o); |
|---|
| | 922 | } |
|---|
| | 923 | } |
|---|
| | 924 | }else{ |
|---|
| | 925 | for(i=0;i<lst.length;i++){ |
|---|
| | 926 | o=lst[i]; |
|---|
| | 927 | if(fn.call(_44,o)){ |
|---|
| | 928 | _45.push(o); |
|---|
| | 929 | } |
|---|
| | 930 | } |
|---|
| | 931 | } |
|---|
| | 932 | } |
|---|
| | 933 | return _45; |
|---|
| | 934 | },_wrapDumbFunction:function(_46){ |
|---|
| | 935 | return function(){ |
|---|
| | 936 | switch(arguments.length){ |
|---|
| | 937 | case 0: |
|---|
| | 938 | return _46(); |
|---|
| | 939 | case 1: |
|---|
| | 940 | return _46(arguments[0]); |
|---|
| | 941 | case 2: |
|---|
| | 942 | return _46(arguments[0],arguments[1]); |
|---|
| | 943 | case 3: |
|---|
| | 944 | return _46(arguments[0],arguments[1],arguments[2]); |
|---|
| | 945 | } |
|---|
| | 946 | var _47=[]; |
|---|
| | 947 | for(var i=0;i<arguments.length;i++){ |
|---|
| | 948 | _47.push("arguments["+i+"]"); |
|---|
| | 949 | } |
|---|
| | 950 | return eval("(func("+_47.join(",")+"))"); |
|---|
| | 951 | }; |
|---|
| | 952 | },bind:function(_48,_49){ |
|---|
| | 953 | if(typeof (_48)=="string"){ |
|---|
| | 954 | _48=_49[_48]; |
|---|
| | 955 | } |
|---|
| | 956 | var _50=_48.im_func; |
|---|
| | 957 | var _51=_48.im_preargs; |
|---|
| | 958 | var _52=_48.im_self; |
|---|
| | 959 | var m=MochiKit.Base; |
|---|
| | 960 | if(typeof (_48)=="function"&&typeof (_48.apply)=="undefined"){ |
|---|
| | 961 | _48=m._wrapDumbFunction(_48); |
|---|
| | 962 | } |
|---|
| | 963 | if(typeof (_50)!="function"){ |
|---|
| | 964 | _50=_48; |
|---|
| | 965 | } |
|---|
| | 966 | if(typeof (_49)!="undefined"){ |
|---|
| | 967 | _52=_49; |
|---|
| | 968 | } |
|---|
| | 969 | if(typeof (_51)=="undefined"){ |
|---|
| | 970 | _51=[]; |
|---|
| | 971 | }else{ |
|---|
| | 972 | _51=_51.slice(); |
|---|
| | 973 | } |
|---|
| | 974 | m.extend(_51,arguments,2); |
|---|
| | 975 | var _53=function(){ |
|---|
| | 976 | var _54=arguments; |
|---|
| | 977 | var me=arguments.callee; |
|---|
| | 978 | if(me.im_preargs.length>0){ |
|---|
| | 979 | _54=m.concat(me.im_preargs,_54); |
|---|
| | 980 | } |
|---|
| | 981 | var _49=me.im_self; |
|---|
| | 982 | if(!_49){ |
|---|
| | 983 | _49=this; |
|---|
| | 984 | } |
|---|
| | 985 | return me.im_func.apply(_49,_54); |
|---|
| | 986 | }; |
|---|
| | 987 | _53.im_self=_52; |
|---|
| | 988 | _53.im_func=_50; |
|---|
| | 989 | _53.im_preargs=_51; |
|---|
| | 990 | return _53; |
|---|
| | 991 | },bindMethods:function(_55){ |
|---|
| | 992 | var _56=MochiKit.Base.bind; |
|---|
| | 993 | for(var k in _55){ |
|---|
| | 994 | var _57=_55[k]; |
|---|
| | 995 | if(typeof (_57)=="function"){ |
|---|
| | 996 | _55[k]=_56(_57,_55); |
|---|
| | 997 | } |
|---|
| | 998 | } |
|---|
| | 999 | },registerComparator:function(_58,_59,_60,_61){ |
|---|
| | 1000 | MochiKit.Base.comparatorRegistry.register(_58,_59,_60,_61); |
|---|
| | 1001 | },_primitives:{"bool":true,"string":true,"number":true},compare:function(a,b){ |
|---|
| | 1002 | if(a==b){ |
|---|
| | 1003 | return 0; |
|---|
| | 1004 | } |
|---|
| | 1005 | var _62=(typeof (a)=="undefined"||a==null); |
|---|
| | 1006 | var _63=(typeof (b)=="undefined"||b==null); |
|---|
| | 1007 | if(_62&&_63){ |
|---|
| | 1008 | return 0; |
|---|
| | 1009 | }else{ |
|---|
| | 1010 | if(_62){ |
|---|
| | 1011 | return -1; |
|---|
| | 1012 | }else{ |
|---|
| | 1013 | if(_63){ |
|---|
| | 1014 | return 1; |
|---|
| | 1015 | } |
|---|
| | 1016 | } |
|---|
| | 1017 | } |
|---|
| | 1018 | var m=MochiKit.Base; |
|---|
| | 1019 | var _64=m._primitives; |
|---|
| | 1020 | if(!(typeof (a) in _64&&typeof (b) in _64)){ |
|---|
| | 1021 | try{ |
|---|
| | 1022 | return m.comparatorRegistry.match(a,b); |
|---|
| | 1023 | } |
|---|
| | 1024 | catch(e){ |
|---|
| | 1025 | if(e!=m.NotFound){ |
|---|
| | 1026 | throw e; |
|---|
| | 1027 | } |
|---|
| | 1028 | } |
|---|
| | 1029 | } |
|---|
| | 1030 | if(a<b){ |
|---|
| | 1031 | return -1; |
|---|
| | 1032 | }else{ |
|---|
| | 1033 | if(a>b){ |
|---|
| | 1034 | return 1; |
|---|
| | 1035 | } |
|---|
| | 1036 | } |
|---|
| | 1037 | var _65=m.repr; |
|---|
| | 1038 | throw new TypeError(_65(a)+" and "+_65(b)+" can not be compared"); |
|---|
| | 1039 | },compareDateLike:function(a,b){ |
|---|
| | 1040 | return MochiKit.Base.compare(a.getTime(),b.getTime()); |
|---|
| | 1041 | },compareArrayLike:function(a,b){ |
|---|
| | 1042 | var _66=MochiKit.Base.compare; |
|---|
| | 1043 | var _67=a.length; |
|---|
| | 1044 | var _68=0; |
|---|
| | 1045 | if(_67>b.length){ |
|---|
| | 1046 | _68=1; |
|---|
| | 1047 | _67=b.length; |
|---|
| | 1048 | }else{ |
|---|
| | 1049 | if(_67<b.length){ |
|---|
| | 1050 | _68=-1; |
|---|
| | 1051 | } |
|---|
| | 1052 | } |
|---|
| | 1053 | for(var i=0;i<_67;i++){ |
|---|
| | 1054 | var cmp=_66(a[i],b[i]); |
|---|
| | 1055 | if(cmp){ |
|---|
| | 1056 | return cmp; |
|---|
| | 1057 | } |
|---|
| | 1058 | } |
|---|
| | 1059 | return _68; |
|---|
| | 1060 | },registerRepr:function(_70,_71,_72,_73){ |
|---|
| | 1061 | MochiKit.Base.reprRegistry.register(_70,_71,_72,_73); |
|---|
| | 1062 | },repr:function(o){ |
|---|
| | 1063 | if(typeof (o)=="undefined"){ |
|---|
| | 1064 | return "undefined"; |
|---|
| | 1065 | }else{ |
|---|
| | 1066 | if(o===null){ |
|---|
| | 1067 | return "null"; |
|---|
| | 1068 | } |
|---|
| | 1069 | } |
|---|
| | 1070 | try{ |
|---|
| | 1071 | if(typeof (o.__repr__)=="function"){ |
|---|
| | 1072 | return o.__repr__(); |
|---|
| | 1073 | }else{ |
|---|
| | 1074 | if(typeof (o.repr)=="function"&&o.repr!=arguments.callee){ |
|---|
| | 1075 | return o.repr(); |
|---|
| | 1076 | } |
|---|
| | 1077 | } |
|---|
| | 1078 | return MochiKit.Base.reprRegistry.match(o); |
|---|
| | 1079 | } |
|---|
| | 1080 | catch(e){ |
|---|
| | 1081 | if(typeof (o.NAME)=="string"&&(o.toString==Function.prototype.toString||o.toString==Object.prototype.toString)){ |
|---|
| | 1082 | return o.NAME; |
|---|
| | 1083 | } |
|---|
| | 1084 | } |
|---|
| | 1085 | try{ |
|---|
| | 1086 | var _74=(o+""); |
|---|
| | 1087 | } |
|---|
| | 1088 | catch(e){ |
|---|
| | 1089 | return "["+typeof (o)+"]"; |
|---|
| | 1090 | } |
|---|
| | 1091 | if(typeof (o)=="function"){ |
|---|
| | 1092 | o=_74.replace(/^\s+/,""); |
|---|
| | 1093 | var idx=o.indexOf("{"); |
|---|
| | 1094 | if(idx!=-1){ |
|---|
| | 1095 | o=o.substr(0,idx)+"{...}"; |
|---|
| | 1096 | } |
|---|
| | 1097 | } |
|---|
| | 1098 | return _74; |
|---|
| | 1099 | },reprArrayLike:function(o){ |
|---|
| | 1100 | var m=MochiKit.Base; |
|---|
| | 1101 | return "["+m.map(m.repr,o).join(", ")+"]"; |
|---|
| | 1102 | },reprString:function(o){ |
|---|
| | 1103 | 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"); |
|---|
| | 1104 | },reprNumber:function(o){ |
|---|
| | 1105 | return o+""; |
|---|
| | 1106 | },registerJSON:function(_76,_77,_78,_79){ |
|---|
| | 1107 | MochiKit.Base.jsonRegistry.register(_76,_77,_78,_79); |
|---|
| | 1108 | },evalJSON:function(){ |
|---|
| | 1109 | return eval("("+arguments[0]+")"); |
|---|
| | 1110 | },serializeJSON:function(o){ |
|---|
| | 1111 | var _80=typeof (o); |
|---|
| | 1112 | if(_80=="undefined"){ |
|---|
| | 1113 | return "undefined"; |
|---|
| | 1114 | }else{ |
|---|
| | 1115 | if(_80=="number"||_80=="boolean"){ |
|---|
| | 1116 | return o+""; |
|---|
| | 1117 | }else{ |
|---|
| | 1118 | if(o===null){ |
|---|
| | 1119 | return "null"; |
|---|
| | 1120 | } |
|---|
| | 1121 | } |
|---|
| | 1122 | } |
|---|
| | 1123 | var m=MochiKit.Base; |
|---|
| | 1124 | var _81=m.reprString; |
|---|
| | 1125 | if(_80=="string"){ |
|---|
| | 1126 | return _81(o); |
|---|
| | 1127 | } |
|---|
| | 1128 | var me=arguments.callee; |
|---|
| | 1129 | var _82; |
|---|
| | 1130 | if(typeof (o.__json__)=="function"){ |
|---|
| | 1131 | _82=o.__json__(); |
|---|
| | 1132 | if(o!==_82){ |
|---|
| | 1133 | return me(_82); |
|---|
| | 1134 | } |
|---|
| | 1135 | } |
|---|
| | 1136 | if(typeof (o.json)=="function"){ |
|---|
| | 1137 | _82=o.json(); |
|---|
| | 1138 | if(o!==_82){ |
|---|
| | 1139 | return me(_82); |
|---|
| | 1140 | } |
|---|
| | 1141 | } |
|---|
| | 1142 | if(_80!="function"&&typeof (o.length)=="number"){ |
|---|
| | 1143 | var res=[]; |
|---|
| | 1144 | for(var i=0;i<o.length;i++){ |
|---|
| | 1145 | var val=me(o[i]); |
|---|
| | 1146 | if(typeof (val)!="string"){ |
|---|
| | 1147 | val="undefined"; |
|---|
| | 1148 | } |
|---|
| | 1149 | res.push(val); |
|---|
| | 1150 | } |
|---|
| | 1151 | return "["+res.join(", ")+"]"; |
|---|
| | 1152 | } |
|---|
| | 1153 | try{ |
|---|
| | 1154 | _82=m.jsonRegistry.match(o); |
|---|
| | 1155 | return me(_82); |
|---|
| | 1156 | } |
|---|
| | 1157 | catch(e){ |
|---|
| | 1158 | if(e!=m.NotFound){ |
|---|
| | 1159 | throw e; |
|---|
| | 1160 | } |
|---|
| | 1161 | } |
|---|
| | 1162 | if(_80=="function"){ |
|---|
| | 1163 | return null; |
|---|
| | 1164 | } |
|---|
| | 1165 | res=[]; |
|---|
| | 1166 | for(var k in o){ |
|---|
| | 1167 | var _84; |
|---|
| | 1168 | if(typeof (k)=="number"){ |
|---|
| | 1169 | _84="\""+k+"\""; |
|---|
| | 1170 | }else{ |
|---|
| | 1171 | if(typeof (k)=="string"){ |
|---|
| | 1172 | _84=_81(k); |
|---|
| | 1173 | }else{ |
|---|
| | 1174 | continue; |
|---|
| | 1175 | } |
|---|
| | 1176 | } |
|---|
| | 1177 | val=me(o[k]); |
|---|
| | 1178 | if(typeof (val)!="string"){ |
|---|
| | 1179 | continue; |
|---|
| | 1180 | } |
|---|
| | 1181 | res.push(_84+":"+val); |
|---|
| | 1182 | } |
|---|
| | 1183 | return "{"+res.join(", ")+"}"; |
|---|
| | 1184 | },objEqual:function(a,b){ |
|---|
| | 1185 | return (MochiKit.Base.compare(a,b)==0); |
|---|
| | 1186 | },arrayEqual:function(_85,arr){ |
|---|
| | 1187 | if(_85.length!=arr.length){ |
|---|
| | 1188 | return false; |
|---|
| | 1189 | } |
|---|
| | 1190 | return (MochiKit.Base.compare(_85,arr)==0); |
|---|
| | 1191 | },concat:function(){ |
|---|
| | 1192 | var _87=[]; |
|---|
| | 1193 | var _88=MochiKit.Base.extend; |
|---|
| | 1194 | for(var i=0;i<arguments.length;i++){ |
|---|
| | 1195 | _88(_87,arguments[i]); |
|---|
| | 1196 | } |
|---|
| | 1197 | return _87; |
|---|
| | 1198 | },keyComparator:function(key){ |
|---|
| | 1199 | var m=MochiKit.Base; |
|---|
| | 1200 | var _90=m.compare; |
|---|
| | 1201 | if(arguments.length==1){ |
|---|
| | 1202 | return function(a,b){ |
|---|
| | 1203 | return _90(a[key],b[key]); |
|---|
| | 1204 | }; |
|---|
| | 1205 | } |
|---|
| | 1206 | var _91=m.extend(null,arguments); |
|---|
| | 1207 | return function(a,b){ |
|---|
| | 1208 | var _92=0; |
|---|
| | 1209 | for(var i=0;(_92==0)&&(i<_91.length);i++){ |
|---|
| | 1210 | var key=_91[i]; |
|---|
| | 1211 | _92=_90(a[key],b[key]); |
|---|
| | 1212 | } |
|---|
| | 1213 | return _92; |
|---|
| | 1214 | }; |
|---|
| | 1215 | },reverseKeyComparator:function(key){ |
|---|
| | 1216 | var _93=MochiKit.Base.keyComparator.apply(this,arguments); |
|---|
| | 1217 | return function(a,b){ |
|---|
| | 1218 | return _93(b,a); |
|---|
| | 1219 | }; |
|---|
| | 1220 | },partial:function(_94){ |
|---|
| | 1221 | var m=MochiKit.Base; |
|---|
| | 1222 | return m.bind.apply(this,m.extend([_94,undefined],arguments,1)); |
|---|
| | 1223 | },listMinMax:function(_95,lst){ |
|---|
| | 1224 | if(lst.length==0){ |
|---|
| | 1225 | return null; |
|---|
| | 1226 | } |
|---|
| | 1227 | var cur=lst[0]; |
|---|
| | 1228 | var _97=MochiKit.Base.compare; |
|---|
| | 1229 | for(var i=1;i<lst.length;i++){ |
|---|
| | 1230 | var o=lst[i]; |
|---|
| | 1231 | if(_97(o,cur)==_95){ |
|---|
| | 1232 | cur=o; |
|---|
| | 1233 | } |
|---|
| | 1234 | } |
|---|
| | 1235 | return cur; |
|---|
| | 1236 | },objMax:function(){ |
|---|
| | 1237 | return MochiKit.Base.listMinMax(1,arguments); |
|---|
| | 1238 | },objMin:function(){ |
|---|
| | 1239 | return MochiKit.Base.listMinMax(-1,arguments); |
|---|
| | 1240 | },findIdentical:function(lst,_98,_99,end){ |
|---|
| | 1241 | if(typeof (end)=="undefined"||end==null){ |
|---|
| | 1242 | end=lst.length; |
|---|
| | 1243 | } |
|---|
| | 1244 | for(var i=(_99||0);i<end;i++){ |
|---|
| | 1245 | if(lst[i]===_98){ |
|---|
| | 1246 | return i; |
|---|
| | 1247 | } |
|---|
| | 1248 | } |
|---|
| | 1249 | return -1; |
|---|
| | 1250 | },find:function(lst,_101,_102,end){ |
|---|
| | 1251 | if(typeof (end)=="undefined"||end==null){ |
|---|
| | 1252 | end=lst.length; |
|---|
| | 1253 | } |
|---|
| | 1254 | var cmp=MochiKit.Base.compare; |
|---|
| | 1255 | for(var i=(_102||0);i<end;i++){ |
|---|
| | 1256 | if(cmp(lst[i],_101)==0){ |
|---|
| | 1257 | return i; |
|---|
| | 1258 | } |
|---|
| | 1259 | } |
|---|
| | 1260 | return -1; |
|---|
| | 1261 | },nodeWalk:function(node,_104){ |
|---|
| | 1262 | var _105=[node]; |
|---|
| | 1263 | var _106=MochiKit.Base.extend; |
|---|
| | 1264 | while(_105.length){ |
|---|
| | 1265 | var res=_104(_105.shift()); |
|---|
| | 1266 | if(res){ |
|---|
| | 1267 | _106(_105,res); |
|---|
| | 1268 | } |
|---|
| | 1269 | } |
|---|
| | 1270 | },nameFunctions:function(_107){ |
|---|
| | 1271 | var base=_107.NAME; |
|---|
| | 1272 | if(typeof (base)=="undefined"){ |
|---|
| | 1273 | base=""; |
|---|
| | 1274 | }else{ |
|---|
| | 1275 | base=base+"."; |
|---|
| | 1276 | } |
|---|
| | 1277 | for(var name in _107){ |
|---|
| | 1278 | var o=_107[name]; |
|---|
| | 1279 | if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){ |
|---|
| | 1280 | try{ |
|---|
| | 1281 | o.NAME=base+name; |
|---|
| | 1282 | } |
|---|
| | 1283 | catch(e){ |
|---|
| | 1284 | } |
|---|
| | 1285 | } |
|---|
| | 1286 | } |
|---|
| | 1287 | },queryString:function(_110,_111){ |
|---|
| | 1288 | if(typeof (MochiKit.DOM)!="undefined"&&arguments.length==1&&(typeof (_110)=="string"||(typeof (_110.nodeType)!="undefined"&&_110.nodeType>0))){ |
|---|
| | 1289 | var kv=MochiKit.DOM.formContents(_110); |
|---|
| | 1290 | _110=kv[0]; |
|---|
| | 1291 | _111=kv[1]; |
|---|
| | 1292 | }else{ |
|---|
| | 1293 | if(arguments.length==1){ |
|---|
| | 1294 | var o=_110; |
|---|
| | 1295 | _110=[]; |
|---|
| | 1296 | _111=[]; |
|---|
| | 1297 | for(var k in o){ |
|---|
| | 1298 | var v=o[k]; |
|---|
| | 1299 | if(typeof (v)!="function"){ |
|---|
| | 1300 | _110.push(k); |
|---|
| | 1301 | _111.push(v); |
|---|
| | 1302 | } |
|---|
| | 1303 | } |
|---|
| | 1304 | } |
|---|
| | 1305 | } |
|---|
| | 1306 | var rval=[]; |
|---|
| | 1307 | var len=Math.min(_110.length,_111.length); |
|---|
| | 1308 | var _115=MochiKit.Base.urlEncode; |
|---|
| | 1309 | for(var i=0;i<len;i++){ |
|---|
| | 1310 | v=_111[i]; |
|---|
| | 1311 | if(typeof (v)!="undefined"&&v!=null){ |
|---|
| | 1312 | rval.push(_115(_110[i])+"="+_115(v)); |
|---|
| | 1313 | } |
|---|
| | 1314 | } |
|---|
| | 1315 | return rval.join("&"); |
|---|
| | 1316 | },parseQueryString:function(_116,_117){ |
|---|
| | 1317 | var _118=_116.replace(/\+/g,"%20").split("&"); |
|---|
| | 1318 | var o={}; |
|---|
| | 1319 | var _119; |
|---|
| | 1320 | if(typeof (decodeURIComponent)!="undefined"){ |
|---|
| | 1321 | _119=decodeURIComponent; |
|---|
| | 1322 | }else{ |
|---|
| | 1323 | _119=unescape; |
|---|
| | 1324 | } |
|---|
| | 1325 | if(_117){ |
|---|
| | 1326 | for(var i=0;i<_118.length;i++){ |
|---|
| | 1327 | var pair=_118[i].split("="); |
|---|
| | 1328 | var name=_119(pair[0]); |
|---|
| | 1329 | var arr=o[name]; |
|---|
| | 1330 | if(!(arr instanceof Array)){ |
|---|
| | 1331 | arr=[]; |
|---|
| | 1332 | o[name]=arr; |
|---|
| | 1333 | } |
|---|
| | 1334 | arr.push(_119(pair[1])); |
|---|
| | 1335 | } |
|---|
| | 1336 | }else{ |
|---|
| | 1337 | for(i=0;i<_118.length;i++){ |
|---|
| | 1338 | pair=_118[i].split("="); |
|---|
| | 1339 | o[_119(pair[0])]=_119(pair[1]); |
|---|
| | 1340 | } |
|---|
| | 1341 | } |
|---|
| | 1342 | return o; |
|---|
| | 1343 | }}); |
|---|
| | 1344 | MochiKit.Base.AdapterRegistry=function(){ |
|---|
| | 1345 | this.pairs=[]; |
|---|
| | 1346 | }; |
|---|
| | 1347 | MochiKit.Base.AdapterRegistry.prototype={register:function(name,_121,wrap,_123){ |
|---|
| | 1348 | if(_123){ |
|---|
| | 1349 | this.pairs.unshift([name,_121,wrap]); |
|---|
| | 1350 | }else{ |
|---|
| | 1351 | this.pairs.push([name,_121,wrap]); |
|---|
| | 1352 | } |
|---|
| | 1353 | },match:function(){ |
|---|
| | 1354 | for(var i=0;i<this.pairs.length;i++){ |
|---|
| | 1355 | var pair=this.pairs[i]; |
|---|
| | 1356 | if(pair[1].apply(this,arguments)){ |
|---|
| | 1357 | return pair[2].apply(this,arguments); |
|---|
| | 1358 | } |
|---|
| | 1359 | } |
|---|
| | 1360 | throw MochiKit.Base.NotFound; |
|---|
| | 1361 | },unregister:function(name){ |
|---|
| | 1362 | for(var i=0;i<this.pairs.length;i++){ |
|---|
| | 1363 | var pair=this.pairs[i]; |
|---|
| | 1364 | if(pair[0]==name){ |
|---|
| | 1365 | this.pairs.splice(i,1); |
|---|
| | 1366 | return true; |
|---|
| | 1367 | } |
|---|
| | 1368 | } |
|---|
| | 1369 | return false; |
|---|
| | 1370 | }}; |
|---|
| | 1371 | MochiKit.Base.EXPORT=["counter","clone","extend","update","updatetree","setdefault","keys","items","NamedError","operator","forward","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","find","findIdentical","flattenArguments"]; |
|---|
| | 1372 | MochiKit.Base.EXPORT_OK=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"]; |
|---|
| | 1373 | MochiKit.Base._exportSymbols=function(_124,_125){ |
|---|
| | 1374 | if(typeof (MochiKit.__export__)=="undefined"){ |
|---|
| | 1375 | MochiKit.__export__=(MochiKit.__compat__||(typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")); |
|---|
| | 1376 | } |
|---|
| | 1377 | if(!MochiKit.__export__){ |
|---|
| | 1378 | return; |
|---|
| | 1379 | } |
|---|
| | 1380 | var all=_125.EXPORT_TAGS[":all"]; |
|---|
| | 1381 | for(var i=0;i<all.length;i++){ |
|---|
| | 1382 | _124[all[i]]=_125[all[i]]; |
|---|
| | 1383 | } |
|---|
| | 1384 | }; |
|---|
| | 1385 | MochiKit.Base.__new__=function(){ |
|---|
| | 1386 | var m=this; |
|---|
| | 1387 | if(typeof (encodeURIComponent)!="undefined"){ |
|---|
| | 1388 | m.urlEncode=function(_127){ |
|---|
| | 1389 | return encodeURIComponent(_127).replace(/\'/g,"%27"); |
|---|
| | 1390 | }; |
|---|
| | 1391 | }else{ |
|---|
| | 1392 | m.urlEncode=function(_128){ |
|---|
| | 1393 | return escape(_128).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval.replace(/\'/g,"%27"); |
|---|
| | 1394 | }; |
|---|
| | 1395 | } |
|---|
| | 1396 | m.NamedError=function(name){ |
|---|
| | 1397 | this.message=name; |
|---|
| | 1398 | this.name=name; |
|---|
| | 1399 | }; |
|---|
| | 1400 | m.NamedError.prototype=new Error(); |
|---|
| | 1401 | m.update(m.NamedError.prototype,{repr:function(){ |
|---|
| | 1402 | if(this.message&&this.message!=this.name){ |
|---|
| | 1403 | return this.name+"("+m.repr(this.message)+")"; |
|---|
| | 1404 | }else{ |
|---|
| | 1405 | return this.name+"()"; |
|---|
| | 1406 | } |
|---|
| | 1407 | },toString:m.forward("repr")}); |
|---|
| | 1408 | m.NotFound=new m.NamedError("MochiKit.Base.NotFound"); |
|---|
| | 1409 | m.listMax=m.partial(m.listMinMax,1); |
|---|
| | 1410 | m.listMin=m.partial(m.listMinMax,-1); |
|---|
| | 1411 | m.isCallable=m.typeMatcher("function"); |
|---|
| | 1412 | m.isUndefined=m.typeMatcher("undefined"); |
|---|
| | 1413 | m.merge=m.partial(m.update,null); |
|---|
| | 1414 | m.zip=m.partial(m.map,null); |
|---|
| | 1415 | m.comparatorRegistry=new m.AdapterRegistry(); |
|---|
| | 1416 | m.registerComparator("dateLike",m.isDateLike,m.compareDateLike); |
|---|
| | 1417 | m.registerComparator("arrayLike",m.isArrayLike,m.compareArrayLike); |
|---|
| | 1418 | m.reprRegistry=new m.AdapterRegistry(); |
|---|
| | 1419 | m.registerRepr("arrayLike",m.isArrayLike,m.reprArrayLike); |
|---|
| | 1420 | m.registerRepr("string",m.typeMatcher("string"),m.reprString); |
|---|
| | 1421 | m.registerRepr("numbers",m.typeMatcher("number","boolean"),m.reprNumber); |
|---|
| | 1422 | m.jsonRegistry=new m.AdapterRegistry(); |
|---|
| | 1423 | var all=m.concat(m.EXPORT,m.EXPORT_OK); |
|---|
| | 1424 | m.EXPORT_TAGS={":common":m.concat(m.EXPORT_OK),":all":all}; |
|---|
| | 1425 | m.nameFunctions(this); |
|---|
| | 1426 | }; |
|---|
| | 1427 | MochiKit.Base.__new__(); |
|---|
| | 1428 | compare=MochiKit.Base.compare; |
|---|
| | 1429 | MochiKit.Base._exportSymbols(this,MochiKit.Base); |
|---|
| | 1430 | if(typeof (dojo)!="undefined"){ |
|---|
| | 1431 | dojo.provide("MochiKit.Iter"); |
|---|
| | 1432 | dojo.require("MochiKit.Base"); |
|---|
| | 1433 | } |
|---|
| | 1434 | if(typeof (JSAN)!="undefined"){ |
|---|
| | 1435 | JSAN.use("MochiKit.Base",[]); |
|---|
| | 1436 | } |
|---|
| | 1437 | try{ |
|---|
| | 1438 | if(typeof (MochiKit.Base)=="undefined"){ |
|---|
| | 1439 | throw ""; |
|---|
| | 1440 | } |
|---|
| | 1441 | } |
|---|
| | 1442 | catch(e){ |
|---|
| | 1443 | throw "MochiKit.Iter depends on MochiKit.Base!"; |
|---|
| | 1444 | } |
|---|
| | 1445 | if(typeof (MochiKit.Iter)=="undefined"){ |
|---|
| | 1446 | MochiKit.Iter={}; |
|---|
| | 1447 | } |
|---|
| | 1448 | MochiKit.Iter.NAME="MochiKit.Iter"; |
|---|
| | 1449 | MochiKit.Iter.VERSION="1.3"; |
|---|
| | 1450 | MochiKit.Base.update(MochiKit.Iter,{__repr__:function(){ |
|---|
| | 1451 | return "["+this.NAME+" "+this.VERSION+"]"; |
|---|
| | 1452 | },toString:function(){ |
|---|
| | 1453 | return this.__repr__(); |
|---|
| | 1454 | },registerIteratorFactory:function(name,_129,_130,_131){ |
|---|
| | 1455 | MochiKit.Iter.iteratorRegistry.register(name,_129,_130,_131); |
|---|
| | 1456 | },iter:function(_132,_133){ |
|---|
| | 1457 | var self=MochiKit.Iter; |
|---|
| | 1458 | if(arguments.length==2){ |
|---|
| | 1459 | return self.takewhile(function(a){ |
|---|
| | 1460 | return a!=_133; |
|---|
| | 1461 | },_132); |
|---|
| | 1462 | } |
|---|
| | 1463 | if(typeof (_132.next)=="function"){ |
|---|
| | 1464 | return _132; |
|---|
| | 1465 | }else{ |
|---|
| | 1466 | if(typeof (_132.iter)=="function"){ |
|---|
| | 1467 | return _132.iter(); |
|---|
| | 1468 | } |
|---|
| | 1469 | } |
|---|
| | 1470 | try{ |
|---|
| | 1471 | return self.iteratorRegistry.match(_132); |
|---|
| | 1472 | } |
|---|
| | 1473 | catch(e){ |
|---|
| | 1474 | var m=MochiKit.Base; |
|---|
| | 1475 | if(e==m.NotFound){ |
|---|
| | 1476 | e=new TypeError(typeof (_132)+": "+m.repr(_132)+" is not iterable"); |
|---|
| | 1477 | } |
|---|
| | 1478 | throw e; |
|---|
| | 1479 | } |
|---|
| | 1480 | },count:function(n){ |
|---|
| | 1481 | if(!n){ |
|---|
| | 1482 | n=0; |
|---|
| | 1483 | } |
|---|
| | 1484 | var m=MochiKit.Base; |
|---|
| | 1485 | return {repr:function(){ |
|---|
| | 1486 | return "count("+n+")"; |
|---|
| | 1487 | },toString:m.forward("repr"),next:m.counter(n)}; |
|---|
| | 1488 | },cycle:function(p){ |
|---|
| | 1489 | var self=MochiKit.Iter; |
|---|
| | 1490 | var m=MochiKit.Base; |
|---|
| | 1491 | var lst=[]; |
|---|
| | 1492 | var _136=self.iter(p); |
|---|
| | 1493 | return {repr:function(){ |
|---|
| | 1494 | return "cycle(...)"; |
|---|
| | 1495 | },toString:m.forward("repr"),next:function(){ |
|---|
| | 1496 | try{ |
|---|
| | 1497 | var rval=_136.next(); |
|---|
| | 1498 | lst.push(rval); |
|---|
| | 1499 | return rval; |
|---|
| | 1500 | } |
|---|
| | 1501 | catch(e){ |
|---|
| | 1502 | if(e!=self.StopIteration){ |
|---|
| | 1503 | throw e; |
|---|
| | 1504 | } |
|---|
| | 1505 | if(lst.length==0){ |
|---|
| | 1506 | this.next=function(){ |
|---|
| | 1507 | throw self.StopIteration; |
|---|
| | 1508 | }; |
|---|
| | 1509 | }else{ |
|---|
| | 1510 | var i=-1; |
|---|
| | 1511 | this.next=function(){ |
|---|
| | 1512 | i=(i+1)%lst.length; |
|---|
| | 1513 | return lst[i]; |
|---|
| | 1514 | }; |
|---|
| | 1515 | } |
|---|
| | 1516 | return this.next(); |
|---|
| | 1517 | } |
|---|
| | 1518 | }}; |
|---|
| | 1519 | },repeat:function(elem,n){ |
|---|
| | 1520 | var m=MochiKit.Base; |
|---|
| | 1521 | if(typeof (n)=="undefined"){ |
|---|
| | 1522 | return {repr:function(){ |
|---|
| | 1523 | return "repeat("+m.repr(elem)+")"; |
|---|
| | 1524 | },toString:m.forward("repr"),next:function(){ |
|---|
| | 1525 | return elem; |
|---|
| | 1526 | }}; |
|---|
| | 1527 | } |
|---|
| | 1528 | return {repr:function(){ |
|---|
| | 1529 | return "repeat("+m.repr(elem)+", "+n+")"; |
|---|
| | 1530 | },toString:m.forward("repr"),next:function(){ |
|---|
| | 1531 | if(n<=0){ |
|---|
| | 1532 | throw MochiKit.Iter.StopIteration; |
|---|
| | 1533 | } |
|---|
| | 1534 | n-=1; |
|---|
| | 1535 | return elem; |
|---|
| | 1536 | }}; |
|---|
| | 1537 | },next:function(_138){ |
|---|
| | 1538 | return _138.next(); |
|---|
| | 1539 | },izip:function(p,q){ |
|---|
| | 1540 | var m=MochiKit.Base; |
|---|
| | 1541 | var next=MochiKit.Iter.next; |
|---|
| | 1542 | var _141=m.map(iter,arguments); |
|---|
| | 1543 | return {repr:function(){ |
|---|
| | 1544 | return "izip(...)"; |
|---|
| | 1545 | },toString:m.forward("repr"),next:function(){ |
|---|
| | 1546 | return m.map(next,_141); |
|---|
| | 1547 | }}; |
|---|
| | 1548 | },ifilter:function(pred,seq){ |
|---|
| | 1549 | var m=MochiKit.Base; |
|---|
| | 1550 | seq=MochiKit.Iter.iter(seq); |
|---|
| | 1551 | if(pred==null){ |
|---|
| | 1552 | pred=m.operator.truth; |
|---|
| | 1553 | } |
|---|
| | 1554 | return {repr:function(){ |
|---|
| | 1555 | return "ifilter(...)"; |
|---|
| | 1556 | },toString:m.forward("repr"),next:function(){ |
|---|
| | 1557 | while(true){ |
|---|
| | 1558 | var rval=seq.next(); |
|---|
| | 1559 | if(pred(rval)){ |
|---|
| | 1560 | return rval; |
|---|
| | 1561 | } |
|---|
| | 1562 | } |
|---|
| | 1563 | return undefined; |
|---|
| | 1564 | }}; |
|---|
| | 1565 | },ifilterfalse:function(pred,seq){ |
|---|
| | 1566 | var m=MochiKit.Base; |
|---|
| | 1567 | seq=MochiKit.Iter.iter(seq); |
|---|
| | 1568 | if(pred==null){ |
|---|
| | 1569 | pred=m.operator.truth; |
|---|
| | 1570 | } |
|---|
| | 1571 | return {repr:function(){ |
|---|
| | 1572 | return "ifilterfalse(...)"; |
|---|
| | 1573 | },toString:m.forward("repr"),next:function(){ |
|---|
| | 1574 | while(true){ |
|---|
| | 1575 | var rval=seq.next(); |
|---|
| | 1576 | if(!pred(rval)){ |
|---|
| | 1577 | return rval; |
|---|
| | 1578 | } |
|---|
| | 1579 | } |
|---|
| | 1580 | return undefined; |
|---|
| | 1581 | }}; |
|---|
| | 1582 | },islice:function(seq){ |
|---|
| | 1583 | var self=MochiKit.Iter; |
|---|
| | 1584 | var m=MochiKit.Base; |
|---|
| | 1585 | seq=self.iter(seq); |
|---|
| | 1586 | var _144=0; |
|---|
| | 1587 | var stop=0; |
|---|
| | 1588 | var step=1; |
|---|
| | 1589 | var i=-1; |
|---|
| | 1590 | if(arguments.length==2){ |
|---|
| | 1591 | stop=arguments[1]; |
|---|
| | 1592 | }else{ |
|---|
| | 1593 | if(arguments.length==3){ |
|---|
| | 1594 | _144=arguments[1]; |
|---|
| | 1595 | stop=arguments[2]; |
|---|
| | 1596 | }else{ |
|---|
| | 1597 | _144=arguments[1]; |
|---|
| | 1598 | stop=arguments[2]; |
|---|
| | 1599 | step=arguments[3]; |
|---|
| | 1600 | } |
|---|
| | 1601 | } |
|---|
| | 1602 | return {repr:function(){ |
|---|
| | 1603 | return "islice("+["...",_144,stop,step].join(", ")+")"; |
|---|
| | 1604 | },toString:m.forward("repr"),next:function(){ |
|---|
| | 1605 | var rval; |
|---|
| | 1606 | while(i<_144){ |
|---|
| | 1607 | rval=seq.next(); |
|---|
| | 1608 | i++; |
|---|
| | 1609 | } |
|---|
| | 1610 | if(_144>=stop){ |
|---|
| | 1611 | throw self.StopIteration; |
|---|
| | 1612 | } |
|---|
| | 1613 | _144+=step; |
|---|
| | 1614 | return rval; |
|---|
| | 1615 | }}; |
|---|
| | 1616 | },imap:function(fun,p,q){ |
|---|
| | 1617 | var m=MochiKit.Base; |
|---|
| | 1618 | var self=MochiKit.Iter; |
|---|
| | 1619 | var _148=m.map(self.iter,m.extend(null,arguments,1)); |
|---|
| | 1620 | var map=m.map; |
|---|
| | 1621 | var next=self.next; |
|---|
| | 1622 | return {repr:function(){ |
|---|
| | 1623 | return "imap(...)"; |
|---|
| | 1624 | },toString:m.forward("repr"),next:function(){ |
|---|
| | 1625 | return fun.apply(this,map(next,_148)); |
|---|
| | 1626 | }}; |
|---|
| | 1627 | },applymap:function(fun,seq,self){ |
|---|
| | 1628 | seq=MochiKit.Iter.iter(seq); |
|---|
| | 1629 | var m=MochiKit.Base; |
|---|
| | 1630 | return {repr:function(){ |
|---|
| | 1631 | return "applymap(...)"; |
|---|
| | 1632 | },toString:m.forward("repr"),next:function(){ |
|---|
| | 1633 | return fun.apply(self,seq.next()); |
|---|
| | 1634 | }}; |
|---|
| | 1635 | },chain:function(p,q){ |
|---|
| | 1636 | var self=MochiKit.Iter; |
|---|
| | 1637 | var m=MochiKit.Base; |
|---|
| | 1638 | if(arguments.length==1){ |
|---|
| | 1639 | return self.iter(arguments[0]); |
|---|
| | 1640 | } |
|---|
| | 1641 | var _150=m.map(self.iter,arguments); |
|---|
| | 1642 | return {repr:function(){ |
|---|
| | 1643 | return "chain(...)"; |
|---|
| | 1644 | },toString:m.forward("repr"),next:function(){ |
|---|
| | 1645 | while(_150.length>1){ |
|---|
| | 1646 | try{ |
|---|
| | 1647 | return _150[0].next(); |
|---|
| | 1648 | } |
|---|
| | 1649 | catch(e){ |
|---|
| | 1650 | if(e!=self.StopIteration){ |
|---|
| | 1651 | throw e; |
|---|
| | 1652 | } |
|---|
| | 1653 | _150.shift(); |
|---|
| | 1654 | } |
|---|
| | 1655 | } |
|---|
| | 1656 | if(_150.length==1){ |
|---|
| | 1657 | var arg=_150.shift(); |
|---|
| | 1658 | this.next=m.bind("next",arg); |
|---|
| | 1659 | return this.next(); |
|---|
| | 1660 | } |
|---|
| | 1661 | throw self.StopIteration; |
|---|
| | 1662 | }}; |
|---|
| | 1663 | },takewhile:function(pred,seq){ |
|---|
| | 1664 | var self=MochiKit.Iter; |
|---|
| | 1665 | seq=self.iter(seq); |
|---|
| | 1666 | return {repr:function(){ |
|---|
| | 1667 | return "takewhile(...)"; |
|---|
| | 1668 | },toString:MochiKit.Base.forward("repr"),next:function(){ |
|---|
| | 1669 | var rval=seq.next(); |
|---|
| | 1670 | if(!pred(rval)){ |
|---|
| | 1671 | this.next=function(){ |
|---|
| | 1672 | throw self.StopIteration; |
|---|
| | 1673 | }; |
|---|
| | 1674 | this.next(); |
|---|
| | 1675 | } |
|---|
| | 1676 | return rval; |
|---|
| | 1677 | }}; |
|---|
| | 1678 | },dropwhile:function(pred,seq){ |
|---|
| | 1679 | seq=MochiKit.Iter.iter(seq); |
|---|
| | 1680 | var m=MochiKit.Base; |
|---|
| | 1681 | var bind=m.bind; |
|---|
| | 1682 | return {"repr":function(){ |
|---|
| | 1683 | return "dropwhile(...)"; |
|---|
| | 1684 | },"toString":m.forward("repr"),"next":function(){ |
|---|
| | 1685 | while(true){ |
|---|
| | 1686 | var rval=seq.next(); |
|---|
| | 1687 | if(!pred(rval)){ |
|---|
| | 1688 | break; |
|---|
| | 1689 | } |
|---|
| | 1690 | } |
|---|
| | 1691 | this.next=bind("next",seq); |
|---|
| | 1692 | return rval; |
|---|
| | 1693 | }}; |
|---|
| | 1694 | },_tee:function(_152,sync,_154){ |
|---|
| | 1695 | sync.pos[_152]=-1; |
|---|
| | 1696 | var m=MochiKit.Base; |
|---|
| | 1697 | var _155=m.listMin; |
|---|
| | 1698 | return {repr:function(){ |
|---|
| | 1699 | return "tee("+_152+", ...)"; |
|---|
| | 1700 | },toString:m.forward("repr"),next:function(){ |
|---|
| | 1701 | var rval; |
|---|
| | 1702 | var i=sync.pos[_152]; |
|---|
| | 1703 | if(i==sync.max){ |
|---|
| | 1704 | rval=_154.next(); |
|---|
| | 1705 | sync.deque.push(rval); |
|---|
| | 1706 | sync.max+=1; |
|---|
| | 1707 | sync.pos[_152]+=1; |
|---|
| | 1708 | }else{ |
|---|
| | 1709 | rval=sync.deque[i-sync.min]; |
|---|
| | 1710 | sync.pos[_152]+=1; |
|---|
| | 1711 | if(i==sync.min&&_155(sync.pos)!=sync.min){ |
|---|
| | 1712 | sync.min+=1; |
|---|
| | 1713 | sync.deque.shift(); |
|---|
| | 1714 | } |
|---|
| | 1715 | } |
|---|
| | 1716 | return rval; |
|---|
| | 1717 | }}; |
|---|
| | 1718 | },tee:function(_156,n){ |
|---|
| | 1719 | var rval=[]; |
|---|
| | 1720 | var sync={"pos":[],"deque":[],"max":-1,"min":-1}; |
|---|
| | 1721 | if(arguments.length==1){ |
|---|
| | 1722 | n=2; |
|---|
| | 1723 | } |
|---|
| | 1724 | var self=MochiKit.Iter; |
|---|
| | 1725 | _156=self.iter(_156); |
|---|
| | 1726 | var _tee=self._tee; |
|---|
| | 1727 | for(var i=0;i<n;i++){ |
|---|
| | 1728 | rval.push(_tee(i,sync,_156)); |
|---|
| | 1729 | } |
|---|
| | 1730 | return rval; |
|---|
| | 1731 | },list:function(_158){ |
|---|
| | 1732 | var m=MochiKit.Base; |
|---|
| | 1733 | if(typeof (_158.slice)=="function"){ |
|---|
| | 1734 | return _158.slice(); |
|---|
| | 1735 | }else{ |
|---|
| | 1736 | if(m.isArrayLike(_158)){ |
|---|
| | 1737 | return m.concat(_158); |
|---|
| | 1738 | } |
|---|
| | 1739 | } |
|---|
| | 1740 | var self=MochiKit.Iter; |
|---|
| | 1741 | _158=self.iter(_158); |
|---|
| | 1742 | var rval=[]; |
|---|
| | 1743 | try{ |
|---|
| | 1744 | while(true){ |
|---|
| | 1745 | rval.push(_158.next()); |
|---|
| | 1746 | } |
|---|
| | 1747 | } |
|---|
| | 1748 | catch(e){ |
|---|
| | 1749 | if(e!=self.StopIteration){ |
|---|
| | 1750 | throw e; |
|---|
| | 1751 | } |
|---|
| | 1752 | return rval; |
|---|
| | 1753 | } |
|---|
| | 1754 | return undefined; |
|---|
| | 1755 | },reduce:function(fn,_159,_160){ |
|---|
| | 1756 | var i=0; |
|---|
| | 1757 | var x=_160; |
|---|
| | 1758 | var self=MochiKit.Iter; |
|---|
| | 1759 | _159=self.iter(_159); |
|---|
| | 1760 | if(arguments.length<3){ |
|---|
| | 1761 | try{ |
|---|
| | 1762 | x=_159.next(); |
|---|
| | 1763 | } |
|---|
| | 1764 | catch(e){ |
|---|
| | 1765 | if(e==self.StopIteration){ |
|---|
| | 1766 | e=new TypeError("reduce() of empty sequence with no initial value"); |
|---|
| | 1767 | } |
|---|
| | 1768 | throw e; |
|---|
| | 1769 | } |
|---|
| | 1770 | i++; |
|---|
| | 1771 | } |
|---|
| | 1772 | try{ |
|---|
| | 1773 | while(true){ |
|---|
| | 1774 | x=fn(x,_159.next()); |
|---|
| | 1775 | } |
|---|
| | 1776 | } |
|---|
| | 1777 | catch(e){ |
|---|
| | 1778 | if(e!=self.StopIteration){ |
|---|
| | 1779 | throw e; |
|---|
| | 1780 | } |
|---|
| | 1781 | } |
|---|
| | 1782 | return x; |
|---|
| | 1783 | },range:function(){ |
|---|
| | 1784 | var _162=0; |
|---|
| | 1785 | var stop=0; |
|---|
| | 1786 | var step=1; |
|---|
| | 1787 | if(arguments.length==1){ |
|---|
| | 1788 | stop=arguments[0]; |
|---|
| | 1789 | }else{ |
|---|
| | 1790 | if(arguments.length==2){ |
|---|
| | 1791 | _162=arguments[0]; |
|---|
| | 1792 | stop=arguments[1]; |
|---|
| | 1793 | }else{ |
|---|
| | 1794 | if(arguments.length==3){ |
|---|
| | 1795 | _162=arguments[0]; |
|---|
| | 1796 | stop=arguments[1]; |
|---|
| | 1797 | step=arguments[2]; |
|---|
| | 1798 | }else{ |
|---|
| | 1799 | throw new TypeError("range() takes 1, 2, or 3 arguments!"); |
|---|
| | 1800 | } |
|---|
| | 1801 | } |
|---|
| | 1802 | } |
|---|
| | 1803 | if(step==0){ |
|---|
| | 1804 | throw new TypeError("range() step must not be 0"); |
|---|
| | 1805 | } |
|---|
| | 1806 | return {next:function(){ |
|---|
| | 1807 | if((step>0&&_162>=stop)||(step<0&&_162<=stop)){ |
|---|
| | 1808 | throw MochiKit.Iter.StopIteration; |
|---|
| | 1809 | } |
|---|
| | 1810 | var rval=_162; |
|---|
| | 1811 | _162+=step; |
|---|
| | 1812 | return rval; |
|---|
| | 1813 | },repr:function(){ |
|---|
| | 1814 | return "range("+[_162,stop,step].join(", ")+")"; |
|---|
| | 1815 | },toString:MochiKit.Base.forward("repr")}; |
|---|
| | 1816 | },sum:function(_163,_164){ |
|---|
| | 1817 | var x=_164||0; |
|---|
| | 1818 | var self=MochiKit.Iter; |
|---|
| | 1819 | _163=self.iter(_163); |
|---|
| | 1820 | try{ |
|---|
| | 1821 | while(true){ |
|---|
| | 1822 | x+=_163.next(); |
|---|
| | 1823 | } |
|---|
| | 1824 | } |
|---|
| | 1825 | catch(e){ |
|---|
| | 1826 | if(e!=self.StopIteration){ |
|---|
| | 1827 | throw e; |
|---|
| | 1828 | } |
|---|
| | 1829 | } |
|---|
| | 1830 | return x; |
|---|
| | 1831 | },exhaust:function(_165){ |
|---|
| | 1832 | var self=MochiKit.Iter; |
|---|
| | 1833 | _165=self.iter(_165); |
|---|
| | 1834 | try{ |
|---|
| | 1835 | while(true){ |
|---|
| | 1836 | _165.next(); |
|---|
| | 1837 | } |
|---|
| | 1838 | } |
|---|
| | 1839 | catch(e){ |
|---|
| | 1840 | if(e!=self.StopIteration){ |
|---|
| | 1841 | throw e; |
|---|
| | 1842 | } |
|---|
| | 1843 | } |
|---|
| | 1844 | },forEach:function(_166,func,self){ |
|---|
| | 1845 | var m=MochiKit.Base; |
|---|
| | 1846 | if(arguments.length>2){ |
|---|
| | 1847 | func=m.bind(func,self); |
|---|
| | 1848 | } |
|---|
| | 1849 | if(m.isArrayLike(_166)){ |
|---|
| | 1850 | try{ |
|---|
| | 1851 | for(var i=0;i<_166.length;i++){ |
|---|
| | 1852 | func(_166[i]); |
|---|
| | 1853 | } |
|---|
| | 1854 | } |
|---|
| | 1855 | catch(e){ |
|---|
| | 1856 | if(e!=MochiKit.Iter.StopIteration){ |
|---|
| | 1857 | throw e; |
|---|
| | 1858 | } |
|---|
| | 1859 | } |
|---|
| | 1860 | }else{ |
|---|
| | 1861 | self=MochiKit.Iter; |
|---|
| | 1862 | self.exhaust(self.imap(func,_166)); |
|---|
| | 1863 | } |
|---|
| | 1864 | },every:function(_168,func){ |
|---|
| | 1865 | var self=MochiKit.Iter; |
|---|
| | 1866 | try{ |
|---|
| | 1867 | self.ifilterfalse(func,_168).next(); |
|---|
| | 1868 | return false; |
|---|
| | 1869 | } |
|---|
| | 1870 | catch(e){ |
|---|
| | 1871 | if(e!=self.StopIteration){ |
|---|
| | 1872 | throw e; |
|---|
| | 1873 | } |
|---|
| | 1874 | return true; |
|---|
| | 1875 | } |
|---|
| | 1876 | },sorted:function(_169,cmp){ |
|---|
| | 1877 | var rval=MochiKit.Iter.list(_169); |
|---|
| | 1878 | if(arguments.length==1){ |
|---|
| | 1879 | cmp=MochiKit.Base.compare; |
|---|
| | 1880 | } |
|---|
| | 1881 | rval.sort(cmp); |
|---|
| | 1882 | return rval; |
|---|
| | 1883 | },reversed:function(_170){ |
|---|
| | 1884 | var rval=MochiKit.Iter.list(_170); |
|---|
| | 1885 | rval.reverse(); |
|---|
| | 1886 | return rval; |
|---|
| | 1887 | },some:function(_171,func){ |
|---|
| | 1888 | var self=MochiKit.Iter; |
|---|
| | 1889 | try{ |
|---|
| | 1890 | self.ifilter(func,_171).next(); |
|---|
| | 1891 | return true; |
|---|
| | 1892 | } |
|---|
| | 1893 | catch(e){ |
|---|
| | 1894 | if(e!=self.StopIteration){ |
|---|
| | 1895 | throw e; |
|---|
| | 1896 | } |
|---|
| | 1897 | return false; |
|---|
| | 1898 | } |
|---|
| | 1899 | },iextend:function(lst,_172){ |
|---|
| | 1900 | if(MochiKit.Base.isArrayLike(_172)){ |
|---|
| | 1901 | for(var i=0;i<_172.length;i++){ |
|---|
| | 1902 | lst.push(_172[i]); |
|---|
| | 1903 | } |
|---|
| | 1904 | |
|---|