home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 123 / cdrom123.iso / essenc / extens / wweb / Web Developer.xpi / chrome / webdeveloper.jar / content / webdeveloper / forms.js < prev    next >
Encoding:
JavaScript  |  2004-11-21  |  34.3 KB  |  813 lines

  1. // Clears all radio buttons
  2. function webdeveloper_clearRadioButtons()
  3. {
  4.     const content      = window.document.getElementById("content");
  5.     const mainTabBox   = content.mTabBox;
  6.     const documentList = webdeveloper_getDocuments(content.browsers[mainTabBox.selectedIndex].contentWindow, new Array());
  7.     const stringBundle = document.getElementById("webdeveloper-string-bundle");
  8.  
  9.     var inputElement     = null;
  10.     var inputElementList = null;
  11.     var pageDocument     = null;
  12.  
  13.     // Loop through the documents
  14.     for(var i = 0; i < documentList.length; i++)
  15.     {
  16.         pageDocument     = documentList[i];
  17.         inputElementList = pageDocument.getElementsByTagName("input");
  18.  
  19.         // Loop through all the input tags
  20.         for(var j = 0; j < inputElementList.length; j++)
  21.         {
  22.             inputElement = inputElementList[j];
  23.  
  24.             // If the element is a radio button
  25.             if(inputElement.hasAttribute("type") && inputElement.getAttribute("type") == "radio")
  26.             {
  27.                 inputElement.checked = false;
  28.             }
  29.             else
  30.             {
  31.                 // This stops the fields reordering
  32.                 inputElement.setAttribute("type", inputElement.getAttribute("type"));
  33.             }
  34.         }
  35.     }
  36.  
  37.     alert(stringBundle.getString("webdeveloper_clearRadioButtonsResult"));
  38. }
  39.  
  40. // Displays/hides the form details for the page
  41. function webdeveloper_displayFormDetails(element, applyStyle)
  42. {
  43.     const content      = window.document.getElementById("content");
  44.     const display      = element.getAttribute("checked");
  45.     const mainTabBox   = content.mTabBox;
  46.     const documentList = webdeveloper_getDocuments(content.browsers[mainTabBox.selectedIndex].contentWindow, new Array());
  47.  
  48.     var inputElement        = null;
  49.     var inputElementList    = null;
  50.     var pageDocument        = null;
  51.     var selectElement       = null;
  52.     var selectElementList   = null;
  53.     var spanElement         = null;
  54.     var spanElementList     = null;
  55.     var text                = null;
  56.     var textareaElement     = null;
  57.     var textareaElementList = null;
  58.  
  59.     // Loop through the documents
  60.     for(var i = 0; i < documentList.length; i++)
  61.     {
  62.         pageDocument        = documentList[i];
  63.         inputElementList    = pageDocument.getElementsByTagName("input");
  64.         selectElementList   = pageDocument.getElementsByTagName("select");
  65.         spanElementList     = pageDocument.getElementsByTagName("span");
  66.         textareaElementList = pageDocument.getElementsByTagName("textarea");
  67.  
  68.         // Loop through all the span tags
  69.         for(var j = 0; j < spanElementList.length; j++)
  70.         {
  71.             spanElement = spanElementList[j];
  72.  
  73.             // If the class exists and is set to webdeveloper-form-span
  74.             if(spanElement.hasAttribute("class") && spanElement.getAttribute("class") == "webdeveloper-form-span")
  75.             {
  76.                 spanElement.parentNode.removeChild(spanElement);
  77.                 j--;
  78.             }
  79.         }
  80.  
  81.         // Loop through all the input tags
  82.         for(j = 0; j < inputElementList.length; j++)
  83.         {
  84.             inputElement = inputElementList[j];
  85.  
  86.             // If displaying
  87.             if(display)
  88.             {
  89.                 spanElement = pageDocument.createElement("span");
  90.                 text        = "<input";
  91.  
  92.                 // If the element is hidden
  93.                 if(inputElement.hasAttribute("type") && inputElement.getAttribute("type") == "hidden")
  94.                 {
  95.                     inputElement.setAttribute("type", "text");
  96.  
  97.                     // If the element has a class attribute
  98.                     if(inputElement.hasAttribute("class"))
  99.                     {
  100.                         inputElement.setAttribute("class", inputElement.getAttribute("class") + " webdeveloper-unhidden");
  101.                     }
  102.                     else
  103.                     {
  104.                         inputElement.setAttribute("class", "webdeveloper-unhidden");
  105.                     }
  106.                 }
  107.  
  108.                 // If the element has an id attribute
  109.                 if(inputElement.hasAttribute("id"))
  110.                 {
  111.                     text += ' id="' + inputElement.getAttribute("id") + '"';
  112.                 }
  113.  
  114.                 // If the element has an name attribute
  115.                 if(inputElement.hasAttribute("name"))
  116.                 {
  117.                     text += ' name="' + inputElement.getAttribute("name") + '"';
  118.                 }
  119.  
  120.                 // If the element has a size attribute
  121.                 if(inputElement.hasAttribute("size"))
  122.                 {
  123.                     text += ' size="' + inputElement.getAttribute("size") + '"';
  124.                 }
  125.  
  126.                 // If the element has a maxlength attribute
  127.                 if(inputElement.hasAttribute("maxlength"))
  128.                 {
  129.                     text += ' maxlength="' + inputElement.getAttribute("maxlength") + '"';
  130.                 }
  131.  
  132.                 text += ">";
  133.  
  134.                 spanElement.setAttribute("class", "webdeveloper-form-span");
  135.                 spanElement.appendChild(pageDocument.createTextNode(text));
  136.                 inputElement.parentNode.insertBefore(spanElement, inputElement);
  137.             }
  138.             else if(inputElement.hasAttribute("class") && inputElement.getAttribute("class").indexOf("webdeveloper-unhidden") != -1)
  139.             {
  140.                 inputElement.setAttribute("type", "hidden");
  141.                 inputElement.setAttribute("class", webdeveloper_removeSubstring(inputElement.getAttribute("class"), "webdeveloper-unhidden").trim());
  142.             }
  143.  
  144.             // This stops the fields reordering
  145.             inputElement.setAttribute("type", inputElement.getAttribute("type"));
  146.         }
  147.  
  148.         // Loop through all the select tags
  149.         for(j = 0; j < selectElementList.length; j++)
  150.         {
  151.             selectElement = selectElementList[j];
  152.  
  153.             // If displaying
  154.             if(display)
  155.             {
  156.                 spanElement = pageDocument.createElement("span");
  157.                 text        = "<select";
  158.  
  159.                 // If the element has an id attribute
  160.                 if(selectElement.hasAttribute("id"))
  161.                 {
  162.                     text += ' id="' + selectElement.getAttribute("id") + '"';
  163.                 }
  164.  
  165.                 // If the element has an name attribute
  166.                 if(selectElement.hasAttribute("name"))
  167.                 {
  168.                     text += ' name="' + selectElement.getAttribute("name") + '"';
  169.                 }
  170.  
  171.                 text += ">";
  172.  
  173.                 spanElement.setAttribute("class", "webdeveloper-form-span");
  174.                 spanElement.appendChild(pageDocument.createTextNode(text));
  175.                 selectElement.parentNode.insertBefore(spanElement, selectElement);
  176.             }
  177.         }
  178.  
  179.         // Loop through all the textarea tags
  180.         for(j = 0; j < textareaElementList.length; j++)
  181.         {
  182.             textareaElement = textareaElementList[j];
  183.  
  184.             // If displaying
  185.             if(display)
  186.             {
  187.                 spanElement = pageDocument.createElement("span");
  188.                 text        = "<textarea";
  189.  
  190.                 // If the element has an id attribute
  191.                 if(textareaElement.hasAttribute("id"))
  192.                 {
  193.                     text += ' id="' + textareaElement.getAttribute("id") + '"';
  194.                 }
  195.  
  196.                 // If the element has an name attribute
  197.                 if(textareaElement.hasAttribute("name"))
  198.                 {
  199.                     text += ' name="' + textareaElement.getAttribute("name") + '"';
  200.                 }
  201.  
  202.                 text += ">";
  203.  
  204.                 spanElement.setAttribute("class", "webdeveloper-form-span");
  205.                 spanElement.appendChild(pageDocument.createTextNode(text));
  206.                 textareaElement.parentNode.insertBefore(spanElement, textareaElement);
  207.             }
  208.         }
  209.     }
  210.  
  211.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/display_form_details.css", "webdeveloper-display-form-details", applyStyle);
  212.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-form-details-tooltips", "*:before, .webdeveloper-form-span");
  213. }
  214.  
  215. // Enables form auto completion
  216. function webdeveloper_enableFormAutoCompletion()
  217. {
  218.     const content      = window.document.getElementById("content");
  219.     const mainTabBox   = content.mTabBox;
  220.     const documentList = webdeveloper_getDocuments(content.browsers[mainTabBox.selectedIndex].contentWindow, new Array());
  221.     const stringBundle = document.getElementById("webdeveloper-string-bundle");
  222.  
  223.     var enabledForms = 0;
  224.     var form         = null;
  225.     var formList     = null;
  226.     var pageDocument = null;
  227.  
  228.     // Loop through the documents
  229.     for(var i = 0; i < documentList.length; i++)
  230.     {
  231.         pageDocument = documentList[i];
  232.         formList     = pageDocument.getElementsByTagName("form");
  233.  
  234.         // Loop through all the forms
  235.         for(var j = 0; j < formList.length; j++)
  236.         {
  237.             form = formList[j];
  238.  
  239.             // If this form has autocomplete off
  240.             if(form.getAttribute("autocomplete") == "off")
  241.             {
  242.                 form.setAttribute("autocomplete", "on");
  243.                 enabledForms++;
  244.             }
  245.         }
  246.     }
  247.  
  248.     // If one form was enabled
  249.     if(enabledForms == 1)
  250.     {
  251.         alert(stringBundle.getString("webdeveloper_enableAutoCompletionSingleResult"));
  252.     }
  253.     else
  254.     {
  255.         alert(stringBundle.getFormattedString("webdeveloper_enableAutoCompletionMultipleResult", [enabledForms]));
  256.     }
  257. }
  258.  
  259. // Makes all the form fields writable
  260. function webdeveloper_makeFormFieldsWritable()
  261. {
  262.     const content      = window.document.getElementById("content");
  263.     const mainTabBox   = content.mTabBox;
  264.     const documentList = webdeveloper_getDocuments(content.browsers[mainTabBox.selectedIndex].contentWindow, new Array());
  265.     const stringBundle = document.getElementById("webdeveloper-string-bundle");
  266.  
  267.     var writableFields      = 0;
  268.     var inputElement        = null;
  269.     var inputElementType    = null;
  270.     var inputElementList    = null;
  271.     var pageDocument        = null;
  272.     var textAreaElement     = null;
  273.     var textAreaElementList = null;
  274.  
  275.     // Loop through the documents
  276.     for(var i = 0; i < documentList.length; i++)
  277.     {
  278.         pageDocument        = documentList[i];
  279.         inputElementList    = pageDocument.getElementsByTagName("input");
  280.         textAreaElementList = pageDocument.getElementsByTagName("textarea");
  281.  
  282.         // Loop through all the input tags
  283.         for(var j = 0; j < inputElementList.length; j++)
  284.         {
  285.             inputElement = inputElementList[j];
  286.  
  287.             // If the input element has a read only attribute
  288.             if(inputElement.hasAttribute("readonly"))
  289.             {
  290.                 inputElement.removeAttribute("readonly");
  291.                 writableFields++;
  292.             }
  293.         }
  294.  
  295.         // Loop through all the text area tags
  296.         for(j = 0; j < textAreaElementList.length; j++)
  297.         {
  298.             textAreaElement = textAreaElementList[j];
  299.  
  300.             // If the text area element has a read only attribute
  301.             if(textAreaElement.hasAttribute("readonly"))
  302.             {
  303.                 textAreaElement.removeAttribute("readonly");
  304.                 writableFields++;
  305.             }
  306.         }
  307.     }
  308.  
  309.     // If one field was made writable
  310.     if(writableFields == 1)
  311.     {
  312.         alert(stringBundle.getString("webdeveloper_makeFormFieldsWritableSingleResult"));
  313.     }
  314.     else
  315.     {
  316.         alert(stringBundle.getFormattedString("webdeveloper_makeFormFieldsWritableMultipleResult", [writableFields]));
  317.     }
  318. }
  319.  
  320. // Populates the form fields on the page
  321. function webdeveloper_populateFormFields()
  322. {
  323.     const content            = window.document.getElementById("content");
  324.     const mainTabBox         = content.mTabBox;
  325.     const documentList       = webdeveloper_getDocuments(content.browsers[mainTabBox.selectedIndex].contentWindow, new Array());
  326.     const preferencesService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
  327.  
  328.     var inputElement        = null;
  329.     var inputElementList    = null;
  330.     var inputElementName    = null;
  331.     var inputElementType    = null;
  332.     var inputElementValue   = null;
  333.     var pageDocument        = null;
  334.     var selectElement       = null;
  335.     var selectElementList   = null;
  336.     var textAreaElement     = null;
  337.     var textAreaElementList = null;
  338.  
  339.     // Loop through the documents
  340.     for(var i = 0; i < documentList.length; i++)
  341.     {
  342.         pageDocument        = documentList[i];
  343.         inputElementList    = pageDocument.getElementsByTagName("input");
  344.         selectElementList   = pageDocument.getElementsByTagName("select");
  345.         textAreaElementList = pageDocument.getElementsByTagName("textarea");
  346.  
  347.         // Loop through all the input tags
  348.         for(var j = 0; j < inputElementList.length; j++)
  349.         {
  350.             inputElement      = inputElementList[j];
  351.             inputElementType  = inputElement.getAttribute("type");
  352.             inputElementValue = inputElement.getAttribute("value");
  353.  
  354.             // If the input element is not disabled
  355.             if(!inputElement.disabled)
  356.             {
  357.                 // If the input element value is not set and has a password or text type
  358.                 if((!inputElementValue || inputElementValue.trim() == "") && (inputElementType == "password" || inputElementType == "text"))
  359.                 {
  360.                     inputElementName = inputElement.getAttribute("name");
  361.  
  362.                     // If the input element type is text, the name contains email and the populate form fields email preference is set
  363.                     if(inputElementType == "text" && inputElementName.toLowerCase().indexOf("email") != -1 && preferencesService.prefHasUserValue("webdeveloper.populate.form.fields.email"))
  364.                     {
  365.                         inputElement.setAttribute("value", preferencesService.getCharPref("webdeveloper.populate.form.fields.email"));
  366.                     }
  367.                     else
  368.                     {
  369.                         inputElement.setAttribute("value", inputElementName);
  370.                     }
  371.                 }
  372.                 else if(inputElementType == "checkbox" || inputElementType == "radio")
  373.                 {
  374.                     inputElement.setAttribute("checked", true);
  375.                 }
  376.             }
  377.         }
  378.  
  379.         // Loop through all the select tags
  380.         for(j = 0; j < selectElementList.length; j++)
  381.         {
  382.             selectElement = selectElementList[j];
  383.  
  384.             // If the select element is not disabled and the size is set greater than 1
  385.             if(!selectElement.disabled && selectElement.hasAttribute("size") && selectElement.getAttribute("size") > 1)
  386.             {
  387.                 selectElement.selectedIndex = 0;
  388.             }
  389.         }
  390.  
  391.         // Loop through all the text area tags
  392.         for(j = 0; j < textAreaElementList.length; j++)
  393.         {
  394.             textAreaElement = textAreaElementList[j];
  395.  
  396.             // If the text area element is not disabled and the value is not set
  397.             if(!textAreaElement.disabled && textAreaElement.value.trim() == "")
  398.             {
  399.                 textAreaElement.value = textAreaElement.getAttribute("name");
  400.             }
  401.         }
  402.     }
  403. }
  404.  
  405. // Removes all maximum lengths on form elements
  406. function webdeveloper_removeMaximumLengths()
  407. {
  408.     const content      = window.document.getElementById("content");
  409.     const mainTabBox   = content.mTabBox;
  410.     const documentList = webdeveloper_getDocuments(content.browsers[mainTabBox.selectedIndex].contentWindow, new Array());
  411.     const stringBundle = document.getElementById("webdeveloper-string-bundle");
  412.  
  413.     var inputElement     = null;
  414.     var inputElementList = null;
  415.     var pageDocument     = null;
  416.     var removed          = 0;
  417.  
  418.     // Loop through the documents
  419.     for(var i = 0; i < documentList.length; i++)
  420.     {
  421.         pageDocument     = documentList[i];
  422.         inputElementList = pageDocument.getElementsByTagName("input");
  423.  
  424.         // Loop through all the input tags
  425.         for(var j = 0; j < inputElementList.length; j++)
  426.         {
  427.             inputElement = inputElementList[j];
  428.  
  429.             // If the element has a maxlength attribute
  430.             if(inputElement.hasAttribute("maxlength"))
  431.             {
  432.                 inputElement.removeAttribute("maxlength");
  433.                 removed++;
  434.             }
  435.         }
  436.     }
  437.  
  438.     // If one maxlength was removed
  439.     if(removed == 1)
  440.     {
  441.         alert(stringBundle.getString("webdeveloper_removeMaximumLengthsSingleResult"));
  442.     }
  443.     else
  444.     {
  445.         alert(stringBundle.getFormattedString("webdeveloper_removeMaximumLengthsMultipleResult", [removed]));
  446.     }
  447. }
  448.  
  449. // Shows all passwords on a form
  450. function webdeveloper_showPasswords()
  451. {
  452.     const content      = window.document.getElementById("content");
  453.     const mainTabBox   = content.mTabBox;
  454.     const documentList = webdeveloper_getDocuments(content.browsers[mainTabBox.selectedIndex].contentWindow, new Array());
  455.     const stringBundle = document.getElementById("webdeveloper-string-bundle");
  456.  
  457.     var inputElement     = null;
  458.     var inputElementList = null;
  459.     var pageDocument     = null;
  460.     var shownPasswords   = 0;
  461.  
  462.     // Loop through the documents
  463.     for(var i = 0; i < documentList.length; i++)
  464.     {
  465.         pageDocument     = documentList[i];
  466.         inputElementList = pageDocument.getElementsByTagName("input");
  467.  
  468.         // Loop through all the input tags
  469.         for(var j = 0; j < inputElementList.length; j++)
  470.         {
  471.             inputElement = inputElementList[j];
  472.  
  473.             // If the element is password
  474.             if(inputElement.getAttribute("type") == "password")
  475.             {
  476.                 inputElement.setAttribute("type", "text");
  477.                 shownPasswords++;
  478.             }
  479.             else
  480.             {
  481.                 // This stops the fields reordering
  482.                 inputElement.setAttribute("type", inputElement.getAttribute("type"));
  483.             }
  484.         }
  485.     }
  486.  
  487.     // If one password was shown
  488.     if(shownPasswords == 1)
  489.     {
  490.         alert(stringBundle.getString("webdeveloper_showPasswordsSingleResult"));
  491.     }
  492.     else
  493.     {
  494.         alert(stringBundle.getFormattedString("webdeveloper_showPasswordsMultipleResult", [shownPasswords]));
  495.     }
  496. }
  497.  
  498. // Toggles form methods
  499. function webdeveloper_toggleFormMethods(method)
  500. {
  501.     const content                = window.document.getElementById("content");
  502.     const displayFormDetailsMenu = document.getElementById("webdeveloper-display-form-details-menu");
  503.     const mainTabBox             = content.mTabBox;
  504.     const documentList           = webdeveloper_getDocuments(content.browsers[mainTabBox.selectedIndex].contentWindow, new Array());
  505.     const stringBundle           = document.getElementById("webdeveloper-string-bundle");
  506.  
  507.     var convertedForms = 0;
  508.     var form           = null;
  509.     var formList       = null;
  510.     var pageDocument   = null;
  511.  
  512.     // Loop through the documents
  513.     for(var i = 0; i < documentList.length; i++)
  514.     {
  515.         pageDocument = documentList[i];
  516.         formList     = pageDocument.getElementsByTagName("form");
  517.  
  518.         // Loop through all the forms
  519.         for(var j = 0; j < formList.length; j++)
  520.         {
  521.             form = formList[j];
  522.  
  523.             // If this form is not already the right method
  524.             if(form.getAttribute("method") != method)
  525.             {
  526.                 form.setAttribute("method", method);
  527.                 convertedForms++;
  528.             }
  529.         }
  530.     }
  531.  
  532.     // Reapply the display form details style sheet if it is currently on - fixes bug with form method not updating
  533.     if(displayFormDetailsMenu.getAttribute("checked"))
  534.     {
  535.         webdeveloper_removeStyleSheet("webdeveloper-display-form-details", false);
  536.         webdeveloper_displayFormDetails(displayFormDetailsMenu, false);
  537.     }
  538.  
  539.     // If one form was converted
  540.     if(convertedForms == 1)
  541.     {
  542.         alert(stringBundle.getFormattedString("webdeveloper_toggleFormMethodsSingleResult", [method.toUpperCase()]));
  543.     }
  544.     else
  545.     {
  546.         alert(stringBundle.getFormattedString("webdeveloper_toggleFormMethodsMultipleResult", [convertedForms, method.toUpperCase()]));
  547.     }
  548. }
  549.  
  550. // Displays all the forms for the page
  551. function webdeveloper_viewFormInformation()
  552. {
  553.     const content            = window.document.getElementById("content");
  554.     const mainTabBox         = content.mTabBox;
  555.     const documentList       = webdeveloper_getDocuments(content.browsers[mainTabBox.selectedIndex].contentWindow, new Array());
  556.     const oldTab             = getBrowser().selectedTab;
  557.     const oldURL             = window.content.document.documentURI;
  558.     const preferencesService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
  559.     const request            = new XMLHttpRequest();
  560.     const stringBundle       = document.getElementById("webdeveloper-string-bundle");
  561.     const title              = stringBundle.getFormattedString("webdeveloper_viewFormInformationTitle", [oldURL]);
  562.  
  563.     var cellDataElement   = null;
  564.     var cellHeaderElement = null;
  565.     var documentURL       = null;
  566.     var elementType       = null;
  567.     var elementValue      = null;
  568.     var form              = null;
  569.     var formElement       = null;
  570.     var formElementId     = null;
  571.     var formElementList   = null;
  572.     var formLength        = null;
  573.     var formList          = null;
  574.     var generatedPage     = null;
  575.     var headerElement     = null;
  576.     var label             = null;
  577.     var labelList         = null;
  578.     var labelValue        = null;
  579.     var linkElement       = null;
  580.     var pageDocument      = null;
  581.     var pElement          = null;
  582.     var preElement        = null;
  583.     var tableElement      = null;
  584.     var tableRowElement   = null;
  585.  
  586.     generatedPage = webdeveloper_generatePage("");
  587.  
  588.     // This must be done to make generated content render
  589.     request.open("GET", "about:blank", false);
  590.     request.send("");
  591.  
  592.     generatedPage.content.document.title = title;
  593.  
  594.     linkElement = generatedPage.content.document.createElement("link");
  595.     linkElement.setAttribute("href", "chrome://webdeveloper/content/stylesheets/generated_content.css");
  596.     linkElement.setAttribute("media", "all");
  597.     linkElement.setAttribute("rel", "stylesheet");
  598.     linkElement.setAttribute("type", "text/css");
  599.     generatedPage.content.document.getElementsByTagName("head")[0].appendChild(linkElement);
  600.  
  601.     headerElement = generatedPage.content.document.createElement("h1");
  602.     headerElement.appendChild(generatedPage.content.document.createTextNode(title));
  603.     generatedPage.content.document.body.appendChild(headerElement);
  604.  
  605.     // Loop through the documents
  606.     for(var i = 0; i < documentList.length; i++)
  607.     {
  608.         pageDocument = documentList[i];
  609.         documentURL  = pageDocument.documentURI;
  610.         formList     = pageDocument.getElementsByTagName("form");
  611.         formLength   = formList.length;
  612.  
  613.         headerElement = generatedPage.content.document.createElement("h2");
  614.         linkElement   = generatedPage.content.document.createElement("a");
  615.         linkElement.setAttribute("href", documentURL);
  616.         linkElement.appendChild(generatedPage.content.document.createTextNode(documentURL));
  617.         headerElement.appendChild(linkElement);
  618.         generatedPage.content.document.body.appendChild(headerElement);
  619.  
  620.         // If there are no forms
  621.         if(formLength == 0)
  622.         {
  623.             pElement = generatedPage.content.document.createElement("p");
  624.             pElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_noForms")));
  625.             generatedPage.content.document.body.appendChild(pElement);
  626.         }
  627.         else
  628.         {
  629.             labelList = pageDocument.getElementsByTagName("label");
  630.  
  631.             // Loop through the forms
  632.             for(var j = 0; j < formLength; j++)
  633.             {
  634.                 form            = formList[j];
  635.                 formElementList = form.elements;
  636.                 headerElement   = generatedPage.content.document.createElement("h2");
  637.                 tableElement    = generatedPage.content.document.createElement("table");
  638.                 tableRowElement = generatedPage.content.document.createElement("tr");
  639.  
  640.                 headerElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_viewFormInformationForm")));
  641.                 generatedPage.content.document.body.appendChild(headerElement);
  642.  
  643.                 //  Form id heading
  644.                 cellHeaderElement = generatedPage.content.document.createElement("th");
  645.                 cellHeaderElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_viewFormInformationId")));
  646.                 tableRowElement.appendChild(cellHeaderElement);
  647.  
  648.                 //  Form name heading
  649.                 cellHeaderElement = generatedPage.content.document.createElement("th");
  650.                 cellHeaderElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_viewFormInformationName")));
  651.                 tableRowElement.appendChild(cellHeaderElement);
  652.  
  653.                 //  Form method heading
  654.                 cellHeaderElement = generatedPage.content.document.createElement("th");
  655.                 cellHeaderElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_viewFormInformationMethod")));
  656.                 tableRowElement.appendChild(cellHeaderElement);
  657.  
  658.                 //  Form action heading
  659.                 cellHeaderElement = generatedPage.content.document.createElement("th");
  660.                 cellHeaderElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_viewFormInformationAction")));
  661.                 tableRowElement.appendChild(cellHeaderElement);
  662.                 tableElement.appendChild(tableRowElement);
  663.  
  664.                 tableRowElement = generatedPage.content.document.createElement("tr");
  665.  
  666.                 //  Form id
  667.                 cellDataElement = generatedPage.content.document.createElement("td");
  668.                 cellDataElement.appendChild(generatedPage.content.document.createTextNode(form.getAttribute("id")));
  669.                 tableRowElement.appendChild(cellDataElement);
  670.  
  671.                 //  Form name
  672.                 cellDataElement = generatedPage.content.document.createElement("td");
  673.                 cellDataElement.appendChild(generatedPage.content.document.createTextNode(form.getAttribute("name")));
  674.                 tableRowElement.appendChild(cellDataElement);
  675.  
  676.                 //  Form method
  677.                 cellDataElement = generatedPage.content.document.createElement("td");
  678.                 cellDataElement.appendChild(generatedPage.content.document.createTextNode(form.getAttribute("method")));
  679.                 tableRowElement.appendChild(cellDataElement);
  680.  
  681.                 //  Form action
  682.                 cellDataElement = generatedPage.content.document.createElement("td");
  683.                 cellDataElement.appendChild(generatedPage.content.document.createTextNode(form.getAttribute("action")));
  684.                 tableRowElement.appendChild(cellDataElement);
  685.                 tableElement.appendChild(tableRowElement);
  686.  
  687.                 generatedPage.content.document.body.appendChild(tableElement);
  688.  
  689.                 pElement = generatedPage.content.document.createElement("p");
  690.                 generatedPage.content.document.body.appendChild(pElement);
  691.  
  692.                 headerElement = generatedPage.content.document.createElement("h2");
  693.                 tableElement  = generatedPage.content.document.createElement("table");
  694.                 tableRowElement = generatedPage.content.document.createElement("tr");
  695.  
  696.                 headerElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_viewFormInformationElements")));
  697.                 generatedPage.content.document.body.appendChild(headerElement);
  698.  
  699.                 //  Element label heading
  700.                 cellHeaderElement = generatedPage.content.document.createElement("th");
  701.                 cellHeaderElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_viewFormInformationLabel")));
  702.                 tableRowElement.appendChild(cellHeaderElement);
  703.  
  704.                 //  Element id heading
  705.                 cellHeaderElement = generatedPage.content.document.createElement("th");
  706.                 cellHeaderElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_viewFormInformationId")));
  707.                 tableRowElement.appendChild(cellHeaderElement);
  708.  
  709.                 //  Element name heading
  710.                 cellHeaderElement = generatedPage.content.document.createElement("th");
  711.                 cellHeaderElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_viewFormInformationName")));
  712.                 tableRowElement.appendChild(cellHeaderElement);
  713.                 tableElement.appendChild(tableRowElement);
  714.  
  715.                 //  Element type heading
  716.                 cellHeaderElement = generatedPage.content.document.createElement("th");
  717.                 cellHeaderElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_viewFormInformationType")));
  718.                 tableRowElement.appendChild(cellHeaderElement);
  719.                 tableElement.appendChild(tableRowElement);
  720.  
  721.                 //  Element value heading
  722.                 cellHeaderElement = generatedPage.content.document.createElement("th");
  723.                 cellHeaderElement.appendChild(generatedPage.content.document.createTextNode(stringBundle.getString("webdeveloper_viewFormInformationValue")));
  724.                 tableRowElement.appendChild(cellHeaderElement);
  725.                 tableElement.appendChild(tableRowElement);
  726.  
  727.                 // Loop through the form elements
  728.                 for(var k = 0; k < formElementList.length; k++)
  729.                 {
  730.                     formElement     = formElementList[k];
  731.                     formElementId   = formElement.getAttribute("id");
  732.                     elementType     = formElement.tagName.toLowerCase();
  733.                     elementValue    = "";
  734.                     label           = "";
  735.                     labelValue      = "";
  736.                     tableRowElement = generatedPage.content.document.createElement("tr");
  737.  
  738.                     // If the element has an id
  739.                     if(formElementId)
  740.                     {
  741.                         // Loop through the labels
  742.                         for(var l = 0; l < labelList.length; l++)
  743.                         {
  744.                             label = labelList[l];
  745.  
  746.                             // If this is the label for the element
  747.                             if(label.hasAttribute("for") && label.getAttribute("for") == formElementId)
  748.                             {
  749.                                 labelValue = label.innerHTML;
  750.                             }
  751.                         }
  752.                     }
  753.  
  754.                     // If this is an odd row
  755.                     if(k % 2 != 0)
  756.                     {
  757.                         tableRowElement.setAttribute("class", "odd");
  758.                     }
  759.  
  760.                     // If this is an input element
  761.                     if(elementType == "input")
  762.                     {
  763.                         elementType  = formElement.getAttribute("type");
  764.                         elementValue = formElement.value;
  765.                     }
  766.                     else if(elementType == "textarea")
  767.                     {
  768.                         elementValue = formElement.value;
  769.                     }
  770.  
  771.                     //  Element label
  772.                     cellDataElement = generatedPage.content.document.createElement("td");
  773.                     cellDataElement.appendChild(generatedPage.content.document.createTextNode(labelValue));
  774.                     tableRowElement.appendChild(cellDataElement);
  775.                     tableElement.appendChild(tableRowElement);
  776.  
  777.                     //  Element id
  778.                     cellDataElement = generatedPage.content.document.createElement("td");
  779.                     cellDataElement.appendChild(generatedPage.content.document.createTextNode(formElementId));
  780.                     tableRowElement.appendChild(cellDataElement);
  781.  
  782.                     //  Element name
  783.                     cellDataElement = generatedPage.content.document.createElement("td");
  784.                     cellDataElement.appendChild(generatedPage.content.document.createTextNode(formElement.getAttribute("name")));
  785.                     tableRowElement.appendChild(cellDataElement);
  786.                     tableElement.appendChild(tableRowElement);
  787.  
  788.                     //  Element type
  789.                     cellDataElement = generatedPage.content.document.createElement("td");
  790.                     cellDataElement.appendChild(generatedPage.content.document.createTextNode(elementType));
  791.                     tableRowElement.appendChild(cellDataElement);
  792.                     tableElement.appendChild(tableRowElement);
  793.  
  794.                     //  Element value
  795.                     cellDataElement = generatedPage.content.document.createElement("td");
  796.                     cellDataElement.appendChild(generatedPage.content.document.createTextNode(elementValue));
  797.                     tableRowElement.appendChild(cellDataElement);
  798.                     tableElement.appendChild(tableRowElement);
  799.                 }
  800.  
  801.                 generatedPage.content.document.body.appendChild(tableElement);
  802.                 generatedPage.content.document.body.appendChild(generatedPage.content.document.createElement("hr"));
  803.             }
  804.         }
  805.     }
  806.  
  807.     // If the open tabs in background preference is set to true
  808.     if(preferencesService.prefHasUserValue("webdeveloper.open.tabs.background") && preferencesService.getBoolPref("webdeveloper.open.tabs.background"))
  809.     {
  810.         getBrowser().selectedTab = oldTab;
  811.     }
  812. }
  813.