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