home *** CD-ROM | disk | FTP | other *** search
-
- //form field names:
- //fileURL - text field where URL appears
- //Delay - form field for delay number
- //Action - radio buttons: radioURL is Go To another document
- // radioThisDoc is stay at current document
-
- // *********** GLOBAL VARS *****************************
-
- var helpDoc = "html/204.creatingdocuments.fm24.html";
-
- // ******************** API ****************************
- function canInspectSelection(){
-
- var metaObj = getSelectedObj();
- return (metaObj.tagName && metaObj.tagName=="META" &&
- metaObj.getAttribute("http-equiv") &&
- metaObj.getAttribute("http-equiv").toLowerCase()=="refresh");
-
- }
-
- function inspectSelection(){
- var refreshObj = getSelectedObj()
- var tagContent = refreshObj.getAttribute("content");
- var Delay = findObject("Delay");
- var radioURL = findObject("radioURL");var radioThisDoc = findObject("radioThisDoc");
- var contentArray;
-
-
- //fill in PI form fields
- //check to see if the refresh applies to the current document by doing
- // an integer check - URL will have a ;
- if (tagContent == parseInt(tagContent)){
- //fill in the Delay value and check the correct radio button:
- Delay.value = tagContent;
- radioThisDoc.checked = true; radioURL.checked = false;
- } else { // else refresh is used to go to another document
- contentArray = getTokens(tagContent,";"); //create 2-member array
- //fill in the Delay value
- Delay.value = (parseInt(contentArray[0])==contentArray[0])?contentArray[0]:"";
- //check correct radio button:
- radioURL.checked = true; radioThisDoc.checked = false;
- //strip "URL=" before placing into PI
- if (contentArray[1] && contentArray[1].indexOf("URL=")==0)
- contentArray[1] = contentArray[1].substring(4);
- //fill in correct URL value
- if (contentArray[1])
- findObject("fileURL").value = contentArray[1];
- else
- findObject("fileURL").value="";
- }
- }
-
-
- // ******************** LOCAL FUNCTIONS ****************************
-
- function clearField(){
- findObject("fileURL").value="";
-
- }
-
- function setMetaTag(whichButton){
- //if whichButton is 0, go to URL just checked. If 1, refresh this doc just checked
- //if 2, this function called from a form field other than a checkbox
- var fileName="",refreshContent="";
- var radioURL = findObject("radioURL");
- var radioThisDoc = findObject("radioThisDoc");
- var fileURL = findObject("fileURL");
- var Delay = findObject("Delay");
- var refreshDelay = (parseInt(Delay.value) == Delay.value)?Delay.value:"";
-
- if (whichButton == 0 || (whichButton == 2 && radioURL.checked && !radioThisDoc.checked)){
- //if going to another doc
- fileName=(fileURL.value)?fileURL.value:"";
- refreshContent=refreshDelay + ";URL=" + fileName;
- //set checkboxes correctly
- radioThisDoc.checked = false;
- radioURL.checked=true;
- }
- else { //refresh current doc
- refreshContent=refreshDelay;
- //set checkboxes correctly
- radioURL.checked = false;
- radioThisDoc=true;
- }
-
- getSelectedObj().setAttribute("content",refreshContent);
-
- }
-
-
- function browseForFile(){
- var File = browseForFileURL();
- if (File)
- findObject("fileURL").value = File;
- }
-
- // ******************** GENERIC FUNCTIONS ****************************
-
- function findObject(objName, parentObj) {
- var i,tempObj="",found=false,curObj = "";
- var NS = (navigator.appName.indexOf("Netscape") != -1);
- if (!NS && document.all) curObj = document.all[objName]; //IE4
- else {
- parentObj = (parentObj != null)? parentObj.document : document;
- if (parentObj[objName] != null) curObj = parentObj[objName]; //at top level
- else { //if in form
- if (parentObj.forms) for (i=0; i<parentObj.forms.length; i++) { //search level for form object
- if (parentObj.forms[i][objName]) {
- curObj = parentObj.forms[i][objName];
- found = true; break;
- } }
- if (!found && NS && parentObj.layers && parentObj.layers.length > 0) {
- parentObj = parentObj.layers;
- for (i=0; i<parentObj.length; i++) { //else search for child layers
- tempObj = findObject(objName,parentObj[i]); //recurse
- if (tempObj) { curObj = tempObj; break;} //if found, done
- } } } }
- return curObj;
- }
-
-
- // ******************** GENERIC DOM MANIPULATION FUNCTIONS ****************************
-
- //Returns the selected object
- function getSelectedObj() {
- var selArr=dreamweaver.getSelection();
- return dreamweaver.offsetsToNode(selArr[0],selArr[1]);
- }
-