home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Beginning Direct3D Game Programming
/
Direct3D.iso
/
directx
/
dxf
/
extras
/
documentation
/
directx7
/
directx7.chm
/
dxmedia
/
foundation
/
d3drm
/
js
/
dynamicload.js
< prev
next >
Wrap
Text File
|
2000-09-22
|
3KB
|
99 lines
public_description = new DataBuffer()
function URLElement(fileName,filePath,dirBack,dirLevel,isValid){
this.fileName = fileName;
this.filePath = filePath;
this.dirBack = dirBack;
this.dirLevel = dirLevel;
this.isValid = isValid;
}
function DataBuffer(){
this.getInnerText = getInnerText;
this.getInnerHTML = getInnerHTML;
}
function getInnerText(sObjID){
if (typeof(ID = eval("window." + sObjID)) != "undefined")
return ID.innerText;
else
return '<FONT COLOR="RED">Text range for <B>sDataID = "' + sObjID + '"</B> was not found!</FONT>';
}
function getInnerHTML(sObjID){
if (typeof(ID = eval("window." + sObjID)) != "undefined")
return ID.innerHTML;
else
return '<FONT COLOR="RED">Text range for <B>sDataID = "' + sObjID + '"</B> was not found!</FONT>';
}
function setHREF(sRoot){
sRoot = sRoot.toLowerCase()
var winLoc = analizePath(window.location.href.toLowerCase(), sRoot);
//Display error message if can't determine project root directory
if (!winLoc.isValid){
alert("This project is expected to reside in a directory named \"" + sRoot +"\" !\nUnable to insert dynamic contents.");
return false;
}
//Restore HREF location for A link objects
var i=0;
var elemLnk = document.links;
for (i=0; i< elemLnk.length; i++){
var lnkPath = analizePath(elemLnk[i].href.toLowerCase(), sRoot);
elemLnk[i].href = winLoc.dirBack + lnkPath.filePath + lnkPath.fileName;
}
//Restore SRC path for IMG image objects
var i=0;
var elemImg = document.images;
for (i=0;i<elemImg.length;i++){
var imgPath = analizePath(elemImg[i].src.toLowerCase(), sRoot);
elemImg[i].src = winLoc.dirBack + imgPath.filePath + imgPath.fileName;
}
return true;
}
function analizePath(sPath, sRoot){
var arrPath = sPath.split("/")
var newObj = new URLElement();
//Init newObj of type URLElement
newObj.fileName = newObj.filePath = newObj.dirBack = "" ;
newObj.isValid = false ; newObj.dirLevel = 0;
//Reverse Path array
arrPath.reverse();
//Get file name, element 0 is now the file name
newObj.fileName = arrPath[0];
//Get all other element values
var i=0;
var len = arrPath.length;
for (i=1;i<len;i++){
//test each array element for the provided root directory
if (arrPath[i]== sRoot){
newObj.isValid = true;
i=len;
}
else if (!newObj.isValid){
newObj.filePath = arrPath[i] + "/" + newObj.filePath;
newObj.dirBack = newObj.dirBack + "../";
newObj.dirLevel++;
}
}
return newObj;
}
//
function window.onload(){
var sRoot = "d3drm" ;
var oFileInfo = analizePath(window.location.href.toLowerCase(), sRoot);
if(oFileInfo.fileName.indexOf("gloss_") == -1){
if (typeof(window.external.frozen) != "undefined") {
if (setHREF(sRoot)) window.external.raiseEvent("evt_DocComplete", window.document);
}
}
}