ÿþ/ *  
   *   F C K e d i t o r   -   T h e   t e x t   e d i t o r   f o r   i n t e r n e t  
   *   C o p y r i g h t   ( C )   2 0 0 3 - 2 0 0 5   F r e d e r i c o   C a l d e i r a   K n a b b e n  
   *    
   *   L i c e n s e d   u n d e r   t h e   t e r m s   o f   t h e   G N U   L e s s e r   G e n e r a l   P u b l i c   L i c e n s e :  
   *   	 	 h t t p : / / w w w . o p e n s o u r c e . o r g / l i c e n s e s / l g p l - l i c e n s e . p h p  
   *    
   *   F o r   f u r t h e r   i n f o r m a t i o n   v i s i t :  
   *   	 	 h t t p : / / w w w . f c k e d i t o r . n e t /  
   *    
   *   F i l e   N a m e :   f c k e d i t o r . j s  
   *   	 T h i s   i s   t h e   i n t e g r a t i o n   f i l e   f o r   J a v a S c r i p t .  
   *    
   *   	 I t   d e f i n e s   t h e   F C K e d i t o r   c l a s s   t h a t   c a n   b e   u s e d   t o   c r e a t e   e d i t o r  
   *   	 i n s t a n c e s   i n   a   H T M L   p a g e   i n   t h e   c l i e n t   s i d e .   F o r   s e r v e r   s i d e  
   *   	 o p e r a t i o n s ,   u s e   t h e   s p e c i f i c   i n t e g r a t i o n   s y s t e m .  
   *    
   *   F i l e   A u t h o r s :  
   *   	 	 F r e d e r i c o   C a l d e i r a   K n a b b e n   ( f r e d c k @ f c k e d i t o r . n e t )  
   * /  
  
 / /   F C K e d i t o r   C l a s s  
 v a r   F C K e d i t o r   =   f u n c t i o n (   i n s t a n c e N a m e ,   w i d t h ,   h e i g h t ,   t o o l b a r S e t ,   v a l u e   )  
 {  
 	 / /   P r o p e r t i e s  
 	 t h i s . I n s t a n c e N a m e 	 =   i n s t a n c e N a m e   ;  
 	 t h i s . W i d t h 	 	 	 =   w i d t h 	 	 	 | |   ' 1 0 0 % '   ;  
 	 t h i s . H e i g h t 	 	 	 =   h e i g h t 	 	 | |   ' 2 0 0 '   ;  
 	 t h i s . T o o l b a r S e t 	 	 =   t o o l b a r S e t 	 | |   ' D e f a u l t '   ;  
 	 t h i s . V a l u e 	 	 	 =   v a l u e 	 	 	 | |   ' '   ;  
 	 t h i s . B a s e P a t h 	 	 =   ' / f c k e d i t o r / '   ;  
 	 t h i s . C h e c k B r o w s e r 	 =   t r u e   ;  
 	 t h i s . D i s p l a y E r r o r s 	 =   t r u e   ;  
 	 t h i s . E n a b l e S a f a r i 	 =   f a l s e   ; 	 	 / /   T h i s   i s   a   t e m p o r a r y   p r o p e r t y ,   w h i l e   S a f a r i   s u p p o r t   i s   u n d e r   d e v e l o p m e n t .  
  
 	 t h i s . C o n f i g 	 	 	 =   n e w   O b j e c t ( )   ;  
  
 	 / /   E v e n t s  
 	 t h i s . O n E r r o r 	 	 =   n u l l   ; 	 / /   f u n c t i o n (   s o u r c e ,   e r r o r N u m b e r ,   e r r o r D e s c r i p t i o n   )  
 }  
  
 F C K e d i t o r . p r o t o t y p e . C r e a t e   =   f u n c t i o n ( )  
 {  
 	 / /   C h e c k   f o r   e r r o r s  
 	 i f   (   ! t h i s . I n s t a n c e N a m e   | |   t h i s . I n s t a n c e N a m e . l e n g t h   = =   0   )  
 	 {  
 	 	 t h i s . _ T h r o w E r r o r (   7 0 1 ,   ' Y o u   m u s t   s p e c i f y   a   i n s t a n c e   n a m e . '   )   ;  
 	 	 r e t u r n   ;  
 	 }  
  
 	 d o c u m e n t . w r i t e (   ' < d i v > '   )   ;  
  
 	 i f   (   ! t h i s . C h e c k B r o w s e r   | |   t h i s . _ I s C o m p a t i b l e B r o w s e r ( )   )  
 	 {  
 	 	 d o c u m e n t . w r i t e (   ' < i n p u t   t y p e = " h i d d e n "   i d = " '   +   t h i s . I n s t a n c e N a m e   +   ' "   n a m e = " '   +   t h i s . I n s t a n c e N a m e   +   ' "   v a l u e = " '   +   t h i s . _ H T M L E n c o d e (   t h i s . V a l u e   )   +   ' "   / > '   )   ;  
 	 	 d o c u m e n t . w r i t e (   t h i s . _ G e t C o n f i g H t m l ( )   )   ;  
 	 	 d o c u m e n t . w r i t e (   t h i s . _ G e t I F r a m e H t m l ( )   )   ;  
 	 }  
 	 e l s e  
 	 {  
 	 	 v a r   s W i d t h     =   t h i s . W i d t h . t o S t r i n g ( ) . i n d e x O f ( ' % ' )     >   0   ?   t h i s . W i d t h     :   t h i s . W i d t h     +   ' p x '   ;  
 	 	 v a r   s H e i g h t   =   t h i s . H e i g h t . t o S t r i n g ( ) . i n d e x O f ( ' % ' )   >   0   ?   t h i s . H e i g h t   :   t h i s . H e i g h t   +   ' p x '   ;  
 	 	 d o c u m e n t . w r i t e ( ' < t e x t a r e a   n a m e = " '   +   t h i s . I n s t a n c e N a m e   +   ' "   r o w s = " 4 "   c o l s = " 4 0 "   s t y l e = " W I D T H :   '   +   s W i d t h   +   ' ;   H E I G H T :   '   +   s H e i g h t   +   ' "   w r a p = " v i r t u a l " > '   +   t h i s . _ H T M L E n c o d e (   t h i s . V a l u e   )   +   ' < \ / t e x t a r e a > ' )   ;  
 	 }  
  
 	 d o c u m e n t . w r i t e (   ' < / d i v > '   )   ;  
 }  
  
 F C K e d i t o r . p r o t o t y p e . R e p l a c e T e x t a r e a   =   f u n c t i o n ( )  
 {  
 	 i f   (   ! t h i s . C h e c k B r o w s e r   | |   t h i s . _ I s C o m p a t i b l e B r o w s e r ( )   )  
 	 {  
 	 	 v a r   o T e x t a r e a   =   d o c u m e n t . g e t E l e m e n t B y I d (   t h i s . I n s t a n c e N a m e   )   ;  
 	 	  
 	 	 i f   (   ! o T e x t a r e a   )  
 	 	 	 o T e x t a r e a   =   d o c u m e n t . g e t E l e m e n t s B y N a m e (   t h i s . I n s t a n c e N a m e   ) [ 0 ]   ;  
 	 	  
 	 	 i f   (   ! o T e x t a r e a   | |   o T e x t a r e a . t a g N a m e   ! =   ' T E X T A R E A '   )  
 	 	 {  
 	 	 	 a l e r t (   ' E r r o r :   T h e   T E X T A R E A   i d   " '   +   t h i s . I n s t a n c e N a m e   +   ' "   w a s   n o t   f o u n d '   )   ;  
 	 	 	 r e t u r n   ;  
 	 	 }  
  
 	 	 o T e x t a r e a . s t y l e . d i s p l a y   =   ' n o n e '   ;  
 	 	 t h i s . _ I n s e r t H t m l B e f o r e (   t h i s . _ G e t C o n f i g H t m l ( ) ,   o T e x t a r e a   )   ;  
 	 	 t h i s . _ I n s e r t H t m l B e f o r e (   t h i s . _ G e t I F r a m e H t m l ( ) ,   o T e x t a r e a   )   ;  
 	 }  
 }  
  
 F C K e d i t o r . p r o t o t y p e . _ I n s e r t H t m l B e f o r e   =   f u n c t i o n (   h t m l ,   e l e m e n t   )  
 {  
 	 i f   (   e l e m e n t . i n s e r t A d j a c e n t H T M L   ) 	 / /   I E  
 	 	 e l e m e n t . i n s e r t A d j a c e n t H T M L (   ' b e f o r e B e g i n ' ,   h t m l   )   ;  
 	 e l s e 	 	 	 	 	 	 	 	 / /   G e c k o  
 	 {  
 	 	 v a r   o R a n g e   =   d o c u m e n t . c r e a t e R a n g e ( )   ;  
 	 	 o R a n g e . s e t S t a r t B e f o r e (   e l e m e n t   )   ;  
 	 	 v a r   o F r a g m e n t   =   o R a n g e . c r e a t e C o n t e x t u a l F r a g m e n t (   h t m l   ) ;  
 	 	 e l e m e n t . p a r e n t N o d e . i n s e r t B e f o r e (   o F r a g m e n t ,   e l e m e n t   )   ;  
 	 }  
 }  
  
 F C K e d i t o r . p r o t o t y p e . _ G e t C o n f i g H t m l   =   f u n c t i o n ( )  
 {  
 	 v a r   s C o n f i g   =   ' '   ;  
 	 f o r   (   v a r   o   i n   t h i s . C o n f i g   )  
 	 {  
 	 	 i f   (   s C o n f i g . l e n g t h   >   0   )   s C o n f i g   + =   ' & a m p ; '   ;  
 	 	 s C o n f i g   + =   e s c a p e ( o )   +   ' = '   +   e s c a p e (   t h i s . C o n f i g [ o ]   )   ;  
 	 }  
  
 	 r e t u r n   ' < i n p u t   t y p e = " h i d d e n "   i d = " '   +   t h i s . I n s t a n c e N a m e   +   ' _ _ _ C o n f i g "   v a l u e = " '   +   s C o n f i g   +   ' "   / > '   ;  
 }  
  
 F C K e d i t o r . p r o t o t y p e . _ G e t I F r a m e H t m l   =   f u n c t i o n ( )  
 {  
 	 v a r   s L i n k   =   t h i s . B a s e P a t h   +   ' e d i t o r / f c k e d i t o r . h t m l ? I n s t a n c e N a m e = '   +   t h i s . I n s t a n c e N a m e   ;  
 	 i f   ( t h i s . T o o l b a r S e t )   s L i n k   + =   ' & T o o l b a r = '   +   t h i s . T o o l b a r S e t   ;  
  
 	 r e t u r n   ' < i f r a m e   i d = " '   +   t h i s . I n s t a n c e N a m e   +   ' _ _ _ F r a m e "   s r c = " '   +   s L i n k   +   ' "   w i d t h = " '   +   t h i s . W i d t h   +   ' "   h e i g h t = " '   +   t h i s . H e i g h t   +   ' "   f r a m e b o r d e r = " n o "   s c r o l l i n g = " n o " > < / i f r a m e > '   ;  
 }  
  
 F C K e d i t o r . p r o t o t y p e . _ I s C o m p a t i b l e B r o w s e r   =   f u n c t i o n ( )  
 {  
 	 v a r   s A g e n t   =   n a v i g a t o r . u s e r A g e n t . t o L o w e r C a s e ( )   ;  
  
 	 / /   I n t e r n e t   E x p l o r e r  
 	 i f   (   s A g e n t . i n d e x O f ( " m s i e " )   ! =   - 1   & &   s A g e n t . i n d e x O f ( " m a c " )   = =   - 1   & &   s A g e n t . i n d e x O f ( " o p e r a " )   = =   - 1   )  
 	 {  
 	 	 v a r   s B r o w s e r V e r s i o n   =   n a v i g a t o r . a p p V e r s i o n . m a t c h ( / M S I E   ( . \ . . ) / ) [ 1 ]   ;  
 	 	 r e t u r n   (   s B r o w s e r V e r s i o n   > =   5 . 5   )   ;  
 	 }  
 	 / /   G e c k o  
 	 e l s e   i f   (   n a v i g a t o r . p r o d u c t   = =   " G e c k o "   & &   n a v i g a t o r . p r o d u c t S u b   > =   2 0 0 3 0 2 1 0   )  
 	 	 r e t u r n   t r u e   ;  
 	 / /   S a f a r i  
 	 e l s e   i f   (   t h i s . E n a b l e S a f a r i   & &   s A g e n t . i n d e x O f (   ' s a f a r i '   )   ! =   - 1   )  
 	 	 r e t u r n   (   s A g e n t . m a t c h (   / s a f a r i \ / ( \ d + ) /   ) [ 1 ]   > =   3 1 2   )   ; 	 / /   B u i l d   m u s t   b e   a t   l e a s t   3 1 2   ( 1 . 3 )  
 	 e l s e  
 	 	 r e t u r n   f a l s e   ;  
 }  
  
 F C K e d i t o r . p r o t o t y p e . _ T h r o w E r r o r   =   f u n c t i o n (   e r r o r N u m b e r ,   e r r o r D e s c r i p t i o n   )  
 {  
 	 t h i s . E r r o r N u m b e r 	 	 =   e r r o r N u m b e r   ;  
 	 t h i s . E r r o r D e s c r i p t i o n 	 =   e r r o r D e s c r i p t i o n   ;  
  
 	 i f   (   t h i s . D i s p l a y E r r o r s   )  
 	 {  
 	 	 d o c u m e n t . w r i t e (   ' < d i v   s t y l e = " C O L O R :   # f f 0 0 0 0 " > '   )   ;  
 	 	 d o c u m e n t . w r i t e (   ' [   F C K e d i t o r   E r r o r   '   +   t h i s . E r r o r N u m b e r   +   ' :   '   +   t h i s . E r r o r D e s c r i p t i o n   +   '   ] '   )   ;  
 	 	 d o c u m e n t . w r i t e (   ' < / d i v > '   )   ;  
 	 }  
  
 	 i f   (   t y p e o f (   t h i s . O n E r r o r   )   = =   ' f u n c t i o n '   )  
 	 	 t h i s . O n E r r o r (   t h i s ,   e r r o r N u m b e r ,   e r r o r D e s c r i p t i o n   )   ;  
 }  
  
 F C K e d i t o r . p r o t o t y p e . _ H T M L E n c o d e   =   f u n c t i o n ( t e x t )   {  
         i f   ( t y p e o f   ( t e x t )   ! =   " s t r i n g " )  
                 t e x t   =   t e x t . t o S t r i n g ( ) ;  
  
         t e x t   =   t e x t . r e p l a c e ( / È / g ,   " " ) ;  
         t e x t   =   t e x t . r e p l a c e ( / ð / g ,   " " ) ;  
         t e x t   =   t e x t . r e p l a c e ( / Æ / g ,   " " ) ;  
         t e x t   =   t e x t . r e p l a c e ( / è / g ,   " " ) ;  
         t e x t   =   t e x t . r e p l a c e ( / æ / g ,   " " ) ;  
         t e x t   =   t e x t . r e p l a c e ( / & / g ,   " & a m p ; " ) ;  
         t e x t   =   t e x t . r e p l a c e ( / " / g ,   " & q u o t ; " ) ;  
         t e x t   =   t e x t . r e p l a c e ( / < / g ,   " & l t ; " ) ;  
         t e x t   =   t e x t . r e p l a c e ( / > / g ,   " & g t ; " ) ;  
         t e x t   =   t e x t . r e p l a c e ( / ' / g ,   " & # 3 9 ; " ) ;  
  
         r e t u r n   t e x t ;  
 } 
