You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.3 KiB

  1. //*==============================================================================
  2. //* Helpware NavScript.js 1.01
  3. //* Copyright (c) 2008, Robert Chandler, The Helpware Group
  4. //* http://helpware.net/FAR/
  5. //* support@helpware.net
  6. //* Descriptions:
  7. //* Adds a Open Navigation link at page top if nav is currently not open
  8. //* or inside a CHM.
  9. //* Usage: Anyone may use and modify this file. If you modify it then
  10. //* please change its name and acknowledge my work in your (c) statement.
  11. //* Email me your changes if you think that others could benefit too.
  12. //*==============================================================================
  13. //* 10-June-2008: 1.00 RWC - Original Version
  14. //* 11-July-2008: 1.01 RWC - Now detects if inside CHM Help file. IsInsideChm()
  15. //*
  16. function GetTest() {
  17. alert( window.location );
  18. }
  19. function WriteOpenNavLink(navLink) {
  20. var ss = '<div style="font-family: Verdana; font-size: 80%;color: #333333; margin:0px 0px 0px 0px; padding:0px 0px 0px 0px;">'
  21. +'<a href="'+navLink+'" style="padding:0px 5px 0px 5px;">&lt; Table Of Contents</a>'
  22. +'</div>';
  23. document.write(ss);
  24. }
  25. function IsNavOpen() {
  26. if ((top.right == null) || (top.right == undefined) || (top.right.location == null) || (top.right.location == undefined) || (typeof(top.right.location.href) != "string") || (top.right.location.href == ""))
  27. return false; //no nav found
  28. else
  29. return true; //nav found
  30. }
  31. function IsInsideChm() { //returns true if current file is inside a CHM Help File
  32. var ra = /::/;
  33. return (location.href.search(ra) > 0); //If found then then we are in a CHM
  34. }
  35. // pass in the directory level. 0 = if this HTML is same level as hh_goto.hh; 1 = of one level down etc
  36. function WriteNavLink(aDirLevel) {
  37. if ((!IsNavOpen()) && (!IsInsideChm()))
  38. {
  39. var prefix = "";
  40. for (var n=0; n < aDirLevel; n++)
  41. prefix = prefix + "../";
  42. //find last back slash in path
  43. var x = location.href.lastIndexOf("/"); // get last splash of "path/dir/name.htm"
  44. for (var n=0; n < aDirLevel; n++)
  45. x = location.href.lastIndexOf("/", x-1); // get 2nd last slash etc
  46. var curFileName = location.href.substr(x+1);
  47. var navLink = prefix + "hh_goto.htm#" + curFileName
  48. WriteOpenNavLink(navLink);
  49. }
  50. }