Go to:  Davar site entry | Site contents | Site index | Internet | JavaScript | Text bottom

Extract  Navigation  Bar  Generation  JavaScript

NAVIGATE JavaScript (stand-alone) is a function that generates and returns two lines representing extract navigation bar that permits along with navigating site hierarchy to switch between two languages (English and Russian) and to switch from single language to double language browsing.  (There's more to the double language presentation than the navigation bar, but that's a separate topic.) 

Development of NAVIGATE JavaScript was prompted by the problem arising from double language navigation (in two vertical half-screen frames).  Once the text goes into the frame the only legitimate navigation within it is switching between Top and Bottom you don't want switching within the half screen frame to pages designed for the full screen that will lead to the unreadable mess.  The obvious solution was to have two copies of the same text for full and split screen browsing that differ in the navigation bars only.  That's not a big trouble once you've got a good text editor, and I was using this approach for several years.

But as time goes on and you read the extract over and over again, you start to notice mistakes in your texts that slipped through all your proofreading efforts and were not caught by the spelling checker.  Necessity to correct those mistakes in two texts and to have them synchronized is quite annoying.  The desire to avoid this anointment was driving the development of the NAVIGATE JavaScript, which (by making the navigation bar adaptable to the current environment) permits to maintain only one copy of text that is used both for full and split screen browsing.

