ÿþ/ *  
 *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 *       J a v a S c r i p t   L i b a r y   t o   A c c e s s   S h a r e P o i n t   L i s t s  
 *        
 *     A u t h o r :   D u W e i   ( E r u c y ) ,   M V P   o f   S h a r e P o i n t   S e r v i c e s  
 *     V e r s i o n :   1 . 0  
 *     L a s t M o d :   2 0 0 9 - 1 - 2 6  
 *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 * /  
  
 / *  
 *   a j a x   p o s t   t o   s h a r e p o i n t ,   f o r   i n t e r n a l   u s e ,   s y n c   m o d e  
 *   	 w s U r l :   w e b   s e r v i c e   f i l e   u r l  
 *   	 a c t i o n H e a d e r :   " S O A P A c t i o n "   h t t p   h e a d e r  
 *   	 w s B o d y :   p o s t   c o n t e n t  
 *   	 d e a l F u n c :   a j a x   p r o c e s s   f u n c t i o n  
 * /  
 f u n c t i o n   i n n e r P o s t ( w s U r l ,   a c t i o n H e a d e r ,   w s B o d y ,   d e a l F u n c )   {  
         v a r   c o n t e n t   =   n e w   S t r i n g B u f f e r ( ) ;  
         c o n t e n t . a p p e n d ( " < ? x m l   v e r s i o n = ' 1 . 0 '   e n c o d i n g = ' u t f - 8 ' ? > " ) ;  
         c o n t e n t . a p p e n d ( " < s o a p : E n v e l o p e   x m l n s : x s i = ' h t t p : / / w w w . w 3 . o r g / 2 0 0 1 / X M L S c h e m a - i n s t a n c e '   x m l n s : x s d = ' h t t p : / / w w w . w 3 . o r g / 2 0 0 1 / X M L S c h e m a '   x m l n s : s o a p = ' h t t p : / / s c h e m a s . x m l s o a p . o r g / s o a p / e n v e l o p e / ' > " ) ;  
         c o n t e n t . a p p e n d ( " < s o a p : B o d y > " ) ;  
         c o n t e n t . a p p e n d ( w s B o d y ) ;  
         c o n t e n t . a p p e n d ( " < / s o a p : B o d y > " ) ;  
         c o n t e n t . a p p e n d ( " < / s o a p : E n v e l o p e > " ) ;  
         $ . a j a x ( {  
                 a s y n c :   f a l s e ,  
                 t y p e :   " P O S T " ,  
                 u r l :   w s U r l ,  
                 c o n t e n t T y p e :   " t e x t / x m l ;   c h a r s e t = u t f - 8 " ,  
                 p r o c e s s D a t a :   f a l s e ,  
                 d a t a :   c o n t e n t . t o S t r i n g ( ) ,  
                 d a t a T y p e :   " x m l " ,  
                 b e f o r e S e n d :   f u n c t i o n ( x h r )   {  
                         x h r . s e t R e q u e s t H e a d e r ( ' S O A P A c t i o n ' ,   a c t i o n H e a d e r ) ;  
                 } ,  
                 s u c c e s s :   d e a l F u n c  
         } ) ;  
         / / 	 $ . a j a x ( {  
         / / 	         a s y n c :   f a l s e ,  
         / / 	         t y p e :   " P O S T " ,  
         / / 	         u r l :   w s U r l ,  
         / / 	         c o n t e n t T y p e :   " t e x t / x m l ;   c h a r s e t = u t f - 8 " ,  
         / / 	         p r o c e s s D a t a :   f a l s e ,  
         / / 	         d a t a :   c o n t e n t . t o S t r i n g ( ) ,  
         / / 	         d a t a T y p e :   " x m l " ,  
         / / 	         s u c c e s s :   d e a l F u n c  
         / / 	 } ) ;  
  
 }  
  
 / *  
 *   g e t   u s e r   p r o f i l e   d a t a  
 *   r e t u r n :   u s e r   p r o f i l e   d a t a   i n   o b j e c t   t y p e  
 *   	 r e s u l t [ p r o p N a m e ]   t o   g e t   v a l u e  
 * /  
 f u n c t i o n   g e t U s e r P r o f i l e ( )   {  
         v a r   r e s u l t   =   { } ;  
         i n n e r P o s t ( w s B a s e U r l   +   ' u s e r p r o f i l e s e r v i c e . a s m x ' ,  
 	 	 ' h t t p : / / m i c r o s o f t . c o m / w e b s e r v i c e s / S h a r e P o i n t P o r t a l S e r v e r / U s e r P r o f i l e S e r v i c e / G e t U s e r P r o f i l e B y N a m e ' ,  
 	 	 ' < G e t U s e r P r o f i l e B y N a m e   x m l n s = " h t t p : / / m i c r o s o f t . c o m / w e b s e r v i c e s / S h a r e P o i n t P o r t a l S e r v e r / U s e r P r o f i l e S e r v i c e " > < A c c o u n t N a m e > < / A c c o u n t N a m e > < / G e t U s e r P r o f i l e B y N a m e > ' ,  
 	 	 f u n c t i o n ( d a t a )   {  
 	 	         $ ( ' P r o p e r t y D a t a ' ,   d a t a ) . e a c h ( f u n c t i o n ( )   {  
 	 	                 v a r   n a m e   =   $ ( t h i s ) . f i n d ( ' N a m e ' ) . t e x t ( ) ;  
 	 	                 v a r   v a l u e   =   $ ( t h i s ) . f i n d ( ' V a l u e ' ) . t e x t ( ) ;  
 	 	                 r e s u l t [ n a m e ]   =   v a l u e ;  
 	 	         } ) ;  
 	 	 } ) ;  
         r e t u r n   r e s u l t ;  
 }  
  
 / *  
 *   b u i l d   q u e r y   c o n t e n t ,   f o r   i n t e r n a l   u s e  
 *   	 l i s t N a m e :   n a m e   o f   t h e   l i s t  
 *   	 q u e r y :   c a m l   t y p e   q u e r y  
 *   	 v i e w F i e l d s :   a r r a y   o f   t h e   f i e l d s   n a m e   ( i n t e r n a l   n a m e )  
 *   	 r o w L i m i t :   h o w   m a n y   i t e m s   t o   q u e r y  
 *   	 p a g i n g I n f o :   w h i c h   p a g e   t o   q u e r y  
 *   r e t u r n :   c o n t e n t   f o r   w e b   s e r v i c e  
 * /  
 f u n c t i o n   b u i l d Q u e r y C o n t e n t ( l i s t N a m e ,   q u e r y ,   v i e w F i e l d s ,   r o w L i m i t ,   p a g i n g I n f o )   {  
         v a r   r e s u l t   =   n e w   S t r i n g B u f f e r ( ) ;  
         r e s u l t . a p p e n d ( ' < G e t L i s t I t e m s   x m l n s = " h t t p : / / s c h e m a s . m i c r o s o f t . c o m / s h a r e p o i n t / s o a p / " > ' ) ;  
         r e s u l t . a p p e n d ( ' < l i s t N a m e > '   +   l i s t N a m e   +   ' < / l i s t N a m e > ' ) ;  
         i f   ( q u e r y   ! =   n u l l   & &   q u e r y   ! =   ' ' )   {  
                 r e s u l t . a p p e n d ( ' < q u e r y > < Q u e r y   x m l n s = " " > ' ) ;  
                 r e s u l t . a p p e n d ( q u e r y ) ;  
                 r e s u l t . a p p e n d ( ' < / Q u e r y > < / q u e r y > ' ) ;  
         }  
         i f   ( v i e w F i e l d s   ! =   n u l l   & &   v i e w F i e l d s . l e n g t h   >   0 )   {  
                 r e s u l t . a p p e n d ( ' < v i e w F i e l d s > < V i e w F i e l d s   x m l n s = " " > ' ) ;  
                 $ . e a c h ( v i e w F i e l d s ,   f u n c t i o n ( i d x ,   f i e l d )   {  
                         r e s u l t . a p p e n d ( ' < F i e l d R e f   N a m e = " '   +   f i e l d   +   ' " / > ' ) ;  
                 } ) ;  
                 r e s u l t . a p p e n d ( ' < / V i e w F i e l d s > < / v i e w F i e l d s > ' ) ;  
         }  
         i f   ( r o w L i m i t   ! =   u n d e f i n e d   & &   r o w L i m i t   ! =   n u l l   & &   r o w L i m i t   >   0 )  
                 r e s u l t . a p p e n d ( ' < r o w L i m i t > '   +   r o w L i m i t   +   ' < / r o w L i m i t > ' ) ;  
         e l s e  
                 r e s u l t . a p p e n d ( ' < r o w L i m i t > 1 0 0 0 0 0 < / r o w L i m i t > ' ) ;  
         r e s u l t . a p p e n d ( ' < q u e r y O p t i o n s > < Q u e r y O p t i o n s   x m l n s = " " > < I n c l u d e M a n d a t o r y C o l u m n s > F A L S E < / I n c l u d e M a n d a t o r y C o l u m n s > ' ) ;  
         i f   ( p a g i n g I n f o   ! =   u n d e f i n e d   & &   p a g i n g I n f o   ! =   n u l l   & &   p a g i n g I n f o   ! =   ' ' )  
                 r e s u l t . a p p e n d ( ' < P a g i n g   L i s t I t e m C o l l e c t i o n P o s i t i o n N e x t = " '   +   p a g i n g I n f o . r e p l a c e ( / & / g ,   ' & a m p ; ' )   +   ' "   / > ' ) ;  
         r e s u l t . a p p e n d ( ' < / Q u e r y O p t i o n s > < / q u e r y O p t i o n s > ' ) ;  
         r e s u l t . a p p e n d ( ' < / G e t L i s t I t e m s > ' ) ;  
         r e t u r n   r e s u l t . t o S t r i n g ( ) ;  
 }  
  
 / *  
 *   g e t   i t e m s   c o u n t   i n   a   l i s t  
 *   	 l i s t N a m e :   n a m e   o f   t h e   l i s t  
 *   	 q u e r y :   c a m l   t y p e   q u e r y  
 *   r e t u r n :   c o u n t   o f   t h e   i t e m s  
 * /  
 f u n c t i o n   q u e r y I t e m C o u n t ( l i s t N a m e ,   q u e r y )   {  
         v a r   c o n t e n t   =   b u i l d Q u e r y C o n t e n t ( l i s t N a m e ,   q u e r y ,   n u l l ) ;  
         v a r   r e s u l t   =   - 1 ;  
         i n n e r P o s t ( w s B a s e U r l   +   ' l i s t s . a s m x ' ,   ' h t t p : / / s c h e m a s . m i c r o s o f t . c o m / s h a r e p o i n t / s o a p / G e t L i s t I t e m s ' ,   c o n t e n t ,   f u n c t i o n ( d a t a )   {  
                 r e s u l t   =   p a r s e I n t ( $ ( ' r s \ \ : d a t a ' ,   d a t a ) . a t t r ( ' I t e m C o u n t ' ) ) ;  
         } ) ;  
         r e t u r n   r e s u l t ;  
 }  
  
 / *  
 *   c o n v e r t   i t e m   t o   o b j e c t ,   f o r   i n t e r n a l   u s e  
 *   	 i t e m D a t a :   x m l   t y p e   d a t a  
 *   	 v i e w F i e l d s :   f i e l d s   t o   v i e w   ( i n t e r n a l   n a m e )  
 *   r e t u r n :   o b j e c t   t y p e   i t e m  
 *   	 r e s u l t [ f i e l d N a m e ]   t o   g e t   v a l u e  
 * /  
 f u n c t i o n   g e n e r a t e I t e m ( i t e m D a t a ,   v i e w F i e l d s )   {  
         v a r   r e s u l t   =   { } ;  
         $ . e a c h ( v i e w F i e l d s ,   f u n c t i o n ( i d x ,   f i e l d )   {  
                 v a r   v a l u e   =   $ ( i t e m D a t a ) . a t t r ( ' o w s _ '   +   f i e l d ) ;  
                 i f   ( v a l u e   = =   u n d e f i n e d )   v a l u e   =   n u l l ;  
                 r e s u l t [ f i e l d ]   =   v a l u e ;  
         } ) ;  
         r e t u r n   r e s u l t ;  
 }  
  
 / *  
 *   g e t   i t e m s   a c c o r d i n g   t o   q u e r y  
 *   	 l i s t N a m e :   n a m e   o f   t h e   l i s t  
 *   	 q u e r y :   c a m l   t y p e   q u e r y  
 *   	 v i e w F i e l d s :   f i e l d s   t o   v i e w   ( i n t e r n a l   n a m e )  
 *   	 r o w L i m i t :   h o w   m a n y   i t e m s   t o   r e t u r n  
 *   	 p a g i n g I n f o :   w h i c h   p a g e   t o   q u e r y ,   u s e   t h e   ' n e x t P a g i n g I n f o '   o f   t h e   p r e v i o u s   p a g e   r e s u l t  
 *   r e t u r n :   	 {   c o u n t :   r e t u r n   i t e m   c o u n t  
 *   	 	 	     n e x t P a g i n g I n f o :   p a g i n g   i n f o   t o   q u e r y   n e x t   p a g e ,   u n d e f i n e d   f o r   t h e   l a s t   p a g e  
 *   	 	 	     i t e m s : a r r a y   o f   o b j e c t   t y p e   i t e m s  
 *   	 	 	 }  
 * /  
 f u n c t i o n   q u e r y I t e m s ( l i s t N a m e ,   q u e r y ,   v i e w F i e l d s ,   r o w L i m i t ,   p a g i n g I n f o )   {  
         v a r   c o n t e n t   =   b u i l d Q u e r y C o n t e n t ( l i s t N a m e ,   q u e r y ,   v i e w F i e l d s ,   r o w L i m i t ,   p a g i n g I n f o ) ;  
         v a r   r e s u l t   =   {   c o u n t :   - 1 ,   n e x t P a g i n g I n f o :   ' ' ,   i t e m s :   n e w   A r r a y ( )   } ;  
         i n n e r P o s t ( w s B a s e U r l   +   ' l i s t s . a s m x ' ,   ' h t t p : / / s c h e m a s . m i c r o s o f t . c o m / s h a r e p o i n t / s o a p / G e t L i s t I t e m s ' ,   c o n t e n t ,   f u n c t i o n ( d a t a )   {  
                 r e s u l t . c o u n t   =   $ ( ' r s \ \ : d a t a ' ,   d a t a ) . a t t r ( ' I t e m C o u n t ' ) ;  
                 r e s u l t . n e x t P a g i n g I n f o   =   $ ( ' r s \ \ : d a t a ' ,   d a t a ) . a t t r ( ' L i s t I t e m C o l l e c t i o n P o s i t i o n N e x t ' ) ;  
                 $ ( ' z \ \ : r o w ' ,   d a t a ) . e a c h ( f u n c t i o n ( i d x ,   i t e m D a t a )   {  
                         r e s u l t . i t e m s . p u s h ( g e n e r a t e I t e m ( i t e m D a t a ,   v i e w F i e l d s ) ) ;  
                 } ) ;  
         } ) ;  
         r e t u r n   r e s u l t ;  
 }  
  
 / *  
 *   g e t   a   i t e m   b y   i d  
 *   	 l i s t N a m e :   n a m e   o f   t h e   l i s t  
 *   	 i d :   i t e m   i d  
 *   	 v i e w F i e l d s :   f i e l d s   t o   v i e w   ( i n t e r n a l   n a m e )  
 * /  
 f u n c t i o n   g e t I t e m B y I d ( l i s t N a m e ,   i d ,   v i e w F i e l d s )   {  
         v a r   q u e r y   =   ' < W h e r e > < E q > < F i e l d R e f   N a m e = " I D "   / > < V a l u e   T y p e = " T e x t " > '   +   i d   +   ' < / V a l u e > < / E q > < / W h e r e > ' ;  
         v a r   r e s u l t   =   q u e r y I t e m s ( l i s t N a m e ,   q u e r y ,   v i e w F i e l d s ) ;  
         i f   ( r e s u l t . i t e m s . l e n g t h   = =   0 )   r e t u r n   n u l l ;  
         e l s e   r e t u r n   r e s u l t . i t e m s [ 0 ] ;  
 }  
  
 / *  
 *   b u i l d   m o d i f y   u s e   ( n e w   &   u p d a t e )   w e b   s e r v i c e   c o n t e n t ,   f o r   i n t e r n a l   u s e  
 *   	 l i s t N a m e :   n a m e   o f   t h e   l i s t  
 *   	 i d :   i t e m   i d   t o   u p d a t e ,   0   f o r   n e w   i t e m  
 *   	 d a t a :   u p d a t e   i n f o  
 *   	 	 d a t a [ f i e l d N a m e ]   =   n e w V a l u e  
 *   r e t u r n :   w e b   s e r v i c e   c o n t e n t   t o   p o s t  
 * /  
 f u n c t i o n   b u i l d M o d i f y C o n t e n t ( l i s t N a m e ,   i d ,   d a t a )   {  
         v a r   r e s u l t   =   n e w   S t r i n g B u f f e r ( ) ;  
         r e s u l t . a p p e n d ( ' < U p d a t e L i s t I t e m s   x m l n s = " h t t p : / / s c h e m a s . m i c r o s o f t . c o m / s h a r e p o i n t / s o a p / " > ' ) ;  
         r e s u l t . a p p e n d ( ' < l i s t N a m e > '   +   l i s t N a m e   +   ' < / l i s t N a m e > ' ) ;  
         r e s u l t . a p p e n d ( ' < u p d a t e s > < B a t c h   O n E r r o r = " C o n t i n u e "   x m l n s = " " > ' ) ;  
         i f   ( i d   = =   0 )   {  
                 r e s u l t . a p p e n d ( ' < M e t h o d   I D = " 1 "   C m d = " N e w " > ' ) ;  
         }  
         e l s e   {  
                 r e s u l t . a p p e n d ( ' < M e t h o d   I D = " 1 "   C m d = " U p d a t e " > ' ) ;  
                 r e s u l t . a p p e n d ( ' < F i e l d   N a m e = " I D " > '   +   i d   +   ' < / F i e l d > ' ) ;  
         }  
         $ . e a c h ( d a t a ,   f u n c t i o n ( f i e l d ,   v a l u e )   {  
                 r e s u l t . a p p e n d ( ' < F i e l d   N a m e = " ' ) ;  
                 r e s u l t . a p p e n d ( f i e l d ) ;  
                 r e s u l t . a p p e n d ( ' " > < ! [ C D A T A [ ' ) ;  
                 r e s u l t . a p p e n d ( v a l u e ) ;  
                 r e s u l t . a p p e n d ( ' ] ] > < / F i e l d > ' ) ;  
         } ) ;  
         r e s u l t . a p p e n d ( ' < / M e t h o d > < / B a t c h > < / u p d a t e s > < / U p d a t e L i s t I t e m s > ' ) ;  
         r e t u r n   r e s u l t . t o S t r i n g ( ) ;  
 }  
  
 / *  
 *   b u i l d   m o d i f y   u s e   w e b   s e r v i c e   c o n t e n t ,   f o r   i n t e r n a l   u s e  
 *   	 l i s t N a m e :   n a m e   o f   t h e   l i s t  
 *   	 i d s :   i t e m s   i d   t o   u p d a t e  
 *   	 d a t a :   u p d a t e   i n f o  
 *   	 	 d a t a [ f i e l d N a m e ]   =   n e w V a l u e  
 *   r e t u r n :   w e b   s e r v i c e   c o n t e n t   t o   p o s t  
 * /  
 f u n c t i o n   b u i l d U p d a t e s C o n t e n t ( l i s t N a m e ,   i d s ,   d a t a )   {  
         v a r   r e s u l t   =   n e w   S t r i n g B u f f e r ( ) ;  
         r e s u l t . a p p e n d ( ' < U p d a t e L i s t I t e m s   x m l n s = " h t t p : / / s c h e m a s . m i c r o s o f t . c o m / s h a r e p o i n t / s o a p / " > ' ) ;  
         r e s u l t . a p p e n d ( ' < l i s t N a m e > '   +   l i s t N a m e   +   ' < / l i s t N a m e > ' ) ;  
         r e s u l t . a p p e n d ( ' < u p d a t e s > < B a t c h   O n E r r o r = " C o n t i n u e "   x m l n s = " " > ' ) ;  
         $ . e a c h ( i d s ,   f u n c t i o n ( i d x ,   i d )   {  
                 r e s u l t . a p p e n d ( ' < M e t h o d   I D = " '   +   ( i d x   +   1 ) . t o S t r i n g ( )   +   ' "   C m d = " U p d a t e " > ' ) ;  
                 r e s u l t . a p p e n d ( ' < F i e l d   N a m e = " I D " > '   +   i d   +   ' < / F i e l d > ' ) ;  
                 $ . e a c h ( d a t a ,   f u n c t i o n ( f i e l d ,   v a l u e )   {  
                         r e s u l t . a p p e n d ( ' < F i e l d   N a m e = " ' ) ;  
                         r e s u l t . a p p e n d ( f i e l d ) ;  
                         r e s u l t . a p p e n d ( ' " > < ! [ C D A T A [ ' ) ;  
                         r e s u l t . a p p e n d ( v a l u e ) ;  
                         r e s u l t . a p p e n d ( ' ] ] > < / F i e l d > ' ) ;  
                 } ) ;  
                 r e s u l t . a p p e n d ( ' < / M e t h o d > ' ) ;  
         } ) ;  
         r e s u l t . a p p e n d ( ' < / B a t c h > < / u p d a t e s > < / U p d a t e L i s t I t e m s > ' ) ;  
         r e t u r n   r e s u l t . t o S t r i n g ( ) ;  
 }  
  
 / *  
 *   b u i l d   d e l e t e   u s e   w e b   s e r v i c e   c o n t e n t ,   f o r   i n t e r n a l   u s e  
 *   	 l i s t N a m e :   n a m e   o f   t h e   l i s t  
 *   	 i d s :   i t e m   i d   t o   d e l e t e  
 *   r e t u r n :   w e b   s e r v i c e   c o n t e n t   t o   p o s t  
 * /  
 f u n c t i o n   b u i l d D e l e t e C o n t e n t ( l i s t N a m e ,   i d )   {  
         v a r   r e s u l t   =   n e w   S t r i n g B u f f e r ( ) ;  
         r e s u l t . a p p e n d ( ' < U p d a t e L i s t I t e m s   x m l n s = " h t t p : / / s c h e m a s . m i c r o s o f t . c o m / s h a r e p o i n t / s o a p / " > ' ) ;  
         r e s u l t . a p p e n d ( ' < l i s t N a m e > '   +   l i s t N a m e   +   ' < / l i s t N a m e > ' ) ;  
         r e s u l t . a p p e n d ( ' < u p d a t e s > < B a t c h   O n E r r o r = " C o n t i n u e "   x m l n s = " " > ' ) ;  
         r e s u l t . a p p e n d ( ' < M e t h o d   I D = " 1 "   C m d = " D e l e t e " > ' ) ;  
         r e s u l t . a p p e n d ( ' < F i e l d   N a m e = " I D " > '   +   i d   +   ' < / F i e l d > ' ) ;  
         r e s u l t . a p p e n d ( ' < / M e t h o d > ' ) ;  
         r e s u l t . a p p e n d ( ' < / B a t c h > < / u p d a t e s > < / U p d a t e L i s t I t e m s > ' ) ;  
         r e t u r n   r e s u l t . t o S t r i n g ( ) ;  
 }  
  
 / *  
 *   u p d a t e   i t e m  
 *   	 l i s t N a m e :   n a m e   o f   t h e   l i s t  
 *   	 i d :   i d   o f   t h e   i t e m   t o   u p d a t e  
 *   	 d a t a :   d a t a   t o   m o d i f i e d  
 *   	 	 d a t a [ f i e l d N a m e ]   =   v a l u e ,   u s e   i n t e r n a l   n a m e  
 *   r e t u r n :   o p e r a t i o n   r e s u l t  
 *   	 	 {   s u c c e s s :   ( b o o l )   w h e t h e r   t h e   o p e r a t i o n   i s   s u c c e s s  
 *   	 	     e r r o r C o d e :   e r r o r   c o d e ,   0 x 0 0 0 0 0 0 0 0   f o r   n o   e r r o r  
 *   	 	     e r r o r T e x t :   e r r o r   t e x t ,   n u l l   f o r   n o   e r r o r  
 *   	 	     i d :   i t e m   i d ,   - 1   f o r   e r r o r  
 *   	 	 }  
 * /  
 f u n c t i o n   u p d a t e I t e m ( l i s t N a m e ,   i d ,   d a t a )   {  
         v a r   c o n t e n t   =   b u i l d M o d i f y C o n t e n t ( l i s t N a m e ,   i d ,   d a t a ) ;  
         v a r   r e s u l t   =   {   s u c c e s s :   f a l s e ,   e r r o r C o d e :   ' ' ,   e r r o r T e x t :   ' i n t e r n a l   e r r o r ' ,   i d :   - 1   } ;  
         i n n e r P o s t ( w s B a s e U r l   +   ' l i s t s . a s m x ' ,   ' h t t p : / / s c h e m a s . m i c r o s o f t . c o m / s h a r e p o i n t / s o a p / U p d a t e L i s t I t e m s ' ,   c o n t e n t ,   f u n c t i o n ( d a t a )   {  
                 i f   ( $ ( ' E r r o r T e x t ' ,   d a t a ) . l e n g t h   >   0 )   {  
                         r e s u l t . s u c c e s s   =   f a l s e ;  
                         r e s u l t . e r r o r C o d e   =   $ ( ' E r r o r C o d e ' ,   d a t a ) . t e x t ( ) ;  
                         r e s u l t . e r r o r T e x t   =   $ ( ' E r r o r T e x t ' ,   d a t a ) . t e x t ( ) ;  
                         r e s u l t . i d   =   - 1 ;  
                 }   e l s e   {  
                         r e s u l t . s u c c e s s   =   t r u e ;  
                         r e s u l t . e r r o r C o d e   =   ' 0 x 0 0 0 0 0 0 0 0 ' ;  
                         r e s u l t . e r r o r T e x t   =   n u l l ;  
                         r e s u l t . i d   =   $ ( ' z \ \ : r o w ' ,   d a t a ) . a t t r ( ' o w s _ I D ' ) ;  
                 }  
         } ) ;  
         r e t u r n   r e s u l t ;  
 }  
  
 / *  
 *   u p d a t e   i t e m s  
 *   	 l i s t N a m e :   n a m e   o f   t h e   l i s t  
 *   	 i d s :   i d   o f   t h e   i t e m s   t o   u p d a t e  
 *   	 d a t a :   d a t a   t o   m o d i f i e d  
 *   	 	 d a t a [ f i e l d N a m e ]   =   v a l u e ,   u s e   i n t e r n a l   n a m e  
 *   r e t u r n :   o p e r a t i o n   r e s u l t  
 *   	 	 {   s u c c e s s :   ( b o o l )   w h e t h e r   t h e   o p e r a t i o n   i s   s u c c e s s  
 *   	 	     e r r o r C o d e :   e r r o r   c o d e ,   0 x 0 0 0 0 0 0 0 0   f o r   n o   e r r o r  
 *   	 	     e r r o r T e x t :   e r r o r   t e x t ,   n u l l   f o r   n o   e r r o r  
 *   	 	 }  
 * /  
 f u n c t i o n   u p d a t e I t e m s ( l i s t N a m e ,   i d s ,   d a t a )   {  
         v a r   c o n t e n t   =   b u i l d U p d a t e s C o n t e n t ( l i s t N a m e ,   i d s ,   d a t a ) ;  
         v a r   r e s u l t   =   {   s u c c e s s :   f a l s e ,   e r r o r C o d e :   ' ' ,   e r r o r T e x t :   ' i n t e r n a l   e r r o r '   } ;  
         i n n e r P o s t ( w s B a s e U r l   +   ' l i s t s . a s m x ' ,   ' h t t p : / / s c h e m a s . m i c r o s o f t . c o m / s h a r e p o i n t / s o a p / U p d a t e L i s t I t e m s ' ,   c o n t e n t ,   f u n c t i o n ( d a t a )   {  
                 i f   ( $ ( ' E r r o r T e x t ' ,   d a t a ) . l e n g t h   >   0 )   {  
                         r e s u l t . s u c c e s s   =   f a l s e ;  
                         r e s u l t . e r r o r C o d e   =   $ ( ' E r r o r C o d e ' ,   d a t a ) . t e x t ( ) ;  
                         r e s u l t . e r r o r T e x t   =   $ ( ' E r r o r T e x t ' ,   d a t a ) . t e x t ( ) ;  
                 }   e l s e   {  
                         r e s u l t . s u c c e s s   =   t r u e ;  
                         r e s u l t . e r r o r C o d e   =   ' 0 x 0 0 0 0 0 0 0 0 ' ;  
                         r e s u l t . e r r o r T e x t   =   n u l l ;  
                 }  
         } ) ;  
         r e t u r n   r e s u l t ;  
 }  
  
 / *  
 *   a d d   a   n e w   i t e m  
 *   	 l i s t N a m e :   n a m e   o f   t h e   l i s t  
 *   	 d a t a :   d a t a   o f   t h e   n e w   i t e m  
 *   	 	 d a t a [ f i e l d N a m e ]   =   v a l u e ,   u s e   i n t e r n a l   n a m e  
 *   r e t u r n :   o p e r a t i o n   r e s u l t  
 *   	 	 {   s u c c e s s :   ( b o o l )   w h e t h e r   t h e   o p e r a t i o n   i s   s u c c e s s  
 *   	 	     e r r o r C o d e :   e r r o r   c o d e ,   0 x 0 0 0 0 0 0 0 0   f o r   n o   e r r o r  
 *   	 	     e r r o r T e x t :   e r r o r   t e x t ,   n u l l   f o r   n o   e r r o r  
 *   	 	     i d :   n e w   i t e m   i d ,   - 1   f o r   e r r o r  
 *   	 	 }  
 * /  
 f u n c t i o n   a d d I t e m ( l i s t N a m e ,   d a t a )   {  
         r e t u r n   u p d a t e I t e m ( l i s t N a m e ,   0 ,   d a t a ) ;  
 }  
  
 / *  
 *   d e l e t e   i t e m  
 *   	 l i s t N a m e :   n a m e   o f   t h e   l i s t  
 *   	 i d :   i d   o f   t h e   i t e m   t o   d e l e t e  
 *   r e t u r n :   o p e r a t i o n   r e s u l t  
 *   	 	 {   s u c c e s s :   ( b o o l )   w h e t h e r   t h e   o p e r a t i o n   i s   s u c c e s s  
 *   	 	     e r r o r C o d e :   e r r o r   c o d e ,   0 x 0 0 0 0 0 0 0 0   f o r   n o   e r r o r  
 *   	 	     e r r o r T e x t :   e r r o r   t e x t ,   n u l l   f o r   n o   e r r o r  
 *   	 	 }  
 * /  
 f u n c t i o n   d e l e t e I t e m ( l i s t N a m e ,   i d )   {  
         v a r   c o n t e n t   =   b u i l d D e l e t e C o n t e n t ( l i s t N a m e ,   i d ) ;  
         v a r   r e s u l t   =   {   s u c c e s s :   f a l s e ,   e r r o r C o d e :   ' ' ,   e r r o r T e x t :   ' i n t e r n a l   e r r o r '   } ;  
         i n n e r P o s t ( w s B a s e U r l   +   ' l i s t s . a s m x ' ,   ' h t t p : / / s c h e m a s . m i c r o s o f t . c o m / s h a r e p o i n t / s o a p / U p d a t e L i s t I t e m s ' ,   c o n t e n t ,   f u n c t i o n ( d a t a )   {  
                 i f   ( $ ( ' E r r o r T e x t ' ,   d a t a ) . l e n g t h   >   0 )   {  
                         r e s u l t . s u c c e s s   =   f a l s e ;  
                         r e s u l t . e r r o r C o d e   =   $ ( ' E r r o r C o d e ' ,   d a t a ) . t e x t ( ) ;  
                         r e s u l t . e r r o r T e x t   =   $ ( ' E r r o r T e x t ' ,   d a t a ) . t e x t ( ) ;  
                 }   e l s e   {  
                         r e s u l t . s u c c e s s   =   t r u e ;  
                         r e s u l t . e r r o r C o d e   =   ' 0 x 0 0 0 0 0 0 0 0 ' ;  
                         r e s u l t . e r r o r T e x t   =   n u l l ;  
                 }  
         } ) ;  
         r e t u r n   r e s u l t ;  
 } 
