home *** CD-ROM | disk | FTP | other *** search
- //form field names:
- //metaAttribute - drop down menu - name is [0] and http is [1]
- //metaValue - text field
- //metaContent - text field
-
- // *********** GLOBAL VARS *****************************
-
- var helpDoc = "html/204.creatingdocuments.fm20.html";
-
- // ******************** API ****************************
- function canInspectSelection(){
- metaObj = getSelectedObj();
- return (metaObj.tagName && metaObj.tagName=="META");
- }
-
- function inspectSelection(){
-
- var metaObj = getSelectedObj();
- var metaValue = findObject("metaValue");
- var metaAttribute = findObject("metaAttribute");
- var metaContent = findObject("metaContent");
- var useNameAttr = metaObj.getAttribute("name") || metaObj.getAttribute("name")=="";
- var thisContent = metaObj.getAttribute("content");
- var thisAttribute;
-
-
- //fill in PI
- metaAttribute.selectedIndex = (useNameAttr)?0:1;
- if (useNameAttr){
- thisAttribute = metaObj.getAttribute("name");
- findObject("metaImage").src="name.gif";
- }
- else{
- thisAttribute = metaObj.getAttribute("http-equiv");
- findObject("metaImage").src="http.gif";
- }
-
- //fill in attribute value if present, otherwise fill text field with empty string
- findObject("metaValue").value = thisAttribute;
- //fill in meta content if present, otherwise fill text field with empty string
- if (metaObj.getAttribute("content") || metaObj.getAttribute("content")=="")
- metaContent.value = (thisContent)?thisContent:"";
-
- }
-
-
-
-
- // ******************** LOCAL FUNCTIONS ****************************
-
- function setMetaTag(){
- var metaObj=getSelectedObj();
- var metaValue = findObject("metaValue").value;
-
-
- if (findObject("metaAttribute").selectedIndex==0){
- metaObj.removeAttribute("http-equiv");
- metaObj.setAttribute("name",metaValue);
- } else {
- metaObj.removeAttribute("name");
- metaObj.setAttribute("http-equiv",metaValue);
- }
- //attribute is removed and then re-applied so that content attribute
- //always appears after name and http-equiv attributes
- metaObj.removeAttribute("content");
- metaObj.setAttribute("content",findObject("metaContent").value);
-
- }
-
-
-
-
-
- // ******************** 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]);
- }
-