Script gets control information from three sources: function arguments (navigation bar position top or bottom and additional navigation data), URL of the calling HTML (path to the file is used to derive text type), and URL parameter of the calling HTML (defines text presentation type full or split screen.  This control information drives generation of HTML code for appropriate navigation bar that is concatenated into one line that is returned to the calling HTML where it gets displayed by the browser using document.write.

NAVIGATE JavaScript is a stand-alone one, which means that it's kept in a separate NAVIGATE.JS file, that gets included into HTML <HEAD> (normally at its end) using the following operator (directory levelling may vary):


       <SCRIPT LANGUAGE=JavaScript SRC=../../NAVIGATE.JS></SCRIPT>
     
Included function is used in the <BODY> of HTML to display two lines of hyperlinks in a way similar to the following:

       <CENTER>
         <SCRIPT LANGUAGE=JavaScript>
           <!--
             document.write(NAVIGATE())
           //-->
         </SCRIPT>
       </CENTER>
     
The code above gets displayed below by the browser as two lines of hyperlinks to other pages on the web site (the nature of defaults used makes function "think" that it is invoked here from the top of the Russian miscellaneous extract).

It's obvious that in order for these hyperlinks to be useful, corresponding site pages should be predefined.  (Please don't try hyperlinks here they won't work, because this text is not an extract for which this function is designed; you can view Pilate fiction extract as a working example).



<!-- Extract Navigation Bar Generation  10/03/200110/24/2001 -->
<!-- --------------------------------------------- 10/17/2001 -->
<!-- www.davar.net/NAVIGATE.JS                                -->
<!-- Copyright (C) 2001 by Vladimir Veytsel                   -->
<!--

// Generates extract navigation bar being adjusted to the context
// of bilingual extract presentation (English-Russian) that provides
// switching between languages as well as switching to split screen
// double text browse.  Its purpose is not a navigation bar shorthand
// (this can provide only a minuscule gain), but the ability to make
// navigation bar dynamic, which makes it possible to use the same
// text both for full and split screen presentations.  This permits
// to avoid otherwise necessary support of two almost identical text
// copies (one for full and another for split screen) that differ only
// in their navigation bars.

// Function arguments:
// 1. Navigation bar position
//    T  - Top    of the text (default)
//    B  - Bottom of the text
// 2. Additional navigation data that shows, if specified, on Full screen only.
//    Precede with " <FONT COLOR=Green>|</FONT> " to continue on the second
//    line (enclosing spaces are necessary), or precede with "<BR>" to start
//    the new navigation bar line.

// Other control data (obtained from current "location" value):
// Type - Text presentation type (first character of the URL parameter value)
//   F  - Full  screen text presentation (default)
//   S  - Split screen text presentation
// Name - Text file name
// Name of split screen control text is derived from file name by appending
// "&" at its end, or substituting 8-th character for "&".

// The returned value is the HTML code for the appropriate navigation bar.

   function NAVIGATE()
            {Pos="T"
             if (arguments.length>0)
                Pos=arguments[0]

             Type=location.search.substr(1,1)

             Path=location.pathname.split("/")
             File=Path[Path.length-1].split(".")
             Name=File[0]

             if (Name.length<8)
                Name_S=Name+"&"
             else
                Name_S=Name.substr(0,7)+"&"

             if (Type=="S")
                if (Pos=="T")
                   {Bar=    "Use [<FONT COLOR=Red>Back</FONT>] button to return to the original text<BR>"
                    Bar=Bar+"<FONT COLOR=Green>Go to</FONT> <A HREF='#Bottom'>Text bottom</A>"
                   }
                else
                   {Bar=    "<FONT COLOR=Green>Go to</FONT> <A HREF='#Top'>Text top</A><BR>"
                    Bar=Bar+"Use [<FONT COLOR=Red>Back</FONT>] button to return to the original text"
                   }
             else
                {Bar=    "<FONT COLOR=Green>Go to:</FONT>  <A HREF='../../index.htm'>Davar site entry</A> "
                 Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='../../CNT.HTM'>Site contents</A> "
                 Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='../../IND.HTM'>Site index</A> "
                 if (location.pathname.indexOf("EXTRACTS")>=0)
                    {Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='../EXTRACTS.HTM'>Extracts</A> "
                     if (location.pathname.indexOf("FICTION")>=0)
                        Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='FICTION.HTM'>Fiction extracts</A> "
                     else
                        Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='MISCL.HTM'>Miscl extracts</A> "
                    }
                 else
                    {Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='../RUSSIAN.HTM'>Russian</A> "
                     if (location.pathname.indexOf("FICTION")>=0)
                        Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='FICTION.HTM'>Russian fiction</A> "
                     else
                        Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='MISCL.HTM'>Miscl Russian</A> "
                    }
                 if (Pos=="T")
                    Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='#Bottom'>Text bottom</A>"
                 else
                    Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='#Top'>Text top</A>"
                 if (location.pathname.indexOf("EXTRACTS")>=0)
                    {Bar=Bar+"<BR></FONT> <A HREF='"+Name_S+".HTM'>English and Russian texts</A> "
                     if (location.pathname.indexOf("FICTION")>=0)
                        Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='../../RUSSIAN/FICTION/"+Name+".HTM'>Russian text</A>"
                     else
                        Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='../../RUSSIAN/MISCL/"+Name+".HTM'>Russian text</A>"
                    }
                 else
                    {Bar=Bar+"<BR></FONT> <A HREF='"+Name_S+".HTM'>Russian and English texts</A> "
                     if (location.pathname.indexOf("FICTION")>=0)
                        Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='../../EXTRACTS/FICTION/"+Name+".HTM'>English text</A>"
                     else
                        Bar=Bar+"<FONT COLOR=Green>|</FONT> <A HREF='../../EXTRACTS/MISCL/"+Name+".HTM'>English text</A>"
                    }
                 if (arguments.length>1)
                    Bar=Bar+arguments[1]
                }
             return Bar
            }
//-->
  

Since NAVIGATE JavaScript is designed for bilingual navigation within extracts and contains in itself code that dynamically adjusts to the current environment, it is impossible to have a navigation example from within this page.  Instead please go to Pilate fiction extract page and switch between the languages and from single text to double text browse mode and back.  Watch in the process of switching how navigation bars at text top and bottom get adjusted according to the current browsing context.  NAVIGATE function is used to generate adaptable navigation bars both for English and for Russian texts.


View Pilate fiction extract page       View [and save] NAVIGATE.TXT text
(Use [Back] button or [Alt]+[CL] to return here from the viewed page/text)
To make text executable rename it to *.JS and make a global change of "&lt;" into "<" signs.
Copyright © 2001 by
Go to:  Davar site entry | Site contents | Site index | Internet | JavaScript | Text top