home *** CD-ROM | disk | FTP | other *** search
- // navbar.js
- // (Global variables are declared in slide.js.)
- // Display previous/next slide in sequence, or goto other slide.
-
- // 30 July 97: rewrite to use top instead of parent so that these functions
- // can be called from within index.htm and notes.htm too [enabling those
- // documents to do an onload="goto_slide(1, true)" ]
-
- // By default, filenames are relative to inside of basefile directory,
- // so when loading HTML slide page files from main directory,
- // we prefix "../" to the filename. However, the onload event handler
- // for documents index.htm and notes.htm must also call this function
- // to load the first page; those documents are in the main directory,
- // so we prefix "" to the filename.
-
- function
- goto_slide(slide_num, caller_in_main_directory)
- { var filename_prefix = ""
- if (caller_in_main_directory == null) { filename_prefix = "../" }
- if(slide_num < 1 || slide_num > top.last_slide){
- alert("Please enter number between 1 and " + top.last_slide);
- }
- else {
- top.current_slide = Math.abs(slide_num);
- top.frames["slide"].location = filename_prefix + top.filename[slide_num];
- // update displayed page count in goto field
- top.frames["next"].document.forms["gotoform"].slidenum.value = top.current_slide;
- }
- }
-
- function
- prev_slide()
- {
- if(top.current_slide == 1){
- alert("You are already at the first slide.\nThere is no previous slide.");
- }
- else goto_slide(top.current_slide - 1);
- }
-
-
- // Display next slide in sequence.
- function
- next_slide()
- {
-
- if (top.current_slide == top.last_slide){
- alert("You are already at the last slide.\nThere is no next slide.");
- } else goto_slide(top.current_slide + 1);
- }
-
-
- function
- goto_slide(slide_num, caller_in_main_directory)
- { var filename_prefix = ""
- if (caller_in_main_directory == null) { filename_prefix = "../" }
- if(slide_num < 1 || slide_num > top.last_slide){
- alert("Please enter number between 1 and " + top.last_slide);
- }
- else {
- top.current_slide = Math.abs(slide_num);
- top.frames["slide"].location = filename_prefix + top.filename[slide_num];
- // update displayed page count in goto field
- top.frames["next"].document.forms["gotoform"].slidenum.value = top.current_slide;
- }
- }
-
- function
- prev_slide(caller_in_main_directory)
- {
- if(top.current_slide == 1){
- alert("You are already at the first slide.\nThere is no previous slide.");
- }
- else goto_slide(top.current_slide - 1, caller_in_main_directory);
- }
-
-
- // Display next slide in sequence.
- function
- next_slide(caller_in_main_directory)
- {
-
- if (top.current_slide == top.last_slide){
- alert("You are already at the last slide.\nThere is no next slide.");
- } else goto_slide(top.current_slide + 1, caller_in_main_directory);
- }
-
-
-
- // KEYBOARD CONTROL IN NAV4
-
- // *** NOTE: SUBTLE DIFFERENCE BETWEEN THIS CODE AND CODE IN style.js ***
- // Here, we do not pass parameter true to next_slide and prev_slide.
-
- // support SPACE key codes (*not* RETURN because of Goto field!)
- var nextKeys = new String("nN ")
- var prevKeys = new String("pP")
-
-
- function handleKeys(e) {
- var keyChar = String.fromCharCode(e.which);
- if (prevKeys.indexOf(keyChar) != -1)
- { prev_slide(); return false }
- else if(nextKeys.indexOf(keyChar) != -1)
- { next_slide(); return false }
- else return true;
- }
-
-
-
- // Workaround for Nav3.x bug in which JavaScript files
- // with <SCRIPT LANGUAGE="JavaScript1.2" SRC=...> are
- // loaded, even though they should be ignored.
- // Make sure this code is only executed by 4.x and later.
- if (parseInt(navigator.appVersion) > 3) {
-
- // support ESC key code (*not* BS because of Goto field!)
- prevKeys.concat(String.fromCharCode(27))
- document.captureEvents(Event.KEYPRESS);
- document.onkeypress = handleKeys;
-
- } // end of Nav4+ only if
-
-