// This is the pathname manager who keeps track of where you are // and writes the html for the path. // Ex: home:unit1:chapter4:concept3 (or explore2, etc.) function PathMan() { this.unit = 0; this.chap = 0; this.misc = 0; this.ie = false; this.mac = false; this.browserVersion = 0; this.whereAreWe = ""; this.linkRegEx = /\{\{!linkPath!\}\}/ig; this.imageRegEx = /\{\{!imagePath!\}\}/ig; this.rootURL = ""; // add the functions to the object this.writePath = writePath; this.getPathHTML = getPathHTML; this.handlePathClick = handlePathClick; this.reset = reset; this.register = register; this.refreshPathFrame = refreshPathFrame; this.getStepperHTML = getStepperHTML; this.setImageAndLinkPath = setImageAndLinkPath; this.changeImages = changeImages; this.setSnifferVariables = setSnifferVariables; this.mGetCurChap = mGetCurChap; this.mGetCurUnit = mGetCurUnit; this.mHandleNextConceptClick = mHandleNextConceptClick; this.mHandleArrowClick = mHandleArrowClick; this.mGetCurConceptNum = mGetCurConceptNum; this.mHandleStepNumClick = mHandleStepNumClick; this.getBrowserVersion = getBrowserVersion; this.getAbsolutePath = getAbsolutePath; this.setSnifferVariables(); this.rootURL = this.getAbsolutePath("index.html"); //Abs path to site's root } function setSnifferVariables() { var agt = navigator.userAgent.toLowerCase(); this.ie = (agt.indexOf("msie") != -1) this.mac = (agt.indexOf("mac") != -1) this.browserVersion = this.getBrowserVersion(); } //Detect browser major version for both MSIE and Navigator. //xsType = {'major', 'minor'} function getBrowserVersion(xsType) { var version = 0; var searchString = "msie"; var versionStr = navigator.appVersion.toLowerCase(); var index = versionStr.indexOf(searchString); if (index >= 0) { var str = versionStr.slice(index); str = str.slice(searchString.length); if (xsType == "major") { version = parseInt(str); } else { version = parseFloat(str); } } else { if (xsType == "major") { version = parseInt(versionStr); } else { version = parseFloat(versionStr); } } return version; } // change the image xsImageName to the xsImageSrc // THIS CAN ONLY BE USED IN THE SUBTOOLBAR FOR MISC PAGES BECAUSE OF THE PATH NAME function changeImages(xsImageName, xsImageSrc) { top.subtoolbar.document.images[xsImageName].src = xsImageSrc; } // called from each content page to reload the subtoolbar. // The path stuff is needed because of IE treats the path as where this object was created, // while other browsers from the page calling this function. // Each content page is ASSUMED to be "index.html" function refreshPathFrame() { var vsSubtoolbarLoc = "toolbar/subtoolbars/subtoolbarpath.html"; if(this.ie) { // for ie top.subtoolbar.document.location = vsSubtoolbarLoc; } else { var vsDocumentLoc = this.getAbsolutePath("index.html"); vsDocumentLoc = vsDocumentLoc + vsSubtoolbarLoc; top.subtoolbar.document.location.href = vsDocumentLoc; } } function getAbsolutePath(xsFile) { var vsDocumentLoc = new String(document.location); var viLastLetter = vsDocumentLoc.indexOf(xsFile); // if the URL is missing the filename then you have the path already or the filename doesn't exist if(viLastLetter != -1) { vsDocumentLoc = vsDocumentLoc.substring(0,viLastLetter); } return vsDocumentLoc; } function reset() { this.unit = 0; this.chap = 0; this.misc = 0; } function register(xsWhich, xiArg1, xiArg2, xiArg3) { // reset all variables so that when going up heirarchy, all is clear this.unit = ""; this.chap = ""; this.misc = ""; this.whereAreWe = xsWhich; switch (xsWhich) { case "unit": this.unit = xiArg1; break; case "chap": this.unit = xiArg1; this.chap = xiArg2; break; case "misc": this.unit = xiArg1; this.chap = xiArg2; this.misc = xiArg3; break; } } //////////////////////////////////////////////////////////////////////////////// // // PATHNAME FUNCTIONS // //////////////////////////////////////////////////////////////////////////////// // called from all of the pages that need the pathman // if the parameter is anything at all, it writes to activities // otherwise to maincontent // xsWhere = "unit", "chap", "misc" function writePath() { var vsHTML = this.getPathHTML(); vsHTML = this.setImageAndLinkPath(vsHTML); // replace the {{!imagePath!}} and {{!linkPath!}} top.subtoolbar.document.open(); top.subtoolbar.document.write(vsHTML); top.subtoolbar.document.close(); } // write out the path function getPathHTML() { var vsSeparator = " > "; var vsHTML = ""; // written no matter what vsHTML = vsHTML + "
| Contents"; vsHTML = vsHTML + vsSeparator; // if chap, then write the unit link, otherwise, we are at a unit home page if(this.chap) { vsHTML = vsHTML + "Unit " + this.unit + ""; // now check for misc to see if we are on a chapter home page if(this.misc) { // not on chapter home page, cuz there is a misc. vsHTML = vsHTML + vsSeparator; vsHTML = vsHTML + "Chapter " + this.chap + ""; vsHTML = vsHTML + vsSeparator; vsHTML = vsHTML + "" + this.misc + " | "; vsHTML = vsHTML + this.getStepperHTML(); vsHTML = vsHTML + "
" + vsCloseLinkTag + "
";
} else {
// if more or less than cur page write the link for the roll
vsHTML = vsHTML + "
";
}
// close off the cell
if(i==viTotalMiscPages) {
vsHTML = vsHTML + "
" + vsCloseLinkTag + "
" + vsCloseLinkTag + "
";
} else {
// if more or less than cur page write the link for the roll
vsHTML = vsHTML + "
";
}
// close off the cell
if(i==viTotalMiscPages) {
vsHTML = vsHTML + "
" + vsCloseLinkTag + "