\n";
}
}
}
//Given the original function call, this parses out the args and updates
//the UI. Loops through each imgObj,imgSrc pair.
//If imgObj already present in menu, stuff imgSrc in imgSrcArray. If imgObj
//doesn't exist, add to menu, and extend imgSrcArray.
function inspectBehavior(behFnCallStr){
var argArray,imgSrcArray,found,numImgs,i,imgObj,imgSrc,j,imgObjNum;
argArray = extractArgs(behFnCallStr);//get new list of imgObj,imgSrc pairs
imgSrcArray = document.MM_myImgSrcs; //get the prior list of imgSrcs
numImgs = document.MM_NS_REFS.length;
for (i=1; i<(argArray.length-2); i+=3){ //with each imgObj,imgSrc pair
imgObj=argArray[i];
imgSrc=unescape(argArray[i+2]);
found = false;
for (j=0; j i) document.theForm.preload.checked = true; //if preload, check box
document.MM_myImgSrcs = imgSrcArray; //save updated imageSrc list
displayImgSrc(); //load the imageSrc for selected image
}
//Used to improve performance, this hardcodes the expected window size. Without
//this fn, or if WINDOWSIZE_Autosize is false, DW will render the UI dynamically.
//IMPORTANT: for internationalization and other UI changes, update the globals.
function WindowDimensions(platform) {
if (!WINDOWSIZE_Autosize) {
if (platform.charAt(0) == "m" || platform.charAt(0) == "M") //if Mac
return WINDOWSIZE_Mac;
else //else Windows 95 or NT
return WINDOWSIZE_Win;
}
}
//***************** LOCAL FUNCTIONS ******************
//Load the select menu with image names.
//Also sets the global property MM_myImgSrcs to the right num of items.
function initializeUI(){
var nameArray, i, imgSrcArray = new Array(); //start global list
var count, copyArray = new Array(); //used to remove unnamed images
document.MM_NS_REFS = getObjectRefs("NS 4.0","document","IMG"); //store parallel NS refs
document.MM_IE_REFS = getObjectRefs("IE 4.0","document","IMG"); //store parallel IE refs
count=0; //search for and removed unnamed images.
for (i=0;i < document.MM_NS_REFS;i++){
if (UNUSABLE_REF != document.MM_NS_REFS[i])
copyArray[count++] = document.MM_NS_REFS[i];
}
document.MM_NS_REFS = copyArray;
count=0; //search for and removed unnamed images.
copyArray = new Array();
for (i=0;i < document.MM_IE_REFS;i++){
if (UNUSABLE_REF != document.MM_IE_REFS[i])
copyArray[count++] = document.MM_IE_REFS[i];
}
document.MM_IE_REFS = copyArray;
nameArray = niceNames(document.MM_NS_REFS,TYPE_Image);
for (i=0; i 0 && theStr.charAt(lastPos) == "'")
argArray[i] = theStr.substring(1,lastPos);
}
return argArray
}
//Given a string "myObject *" returns "myObject *".
function stripStar(theStr) {
var endPos;
endPos = theStr.indexOf(' *');
return ((endPos > 0)? theStr.substring(0,endPos) : theStr);
}
//Given theSelect obj and an index, it appends a star
//and inserts the new string into the menu at position index.
//If the menu item was "layer[2]" it becomes "layer[2] *".
//Existing " *" values get stripped off first.
function addStarToMenuItem(theSelect,menuIndex) {
var newMenuText;
newMenuText = stripStar(theSelect.options[menuIndex].text); //remove if old star
newMenuText += " *"; //append " *"
theSelect.options[menuIndex]=new Option(newMenuText); //add new line to menu
}
//Passed a string, finds special chars '"\ and escapes them with \
function escQuotes(theStr){
var i, theChar, escStr = "";
for(var i=0; i 1) {
niceRef = objTypeStr + ' ' + nameReduce(tokens[0]); //start building str, ie: image "foo"
if (tokens.length > 2) { //reference includes some nesting...
if (tokens[1] != "document") //inside a form so add form reference
niceRef += ' ' + TYPE_Separator + ' ' + TYPE_Form + ' ' + nameReduce(tokens[1]);
for (j=1; j "myImg"
// layers['foo'] => "foo"
// embeds[0] => 0
// myImg[2] => "myImg[2]"
function nameReduce (objName) {
var retVal, arrayTokens;
retVal = '"' + objName + '"'; //default is object wrapped in quotes
if (objName.indexOf("[") > 0) { //if it's an array
arrayTokens = getTokens(objName,"[]\"'"); //break up tokens
if (arrayTokens.length == 2) { //if exactly two tokens
if ("layers forms embeds links anchors all".indexOf(arrayTokens[0]) != -1) { //if legal
if (arrayTokens[1] == ""+parseInt(arrayTokens[1])) //if a number
retVal = arrayTokens[1];
else //else it's a string
retVal = '"' + arrayTokens[1] + '"';
}
}
}
return retVal;
}
//Emulates printf("blah blah %s blah %s",str1,str2)
//Used for concatenating error message for easier localization.
//Returns assembled string.
function errMsg() {
var i,numArgs,errStr="",argNum=0,startPos;
numArgs = errMsg.arguments.length;
if (numArgs) {
theStr = errMsg.arguments[argNum++];
startPos = 0; endPos = theStr.indexOf("%s",startPos);
if (endPos == -1) endPos = theStr.length;
while (startPos < theStr.length) {
errStr += theStr.substring(startPos,endPos);
if (argNum < numArgs) errStr += errMsg.arguments[argNum++];
startPos = endPos+2; endPos = theStr.indexOf("%s",startPos);
if (endPos == -1) endPos = theStr.length;
}
if (!errStr) errStr = errMsg.arguments[0];
}
return errStr;
}
//*************** END OF JAVASCRIPT *****************
behavior "Swap Image"