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