1 // Adds colors from the specified property of the element to the given list
2 function webdeveloper_addColor(element
, property
, colorList
)
4 // If the element, property and color list are set
5 if(element
&& property
&& colorList
)
7 var computedStyle
= element
.ownerDocument
.defaultView
.getComputedStyle(element
, null);
8 var color
= computedStyle
.getPropertyCSSValue(property
);
10 // If the color is set and it is a color
11 if(color
&& color
.primitiveType
== CSSPrimitiveValue
.CSS_RGBCOLOR
)
13 color
= color
.getRGBColorValue();
15 colorList
.push("#" + webdeveloper_formatColor(color
.red
.getFloatValue(CSSPrimitiveValue
.CSS_NUMBER
)) + webdeveloper_formatColor(color
.green
.getFloatValue(CSSPrimitiveValue
.CSS_NUMBER
)) + webdeveloper_formatColor(color
.blue
.getFloatValue(CSSPrimitiveValue
.CSS_NUMBER
)));
20 // Displays all abbreviations
21 function webdeveloper_displayAbbreviations(element
)
23 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/display_abbreviations.css", "webdeveloper-display-abbreviations");
24 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-abbreviations-tooltips", "*:before");
27 // Displays all access keys
28 function webdeveloper_displayAccessKeys(element
)
30 var accessKeyElement
= null;
31 var accessKeyElementList
= null;
32 var accessKeyElementsLength
= null;
33 var display
= element
.getAttribute("checked");
34 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
35 var documentLength
= documentList
.length
;
36 var pageDocument
= null;
37 var spanElement
= null;
40 // Loop through the documents
41 for(var i
= 0; i
< documentLength
; i
++)
43 pageDocument
= documentList
[i
];
45 // Need to do this to stop the feature running twice
46 webdeveloper_removeAllElementsByXPath(pageDocument
, "//span[@class='webdeveloper-display-access-keys']");
51 accessKeyElementList
= webdeveloper_evaluateXPath(pageDocument
, "//*[@accesskey]");
52 accessKeyElementsLength
= accessKeyElementList
.length
;
54 // Loop through all the access key elements
55 for(var j
= 0; j
< accessKeyElementsLength
; j
++)
57 accessKeyElement
= accessKeyElementList
[j
];
58 spanElement
= pageDocument
.createElement("span");
59 text
= "Accesskey=" + accessKeyElement
.getAttribute("accesskey");
61 spanElement
.setAttribute("class", "webdeveloper-display-access-keys");
62 spanElement
.setAttribute("title", text
);
63 spanElement
.appendChild(pageDocument
.createTextNode(text
));
64 accessKeyElement
.parentNode
.insertBefore(spanElement
, accessKeyElement
);
69 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-access-keys");
70 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-access-keys-tooltips", "span.webdeveloper-display-access-keys");
73 // Displays all anchors
74 function webdeveloper_displayAnchors(element
)
76 var anchorElement
= null;
77 var anchorElementList
= null;
78 var anchorElementsLength
= null;
79 var anchorText
= null;
80 var display
= element
.getAttribute("checked");
81 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
82 var documentLength
= documentList
.length
;
83 var linkElement
= null;
84 var pageDocument
= null;
85 var spanElement
= null;
87 // Loop through the documents
88 for(var i
= 0; i
< documentLength
; i
++)
90 pageDocument
= documentList
[i
];
92 // Need to do this to stop the feature running twice
93 webdeveloper_removeAllElementsByXPath(pageDocument
, "//span[@class='webdeveloper-display-anchors']");
98 anchorElementList
= webdeveloper_evaluateXPath(pageDocument
, "//*[@id] | //a[@name]");
99 anchorElementsLength
= anchorElementList
.length
;
101 // Loop through all the anchor elements
102 for(var j
= 0; j
< anchorElementsLength
; j
++)
104 anchorElement
= anchorElementList
[j
];
105 linkElement
= pageDocument
.createElement("a");
106 spanElement
= pageDocument
.createElement("span");
108 // If the anchor element has an id attribute
109 if(anchorElement
.hasAttribute("id"))
111 anchorText
= "#" + anchorElement
.getAttribute("id");
113 else if(anchorElement
.hasAttribute("name"))
115 anchorText
= "#" + anchorElement
.getAttribute("name");
118 linkElement
.setAttribute("href", anchorText
);
119 linkElement
.setAttribute("title", anchorText
);
120 linkElement
.appendChild(pageDocument
.createTextNode(anchorText
));
122 spanElement
.setAttribute("class", "webdeveloper-display-anchors");
123 spanElement
.setAttribute("title", anchorText
);
124 spanElement
.appendChild(linkElement
);
127 // Try to insert the anchor element
130 anchorElement
.parentNode
.insertBefore(spanElement
, anchorElement
);
140 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/display_anchors.css", "webdeveloper-display-anchors");
141 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-anchors-tooltips", "span.webdeveloper-display-anchors, span.webdeveloper-display-anchors a");
144 // Displays all block sizes
145 function webdeveloper_displayBlockSize(element
)
147 var blockSizeElement
= null;
148 var blockSizeElementList
= null;
149 var blockSizeElementsLength
= null;
150 var display
= element
.getAttribute("checked");
151 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
152 var documentLength
= documentList
.length
;
155 var pageDocument
= null;
156 var spanElement
= null;
161 // Loop through the documents
162 for(var i
= 0; i
< documentLength
; i
++)
164 pageDocument
= documentList
[i
];
166 // Need to do this to stop the feature running twice
167 webdeveloper_removeAllElementsByXPath(pageDocument
, "//span[@class='webdeveloper-display-block-size']");
172 blockSizeElementList
= webdeveloper_evaluateXPath(pageDocument
, "//div | //form | //table");
173 blockSizeElementsLength
= blockSizeElementList
.length
;
175 // Loop through the block size elements
176 for(var j
= 0; j
< blockSizeElementsLength
; j
++)
178 blockSizeElement
= blockSizeElementList
[j
];
179 height
= blockSizeElement
.offsetHeight
;
180 left
= blockSizeElement
.offsetLeft
;
181 spanElement
= pageDocument
.createElement("span");
182 top
= blockSizeElement
.offsetTop
;
183 width
= blockSizeElement
.offsetWidth
;
184 text
= webdeveloper_getElementDescription(blockSizeElement
) + " " + width
+ "x" + height
;
186 spanElement
.style
.left
= left
+ "px";
187 spanElement
.style
.position
= "absolute";
188 spanElement
.style
.top
= top
+ "px";
190 spanElement
.setAttribute("class", "webdeveloper-display-block-size");
191 spanElement
.setAttribute("title", text
);
192 spanElement
.appendChild(pageDocument
.createTextNode(text
));
194 webdeveloper_insertAsFirstChild(blockSizeElement
, spanElement
);
199 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/display_block_size.css", "webdeveloper-display-block-size");
200 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-block-size-tooltips", "span.webdeveloper-display-block-size");
203 // Displays the order of the divs on the page
204 function webdeveloper_displayDivOrder(element
)
206 var display
= element
.getAttribute("checked");
207 var divElement
= null;
208 var divElementList
= null;
209 var divElementsLength
= null;
210 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
211 var documentLength
= documentList
.length
;
212 var pageDocument
= null;
213 var spanElement
= null;
216 // Loop through the documents
217 for(var i
= 0; i
< documentLength
; i
++)
219 pageDocument
= documentList
[i
];
221 // Need to do this to stop the feature running twice
222 webdeveloper_removeAllElementsByXPath(pageDocument
, "//span[@class='webdeveloper-display-div-order']");
227 divElementList
= pageDocument
.getElementsByTagName("div");
228 divElementsLength
= divElementList
.length
;
230 // Loop through the div elements
231 for(var j
= 0; j
< divElementsLength
; j
++)
233 divElement
= divElementList
[j
];
234 spanElement
= pageDocument
.createElement("span");
235 text
= webdeveloper_getElementDescription(divElement
) + " " + (j
+ 1);
237 spanElement
.setAttribute("class", "webdeveloper-display-div-order");
238 spanElement
.setAttribute("title", text
);
239 spanElement
.appendChild(pageDocument
.createTextNode(text
));
241 webdeveloper_insertAsFirstChild(divElement
, spanElement
);
246 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/display_div_order.css", "webdeveloper-display-div-order");
247 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-div-order-tooltips", "span.webdeveloper-display-div-order");
250 // Displays id and class details for the page
251 function webdeveloper_displayIdClassDetails(element
)
253 var display
= element
.getAttribute("checked");
254 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
255 var documentLength
= documentList
.length
;
256 var idClassElement
= null;
257 var idClassElementList
= null;
258 var idClassElementsLength
= null;
259 var idClassElementText
= null;
260 var pageDocument
= null;
261 var spanElement
= null;
263 // Loop through the documents
264 for(var i
= 0; i
< documentLength
; i
++)
266 pageDocument
= documentList
[i
];
268 // Need to do this to stop the feature running twice
269 webdeveloper_removeAllElementsByXPath(pageDocument
, "//span[@class='webdeveloper-display-id-class-details']");
274 idClassElementList
= webdeveloper_evaluateXPath(pageDocument
, "//*[@class] | //*[@id]");
275 idClassElementsLength
= idClassElementList
.length
;
277 // Loop through all the id class elements
278 for(var j
= 0; j
< idClassElementsLength
; j
++)
280 idClassElement
= idClassElementList
[j
];
282 // If the id class element is a Web Developer element
283 if((idClassElement
.hasAttribute("class") && idClassElement
.getAttribute("class").indexOf("webdeveloper-")) || (idClassElement
.hasAttribute("id") && idClassElement
.getAttribute("id").indexOf("webdeveloper-")))
285 idClassElementText
= "";
286 spanElement
= pageDocument
.createElement("span");
288 // If the id class element has an id attribute
289 if(idClassElement
.hasAttribute("id"))
291 idClassElementText
+= " #" + idClassElement
.getAttribute("id");
294 // If the id class element has a class attribute
295 if(idClassElement
.hasAttribute("class"))
297 idClassElementText
+= " ." + idClassElement
.getAttribute("class");
300 spanElement
.setAttribute("class", "webdeveloper-display-id-class-details");
301 spanElement
.setAttribute("title", idClassElementText
);
302 spanElement
.appendChild(pageDocument
.createTextNode(idClassElementText
));
304 // Try to insert the id class element
307 idClassElement
.parentNode
.insertBefore(spanElement
, idClassElement
);
318 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-id-class-details");
319 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-id-class-details-tooltips", "span.webdeveloper-display-id-class-details");
322 // Displays all link details
323 function webdeveloper_displayLinkDetails(element
)
325 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/display_link_details.css", "webdeveloper-display-link-details");
326 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-link-details-tooltips", "*:before");
329 // Displays object information
330 function webdeveloper_displayObjectInformation(element
)
332 var checked
= element
.getAttribute("checked");
333 var divElement
= null;
334 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
335 var documentLength
= documentList
.length
;
336 var objectAttributes
= null;
337 var objectElement
= null;
338 var objectElementList
= null;
339 var objectElementsLength
= null;
340 var pageDocument
= null;
341 var paramAttributes
= null;
342 var paramElement
= null;
343 var paramElementList
= null;
344 var paramElementsLength
= null;
346 var treeWalker
= null;
348 // Loop through the documents
349 for(var i
= 0; i
< documentLength
; i
++)
351 pageDocument
= documentList
[i
];
353 // Need to do this to stop the feature running twice
354 webdeveloper_removeAllElementsByXPath(pageDocument
, "//div[@class='webdeveloper-display-object-information']");
356 // If the element is checked
359 objectElementList
= pageDocument
.getElementsByTagName("object");
360 objectElementsLength
= objectElementList
.length
;
362 // Loop through all the object elements
363 for(var j
= 0; j
< objectElementsLength
; j
++)
365 divElement
= pageDocument
.createElement("div");
366 objectAttributes
= "";
367 objectElement
= objectElementList
[j
];
368 paramElementList
= objectElement
.getElementsByTagName("param");
369 paramElementsLength
= paramElementList
.length
;
370 pElement
= pageDocument
.createElement("p");
372 // If the object has an width attribute
373 if(objectElement
.hasAttribute("width"))
375 objectAttributes
+= ' width="' + objectElement
.getAttribute("width") + '"';
378 // If the object has an height attribute
379 if(objectElement
.hasAttribute("height"))
381 objectAttributes
+= ' height="' + objectElement
.getAttribute("height") + '"';
384 // If the object has an archive attribute
385 if(objectElement
.hasAttribute("archive"))
387 objectAttributes
+= ' archive="' + objectElement
.getAttribute("archive") + '"';
390 // If the object has an classid attribute
391 if(objectElement
.hasAttribute("classid"))
393 objectAttributes
+= ' classid="' + objectElement
.getAttribute("classid") + '"';
396 // If the object has an codebase attribute
397 if(objectElement
.hasAttribute("codebase"))
399 objectAttributes
+= ' codebase="' + objectElement
.getAttribute("codebase") + '"';
402 // If the object has an codetype attribute
403 if(objectElement
.hasAttribute("codetype"))
405 objectAttributes
+= ' codetype="' + objectElement
.getAttribute("codetype") + '"';
408 // If the object has an data attribute
409 if(objectElement
.hasAttribute("data"))
411 objectAttributes
+= ' data="' + objectElement
.getAttribute("data") + '"';
414 // If the object has an standby attribute
415 if(objectElement
.hasAttribute("standby"))
417 objectAttributes
+= ' standby="' + objectElement
.getAttribute("standby") + '"';
420 // If the object has an type attribute
421 if(objectElement
.hasAttribute("type"))
423 objectAttributes
+= ' type="' + objectElement
.getAttribute("type") + '"';
426 pElement
.appendChild(document
.createTextNode("<object" + objectAttributes
+ ">"));
427 divElement
.appendChild(pElement
);
429 // Loop through all the param elements
430 for(var k
= 0; k
< paramElementsLength
; k
++)
432 paramAttributes
= "";
433 paramElement
= paramElementList
[k
];
434 pElement
= pageDocument
.createElement("p");
436 // If the param has a name attribute
437 if(paramElement
.hasAttribute("name"))
439 paramAttributes
+= ' name="' + paramElement
.getAttribute("name") + '"';
442 // If the param has a value attribute
443 if(paramElement
.hasAttribute("value"))
445 paramAttributes
+= ' value="' + paramElement
.getAttribute("value") + '"';
448 pElement
.appendChild(document
.createTextNode("<param" + paramAttributes
+ " />"));
449 pElement
.setAttribute("class", "param");
450 divElement
.appendChild(pElement
);
453 pElement
= pageDocument
.createElement("p");
454 pElement
.appendChild(document
.createTextNode("</object>"));
455 divElement
.appendChild(pElement
);
457 divElement
.setAttribute("class", "webdeveloper-display-object-information");
458 objectElement
.parentNode
.insertBefore(divElement
, objectElement
);
463 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/display_object_information.css", "webdeveloper-display-object-information");
464 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-object-information-tooltips", "div.webdeveloper-display-object-information");
467 // Displays the stack level of all elements on the page
468 function webdeveloper_displayStackLevels(element
)
470 var display
= element
.getAttribute("checked");
471 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
472 var documentLength
= documentList
.length
;
473 var pageDocument
= null;
474 var pageElement
= null;
475 var spanElement
= null;
477 var treeWalker
= null;
479 // Loop through the documents
480 for(var i
= 0; i
< documentLength
; i
++)
482 pageDocument
= documentList
[i
];
484 // Need to do this to stop the feature running twice
485 webdeveloper_removeAllElementsByXPath(pageDocument
, "//span[@class='webdeveloper-display-stack-levels']");
490 treeWalker
= pageDocument
.createTreeWalker(pageDocument
, NodeFilter
.SHOW_ELEMENT
, webdeveloper_stackLevelFilter
, false);
492 // While the tree walker has more nodes
493 while((pageElement
= treeWalker
.nextNode()) != null)
495 spanElement
= pageDocument
.createElement("span");
496 text
= webdeveloper_getElementDescription(pageElement
) + " Z-index=" + pageElement
.ownerDocument
.defaultView
.getComputedStyle(pageElement
, null).getPropertyCSSValue("z-index").cssText
;
498 spanElement
.setAttribute("class", "webdeveloper-display-stack-levels");
499 spanElement
.setAttribute("title", text
);
500 spanElement
.appendChild(pageDocument
.createTextNode(text
));
502 webdeveloper_insertAsFirstChild(pageElement
, spanElement
);
507 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-stack-levels");
508 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-stack-levels-tooltips", "span.webdeveloper-display-stack-levels");
511 // Displays all tab indices
512 function webdeveloper_displayTabIndex(element
)
514 var checked
= element
.getAttribute("checked");
515 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
516 var documentLength
= documentList
.length
;
517 var pageDocument
= null;
518 var spanElement
= null;
519 var tabIndexElement
= null;
520 var tabIndexElementList
= null;
521 var tabIndexElementsLength
= null;
524 // Loop through the documents
525 for(var i
= 0; i
< documentLength
; i
++)
527 pageDocument
= documentList
[i
];
529 // Need to do this to stop the feature running twice
530 webdeveloper_removeAllElementsByXPath(pageDocument
, "//span[@class='webdeveloper-display-tab-index']");
532 // If the element is checked
535 tabIndexElementList
= webdeveloper_evaluateXPath(pageDocument
, "//*[@tabindex]");
536 tabIndexElementsLength
= tabIndexElementList
.length
;
538 // Loop through all the tab index elements
539 for(var j
= 0; j
< tabIndexElementsLength
; j
++)
541 spanElement
= pageDocument
.createElement("span");
542 tabIndexElement
= tabIndexElementList
[j
];
543 text
= "Tabindex=" + tabIndexElement
.getAttribute("tabindex");
545 spanElement
.setAttribute("class", "webdeveloper-display-tab-index");
546 spanElement
.setAttribute("title", text
);
547 spanElement
.appendChild(document
.createTextNode(text
));
548 tabIndexElement
.parentNode
.insertBefore(spanElement
, tabIndexElement
);
553 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-tab-index");
554 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-tab-index-tooltips", "span.webdeveloper-display-tab-index");
557 // Displays the depth of all tables
558 function webdeveloper_displayTableDepth(element
)
560 var checked
= element
.getAttribute("checked");
561 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
562 var documentLength
= documentList
.length
;
563 var pageDocument
= null;
564 var spanElement
= null;
565 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
566 var tableElement
= null;
567 var tableElementList
= null;
568 var tableElementsLength
= null;
571 // Loop through the documents
572 for(var i
= 0; i
< documentLength
; i
++)
574 pageDocument
= documentList
[i
];
576 // Need to do this to stop the feature running twice
577 webdeveloper_removeAllElementsByXPath(pageDocument
, "//span[@class='webdeveloper-display-table-depth']");
579 // If the element is checked
582 tableElementList
= pageDocument
.getElementsByTagName("table");
583 tableElementsLength
= tableElementList
.length
;
585 // Loop through all the table elements
586 for(var j
= 0; j
< tableElementsLength
; j
++)
588 spanElement
= pageDocument
.createElement("span");
589 tableElement
= tableElementList
[j
];
590 text
= stringBundle
.getString("webdeveloper_depth") + "=" + webdeveloper_getTableDepth(tableElement
);
592 spanElement
.setAttribute("class", "webdeveloper-display-table-depth");
593 spanElement
.setAttribute("title", text
);
594 spanElement
.appendChild(document
.createTextNode(text
));
595 tableElement
.parentNode
.insertBefore(spanElement
, tableElement
);
600 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-table-depth");
601 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-table-depth-tooltips", "span.webdeveloper-display-table-depth");
604 // Displays table information
605 function webdeveloper_displayTableInformation(element
)
607 var checked
= element
.getAttribute("checked");
608 var divElement
= null;
609 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
610 var documentLength
= documentList
.length
;
611 var pageDocument
= null;
612 var tableCellElementList
= null;
613 var tableCellElementsLength
= null;
614 var tableElement
= null;
615 var tableElementList
= null;
616 var tableElementsLength
= null;
618 // Loop through the documents
619 for(var i
= 0; i
< documentLength
; i
++)
621 pageDocument
= documentList
[i
];
623 // Need to do this to stop the feature running twice
624 webdeveloper_removeAllElementsByXPath(pageDocument
, "//div[@class='webdeveloper-display-table-information']");
626 // If the element is checked
629 tableElementList
= pageDocument
.getElementsByTagName("table");
630 tableElementsLength
= tableElementList
.length
;
632 // Loop through all the table elements
633 for(var j
= 0; j
< tableElementsLength
; j
++)
635 tableElement
= tableElementList
[j
];
636 tableCellElementList
= tableElement
.getElementsByTagName("th");
637 tableCellElementsLength
= tableCellElementList
.length
;
639 // If the table has a summary attribute
640 if(tableElement
.hasAttribute("summary"))
642 divElement
= pageDocument
.createElement("div");
644 divElement
.setAttribute("class", "webdeveloper-display-table-information");
645 divElement
.appendChild(pageDocument
.createTextNode("Summary=" + tableElement
.getAttribute("summary")));
646 tableElement
.parentNode
.insertBefore(divElement
, tableElement
);
649 // Loop through the cell elements
650 for(var k
= 0; k
< tableCellElementsLength
; k
++)
652 webdeveloper_outputTableCellInformation(tableCellElementList
[k
], pageDocument
);
655 tableCellElementList
= tableElement
.getElementsByTagName("td");
656 tableCellElementsLength
= tableCellElementList
.length
;
658 // Loop through the cell elements
659 for(k
= 0; k
< tableCellElementsLength
; k
++)
661 webdeveloper_outputTableCellInformation(tableCellElementList
[k
], pageDocument
);
667 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/display_table_information.css", "webdeveloper-display-table-information");
668 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-table-information-tooltips", "div.webdeveloper-display-table-information");
671 // Displays all title attributes
672 function webdeveloper_displayTitleAttributes(element
)
674 var checked
= element
.getAttribute("checked");
675 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
676 var documentLength
= documentList
.length
;
677 var pageDocument
= null;
678 var spanElement
= null;
680 var titleAttributeElement
= null;
681 var titleAttributeElementList
= null;
682 var titleAttributeElementsLength
= null;
684 // Loop through the documents
685 for(var i
= 0; i
< documentLength
; i
++)
687 pageDocument
= documentList
[i
];
689 // Need to do this to stop the feature running twice
690 webdeveloper_removeAllElementsByXPath(pageDocument
, "//span[@class='webdeveloper-display-title-attributes']");
692 // If the element is checked
695 titleAttributeElementList
= webdeveloper_evaluateXPath(pageDocument
, "//*[@title]");
696 titleAttributeElementsLength
= titleAttributeElementList
.length
;
698 // Loop through all the title attribute elements
699 for(var j
= 0; j
< titleAttributeElementsLength
; j
++)
701 spanElement
= pageDocument
.createElement("span");
702 titleAttributeElement
= titleAttributeElementList
[j
];
703 text
= "Title=" + titleAttributeElement
.getAttribute("title");
705 spanElement
.setAttribute("class", "webdeveloper-display-title-attributes");
706 spanElement
.setAttribute("title", text
);
707 spanElement
.appendChild(pageDocument
.createTextNode(text
));
708 titleAttributeElement
.parentNode
.insertBefore(spanElement
, titleAttributeElement
);
713 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-title-attributes");
714 webdeveloper_toggleFeatureTooltipStyles(element
, "webdeveloper-display-title-attributes-tooltips", "span.webdeveloper-display-title-attributes");
717 // Displays the topographic information for all elements
718 function webdeveloper_displayTopographicInformation(element
)
720 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/display_topographic_information.css", "webdeveloper-display-topographic-information");
723 // Formats a CSS color
724 function webdeveloper_formatColor(color
)
726 var formattedColor
= color
.toString(16);
728 // If the formatted color is less than 2 characters long
729 if(formattedColor
.length
< 2)
731 return "0" + formattedColor
;
735 return formattedColor
;
739 // Returns the depth of the table
740 function webdeveloper_getTableDepth(table
)
744 // If the table is set
747 var ancestorList
= webdeveloper_getElementAncestors(table
);
748 var ancestorLength
= ancestorList
.length
;
751 // Loop through the ancestors
752 for(var i
= 0; i
< ancestorLength
; i
++)
754 tagName
= ancestorList
[i
].tagName
;
756 // If the tag name is set and equals table
757 if(tagName
&& tagName
.toLowerCase() == "table")
767 // Returns the text from a table heading
768 function webdeveloper_getTableHeadingText(headingNode
, headingText
)
770 // If the heading node is set
773 var childNode
= null;
774 var childNodeList
= headingNode
.childNodes
;
775 var childNodeLength
= childNodeList
.length
;
776 var childNodeType
= null;
778 // Loop through the child nodes
779 for(var i
= 0; i
< childNodeLength
; i
++)
781 childNode
= childNodeList
[i
];
782 childNodeType
= childNode
.nodeType
;
784 // If the child node type is an element and it does not have a webdeveloper-table-information class
785 if(childNodeType
== Node
.ELEMENT_NODE
&& (!childNode
.hasAttribute("class") || childNode
.getAttribute("class") != "webdeveloper-table-information"))
787 headingText
= webdeveloper_getTableHeadingText(childNode
, headingText
);
789 else if(childNodeType
== Node
.TEXT_NODE
)
791 headingText
+= childNode
.nodeValue
+ " ";
796 return headingText
.trim();
799 // Outputs the information for a table cell
800 function webdeveloper_outputTableCellInformation(tableCellElement
, pageDocument
)
802 // If the table cell element is set
805 var divElement
= null;
807 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
809 // If the table cell has a headers attribute
810 if(tableCellElement
.hasAttribute("headers"))
812 var definitionElement
= pageDocument
.createElement("dd");
813 var headerList
= tableCellElement
.getAttribute("headers").split(" ");
814 var headersLength
= headerList
.length
;
816 // Loop through the headers
817 for(var i
= 0; i
< headersLength
; i
++)
819 pElement
= pageDocument
.createElement("p");
820 pElement
.appendChild(pageDocument
.createTextNode(webdeveloper_getTableHeadingText(pageDocument
.getElementById(headerList
[i
]), "")));
821 definitionElement
.appendChild(pElement
);
824 // If the definition element has child nodes
825 if(definitionElement
.childNodes
.length
> 0)
827 var listElement
= pageDocument
.createElement("dl");
828 var termElement
= pageDocument
.createElement("dt");
830 divElement
= pageDocument
.createElement("div");
832 termElement
.appendChild(pageDocument
.createTextNode(stringBundle
.getString("webdeveloper_headers")));
833 listElement
.appendChild(termElement
);
834 listElement
.appendChild(definitionElement
);
836 divElement
.setAttribute("class", "webdeveloper-table-information");
837 divElement
.appendChild(listElement
);
838 tableCellElement
.appendChild(divElement
);
842 divElement
= pageDocument
.createElement("div");
844 // If the table cell has a scope attribute
845 if(tableCellElement
.hasAttribute("scope"))
847 var scope
= tableCellElement
.getAttribute("scope");
849 pElement
= pageDocument
.createElement("p");
851 // If the scope is col
854 pElement
.appendChild(pageDocument
.createTextNode(stringBundle
.getString("webdeveloper_tableInformationHeadingColumn")));
856 else if(scope
== "colgroup")
858 pElement
.appendChild(pageDocument
.createTextNode(stringBundle
.getString("webdeveloper_tableInformationHeadingColumnGroup")));
860 else if(scope
== "row")
862 pElement
.appendChild(pageDocument
.createTextNode(stringBundle
.getString("webdeveloper_tableInformationHeadingRow")));
864 else if(scope
== "rowgroup")
866 pElement
.appendChild(pageDocument
.createTextNode(stringBundle
.getString("webdeveloper_tableInformationHeadingRowGroup")));
869 divElement
.appendChild(pElement
);
872 // If the table cell has an abbr attribute
873 if(tableCellElement
.hasAttribute("abbr"))
875 pElement
= pageDocument
.createElement("p");
876 pElement
.appendChild(pageDocument
.createTextNode(stringBundle
.getString("webdeveloper_abbreviation") + "=" + tableCellElement
.getAttribute("abbr")));
877 divElement
.appendChild(pElement
);
880 // If the table cell has an axis attribute
881 if(tableCellElement
.hasAttribute("axis"))
883 pElement
= pageDocument
.createElement("p");
884 pElement
.appendChild(pageDocument
.createTextNode(stringBundle
.getString("webdeveloper_axis") + "=" + tableCellElement
.getAttribute("axis")));
885 divElement
.appendChild(pElement
);
888 // If the div element has child nodes
889 if(divElement
.childNodes
.length
> 0)
891 divElement
.setAttribute("class", "webdeveloper-table-information");
892 tableCellElement
.appendChild(divElement
);
897 // Sets the image file sizes for a list of images
898 function webdeveloper_setImageFileSizes(imageList
)
901 var imageListLength
= imageList
.length
;
902 var newImageList
= new Array();
904 // Loop through the images
905 for(var i
= 0; i
< imageListLength
; i
++)
907 image
= imageList
[i
];
908 image
.fileSize
= webdeveloper_getFileSize(image
.src
);
910 newImageList
.push(image
);
916 // Sets the script file sizes for a list of scripts
917 function webdeveloper_setScriptFileSizes(scriptList
)
920 var scriptListLength
= scriptList
.length
;
921 var newScriptList
= new Array();
923 // Loop through the images
924 for(var i
= 0; i
< scriptListLength
; i
++)
926 script
= scriptList
[i
];
927 script
.fileSize
= webdeveloper_getFileSize(script
.src
);
928 script
.uncompressedFileSize
= webdeveloper_getUncompressedFileSize(script
.src
);
930 newScriptList
.push(script
);
933 return newScriptList
;
936 // Sets the style sheet file sizes for a list of style sheets
937 function webdeveloper_setStyleSheetFileSizes(styleSheetList
)
939 var styleSheet
= null;
940 var styleSheetListLength
= styleSheetList
.length
;
941 var newStyleSheetList
= new Array();
943 // Loop through the style sheets
944 for(var i
= 0; i
< styleSheetListLength
; i
++)
946 styleSheet
= styleSheetList
[i
];
947 styleSheet
.fileSize
= webdeveloper_getFileSize(styleSheet
.href
);
948 styleSheet
.uncompressedFileSize
= webdeveloper_getUncompressedFileSize(styleSheet
.href
);
950 newStyleSheetList
.push(styleSheet
);
953 return newStyleSheetList
;
957 function webdeveloper_sortAnchors(anchorOne
, anchorTwo
)
959 // If both anchors are set
960 if(anchorOne
&& anchorTwo
)
962 var anchorOneLink
= null;
963 var anchorTwoLink
= null;
965 // If the first anchor has an id attribute
966 if(anchorOne
.hasAttribute("id"))
968 anchorOneLink
= anchorOne
.getAttribute("id");
970 else if(anchorOne
.hasAttribute("name"))
972 anchorOneLink
= anchorOne
.getAttribute("name");
975 // If the second anchor has an id attribute
976 if(anchorTwo
.hasAttribute("id"))
978 anchorTwoLink
= anchorTwo
.getAttribute("id");
980 else if(anchorTwo
.hasAttribute("name"))
982 anchorTwoLink
= anchorTwo
.getAttribute("name");
985 // If the anchor links are equal
986 if(anchorOneLink
== anchorTwoLink
)
990 else if(anchorOneLink
< anchorTwoLink
)
999 // Sorts two documents
1000 function webdeveloper_sortDocuments(documentOne
, documentTwo
)
1002 // If both documents are set
1003 if(documentOne
&& documentTwo
)
1005 var documentOneURL
= documentOne
.documentURI
;
1006 var documentTwoURL
= documentTwo
.documentURI
;
1008 // If the documents are equal
1009 if(documentOneURL
== documentTwoURL
)
1013 else if(documentOneURL
< documentTwoURL
)
1022 // Sorts two documents by file size
1023 function webdeveloper_sortDocumentsByFileSize(documentOne
, documentTwo
)
1025 // If both documents and their URLs are set
1026 if(documentOne
&& documentTwo
&& documentOne
.documentURI
&& documentTwo
.documentURI
)
1028 var documentOneFileSize
= webdeveloper_getFileSize(documentOne
.documentURI
);
1029 var documentTwoFileSize
= webdeveloper_getFileSize(documentTwo
.documentURI
);
1031 // If the document file sizes are equal
1032 if(documentOneFileSize
== documentTwoFileSize
)
1034 return webdeveloper_sortDocuments(documentOne
, documentTwo
);
1036 else if(documentOneFileSize
> documentTwoFileSize
)
1045 // Sorts two images by file size
1046 function webdeveloper_sortImagesByFileSize(imageOne
, imageTwo
)
1048 // If both images and their file sizes are set
1049 if(imageOne
&& imageTwo
&& imageOne
.fileSize
&& imageTwo
.fileSize
)
1051 var imageOneFileSize
= imageOne
.fileSize
;
1052 var imageTwoFileSize
= imageTwo
.fileSize
;
1054 // If the image file sizes are equal
1055 if(imageOneFileSize
== imageTwoFileSize
)
1057 return webdeveloper_sortImages(imageOne
, imageTwo
);
1059 else if(imageOneFileSize
> imageTwoFileSize
)
1069 function webdeveloper_sortLinks(linkOne
, linkTwo
)
1071 // If both links are set
1072 if(linkOne
&& linkTwo
)
1074 var linkOneHref
= linkOne
.href
;
1075 var linkTwoHref
= linkTwo
.href
;
1077 // If the links are equal
1078 if(linkOneHref
== linkTwoHref
)
1082 else if(linkOneHref
< linkTwoHref
)
1091 // Sorts two scripts
1092 function webdeveloper_sortScripts(scriptOne
, scriptTwo
)
1094 // If both scripts and src are set
1095 if(scriptOne
&& scriptTwo
&& scriptOne
.src
&& scriptTwo
.src
)
1097 var scriptOneSrc
= scriptOne
.src
;
1098 var scriptTwoSrc
= scriptTwo
.src
;
1100 // If the scripts are equal
1101 if(scriptOneSrc
== scriptTwoSrc
)
1105 else if(scriptOneSrc
< scriptTwoSrc
)
1114 // Sorts two scripts by file size
1115 function webdeveloper_sortScriptsByFileSize(scriptOne
, scriptTwo
)
1117 // If both scripts and src are set
1118 if(scriptOne
&& scriptTwo
&& scriptOne
.src
&& scriptTwo
.src
)
1120 var scriptOneFileSize
= webdeveloper_getFileSize(scriptOne
.src
);
1121 var scriptTwoFileSize
= webdeveloper_getFileSize(scriptTwo
.src
);
1123 // If the script file sizes are equal
1124 if(scriptOneFileSize
== scriptTwoFileSize
)
1126 return webdeveloper_sortScripts(scriptOne
, scriptTwo
);
1128 else if(scriptOneFileSize
> scriptTwoFileSize
)
1137 // Sorts two style sheets
1138 function webdeveloper_sortStyleSheets(styleSheetOne
, styleSheetTwo
)
1140 // If both style sheets and href are set
1141 if(styleSheetOne
&& styleSheetTwo
&& styleSheetOne
.href
&& styleSheetTwo
.href
)
1143 var styleSheetOneSrc
= styleSheetOne
.href
;
1144 var styleSheetTwoSrc
= styleSheetTwo
.href
;
1146 // If the style sheets are equal
1147 if(styleSheetOneSrc
== styleSheetTwoSrc
)
1151 else if(styleSheetOneSrc
< styleSheetTwoSrc
)
1160 // Sorts two style sheets by file size
1161 function webdeveloper_sortStyleSheetsByFileSize(styleSheetOne
, styleSheetTwo
)
1163 // If both style sheets and href are set
1164 if(styleSheetOne
&& styleSheetTwo
&& styleSheetOne
.href
&& styleSheetTwo
.href
)
1166 var styleSheetOneFileSize
= webdeveloper_getFileSize(styleSheetOne
.href
);
1167 var styleSheetTwoFileSize
= webdeveloper_getFileSize(styleSheetTwo
.href
);
1169 // If the style sheet file sizes are equal
1170 if(styleSheetOneFileSize
== styleSheetTwoFileSize
)
1172 return webdeveloper_sortStyleSheets(styleSheetOne
, styleSheetTwo
);
1174 else if(styleSheetOneFileSize
> styleSheetTwoFileSize
)
1183 // Filter for stack level tree walker
1184 function webdeveloper_stackLevelFilter(node
)
1186 // If the node has a class attribute and it starts with webdeveloper
1187 if(node
&& (!node
.hasAttribute("class") || node
.getAttribute("class").indexOf("webdeveloper-") != 0))
1189 var zIndex
= node
.ownerDocument
.defaultView
.getComputedStyle(node
, null).getPropertyCSSValue("z-index").cssText
;
1191 // If the node has a z-index and it is not set to auto
1192 if(zIndex
&& zIndex
!= "auto")
1194 return NodeFilter
.FILTER_ACCEPT
;
1198 return NodeFilter
.FILTER_SKIP
;
1201 // Tidies a list of anchors by removing duplicates and sorting
1202 function webdeveloper_tidyAnchors(anchorList
)
1205 var anchorLink
= null;
1206 var anchorListLength
= anchorList
.length
;
1207 var newAnchorList
= new Array();
1208 var newAnchorListLength
= null;
1209 var nextAnchor
= null;
1210 var nextAnchorLink
= null;
1211 var tidiedAnchorList
= new Array();
1213 // Loop through the anchors
1214 for(var i
= 0; i
< anchorListLength
; i
++)
1216 newAnchorList
.push(anchorList
[i
]);
1219 newAnchorList
.sort(webdeveloper_sortAnchors
);
1221 newAnchorListLength
= newAnchorList
.length
;
1223 // Loop through the anchors
1224 for(i
= 0; i
< newAnchorListLength
; i
++)
1226 anchor
= newAnchorList
[i
];
1228 // If the anchor has an id attribute
1229 if(anchor
.hasAttribute("id"))
1231 anchorLink
= anchor
.getAttribute("id");
1235 anchorLink
= anchor
.getAttribute("name");
1238 // If this is not the last anchor
1239 if(i
+ 1 < newAnchorListLength
)
1241 nextAnchor
= newAnchorList
[i
+ 1];
1243 // If the next anchor has an id attribute
1244 if(nextAnchor
.hasAttribute("id"))
1246 nextAnchorLink
= nextAnchor
.getAttribute("id");
1250 nextAnchorLink
= nextAnchor
.getAttribute("name");
1253 // If the anchor link is the same as the next anchor link
1254 if(anchorLink
== nextAnchorLink
)
1260 tidiedAnchorList
.push(anchor
);
1263 return tidiedAnchorList
;
1266 // Tidies a list of colors by removing duplicates and sorting
1267 function webdeveloper_tidyColors(colorList
)
1270 var colorListLength
= colorList
.length
;
1271 var newColorList
= new Array();
1272 var newColorListLength
= null;
1273 var tidiedColorList
= new Array();
1275 // Loop through the colors
1276 for(var i
= 0; i
< colorListLength
; i
++)
1278 newColorList
.push(colorList
[i
]);
1281 newColorList
.sort();
1283 newColorListLength
= newColorList
.length
;
1285 // Loop through the colors
1286 for(i
= 0; i
< newColorListLength
; i
++)
1288 color
= newColorList
[i
];
1290 // If this is not the last color and the color is the same as the next color
1291 if(i
+ 1 < newColorListLength
&& color
== newColorList
[i
+ 1])
1296 tidiedColorList
.push(color
);
1299 return tidiedColorList
;
1302 // Tidies a list of documents by removing duplicates and sorting
1303 function webdeveloper_tidyDocuments(documentList
)
1305 var documentListLength
= documentList
.length
;
1306 var documentURL
= null;
1307 var newDocumentList
= new Array();
1308 var newDocumentListLength
= null;
1309 var pageDocument
= null;
1310 var tidiedDocumentList
= new Array();
1312 // Loop through the documents
1313 for(var i
= 0; i
< documentListLength
; i
++)
1315 newDocumentList
.push(documentList
[i
]);
1318 newDocumentList
.sort(webdeveloper_sortDocuments
);
1320 newDocumentListLength
= newDocumentList
.length
;
1322 // Loop through the documents
1323 for(i
= 0; i
< newDocumentListLength
; i
++)
1325 pageDocument
= newDocumentList
[i
];
1327 // If this is not the last document and the document is the same as the next document
1328 if(i
+ 1 < newDocumentListLength
&& pageDocument
.documentURI
== newDocumentList
[i
+ 1].documentURI
)
1333 tidiedDocumentList
.push(pageDocument
);
1336 return tidiedDocumentList
;
1339 // Tidies a list of links by removing duplicates and sorting
1340 function webdeveloper_tidyLinks(linkList
)
1343 var linkListLength
= linkList
.length
;
1344 var newLinkList
= new Array();
1345 var newLinkListLength
= null;
1346 var tidiedLinkList
= new Array();
1348 // Loop through the links
1349 for(var i
= 0; i
< linkListLength
; i
++)
1353 // If this link is set
1356 newLinkList
.push(link
);
1360 newLinkList
.sort(webdeveloper_sortLinks
);
1362 newLinkListLength
= newLinkList
.length
;
1364 // Loop through the links
1365 for(i
= 0; i
< newLinkListLength
; i
++)
1367 link
= newLinkList
[i
];
1369 // If this is not the last link and the link is the same as the next link
1370 if(i
+ 1 < newLinkListLength
&& link
.href
== newLinkList
[i
+ 1].href
)
1375 tidiedLinkList
.push(link
);
1378 return tidiedLinkList
;
1381 // Tidies a list of scripts by removing duplicates and sorting
1382 function webdeveloper_tidyScripts(scriptList
)
1385 var scriptListLength
= scriptList
.length
;
1386 var newScriptList
= new Array();
1387 var newScriptListLength
= null;
1388 var tidiedScriptList
= new Array();
1390 // Loop through the scripts
1391 for(var i
= 0; i
< scriptListLength
; i
++)
1393 script
= scriptList
[i
];
1395 // If this script and the src is set
1396 if(script
&& script
.src
)
1398 newScriptList
.push(script
);
1402 newScriptList
.sort(webdeveloper_sortScripts
);
1404 newScriptListLength
= newScriptList
.length
;
1406 // Loop through the scripts
1407 for(i
= 0; i
< newScriptListLength
; i
++)
1409 script
= newScriptList
[i
];
1411 // If this is not the last script and the script is the same as the next script
1412 if(i
+ 1 < newScriptListLength
&& script
.src
== newScriptList
[i
+ 1].src
)
1417 tidiedScriptList
.push(script
);
1420 return tidiedScriptList
;
1423 // Tidies a list of style sheets by removing duplicates and sorting
1424 function webdeveloper_tidyStyleSheets(styleSheetList
)
1426 var styleSheet
= null;
1427 var styleSheetListLength
= styleSheetList
.length
;
1428 var newStyleSheetList
= new Array();
1429 var newStyleSheetListLength
= null;
1430 var tidiedStyleSheetList
= new Array();
1432 // Loop through the style sheets
1433 for(var i
= 0; i
< styleSheetListLength
; i
++)
1435 styleSheet
= styleSheetList
[i
];
1437 // If this style sheet and the href is set
1438 if(styleSheet
&& styleSheet
.href
)
1440 newStyleSheetList
.push(styleSheet
);
1444 newStyleSheetList
.sort(webdeveloper_sortStyleSheets
);
1446 newStyleSheetListLength
= newStyleSheetList
.length
;
1448 // Loop through the style sheets
1449 for(i
= 0; i
< newStyleSheetListLength
; i
++)
1451 styleSheet
= newStyleSheetList
[i
];
1453 // If this is not the last style sheet and the style sheet is the same as the next style sheet
1454 if(i
+ 1 < newStyleSheetListLength
&& styleSheet
.href
== newStyleSheetList
[i
+ 1].href
)
1459 tidiedStyleSheetList
.push(styleSheet
);
1462 return tidiedStyleSheetList
;
1465 // Updates the information menu
1466 function webdeveloper_updateInformationMenu(suffix
)
1468 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-abbreviations-" + suffix
), "checked", "webdeveloper-display-abbreviations");
1469 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-access-keys-" + suffix
), "checked", "webdeveloper-display-access-keys");
1470 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-anchors-" + suffix
), "checked", "webdeveloper-display-anchors");
1471 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-block-size-" + suffix
), "checked", "webdeveloper-display-block-size");
1472 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-div-order-" + suffix
), "checked", "webdeveloper-display-div-order");
1473 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-element-information-" + suffix
), "checked", "webdeveloper-display-element-information");
1474 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-id-class-details-" + suffix
), "checked", "webdeveloper-display-id-class-details");
1475 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-link-details-" + suffix
), "checked", "webdeveloper-display-link-details");
1476 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-object-information-" + suffix
), "checked", "webdeveloper-display-object-information");
1477 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-stack-levels-" + suffix
), "checked", "webdeveloper-display-stack-levels");
1478 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-tab-index-" + suffix
), "checked", "webdeveloper-display-tab-index");
1479 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-table-depth-" + suffix
), "checked", "webdeveloper-display-table-depth");
1480 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-table-information-" + suffix
), "checked", "webdeveloper-display-table-information");
1481 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-title-attributes-" + suffix
), "checked", "webdeveloper-display-title-attributes");
1482 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-topographic-information-" + suffix
), "checked", "webdeveloper-display-topographic-information");
1485 // Displays all the anchors for the page
1486 function webdeveloper_viewAnchorInformation()
1489 var anchorLength
= null;
1490 var anchorLink
= null;
1491 var anchorList
= null;
1492 var divElement
= null;
1493 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
1494 var documentLength
= documentList
.length
;
1495 var documentURL
= null;
1496 var linkElement
= null;
1497 var linkHref
= null;
1498 var linkLength
= null;
1499 var listElement
= null;
1500 var listItemElement
= null;
1501 var oldTab
= getBrowser().selectedTab
;
1502 var oldURL
= getBrowser().currentURI
.spec
;
1503 var generatedDocument
= webdeveloper_generateDocument("");
1504 var bodyElement
= webdeveloper_getDocumentBodyElement(generatedDocument
);
1505 var headElement
= webdeveloper_getDocumentHeadElement(generatedDocument
);
1506 var headerElement
= generatedDocument
.createElement("h1");
1507 var pageDocument
= null;
1508 var pElement
= null;
1509 var scriptElement
= generatedDocument
.createElement("script");
1510 var spanElement
= null;
1511 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
1512 var title
= stringBundle
.getFormattedString("webdeveloper_viewAnchorInformationTitle", [oldURL
]);
1514 generatedDocument
.title
= title
;
1516 webdeveloper_addGeneratedStyles(generatedDocument
);
1518 headerElement
.appendChild(generatedDocument
.createTextNode(title
));
1519 bodyElement
.appendChild(headerElement
);
1521 webdeveloper_addGeneratedTools(generatedDocument
);
1523 // Loop through the documents
1524 for(var i
= 0; i
< documentLength
; i
++)
1526 divElement
= generatedDocument
.createElement("div");
1527 headerElement
= generatedDocument
.createElement("h2");
1528 linkElement
= generatedDocument
.createElement("a");
1529 pageDocument
= documentList
[i
];
1530 anchorList
= webdeveloper_evaluateXPath(pageDocument
, "//*[@id] | //a[@name]");
1531 documentURL
= pageDocument
.documentURI
;
1532 spanElement
= generatedDocument
.createElement("span");
1534 // If the tidy information preference is set
1535 if(webdeveloper_getBooleanPreference("webdeveloper.information.tidy", true))
1537 anchorList
= webdeveloper_tidyAnchors(anchorList
);
1540 spanElement
.setAttribute("class", "expanded pivot");
1541 headerElement
.appendChild(spanElement
);
1542 linkElement
.setAttribute("href", documentURL
);
1543 linkElement
.appendChild(generatedDocument
.createTextNode(documentURL
));
1544 headerElement
.appendChild(linkElement
);
1545 bodyElement
.appendChild(headerElement
);
1547 anchorLength
= anchorList
.length
;
1549 // If there are no anchors
1550 if(anchorLength
== 0)
1552 pElement
= generatedDocument
.createElement("p");
1554 pElement
.appendChild(generatedDocument
.createTextNode(stringBundle
.getString("webdeveloper_noAnchors")));
1555 divElement
.appendChild(pElement
);
1559 listElement
= generatedDocument
.createElement("ol");
1561 // Loop through the links
1562 for(var j
= 0; j
< anchorLength
; j
++)
1564 anchor
= anchorList
[j
];
1566 // If the anchor has an id attribute
1567 if(anchor
.hasAttribute("id"))
1569 anchorLink
= "#" + anchor
.getAttribute("id");
1573 anchorLink
= "#" + anchor
.getAttribute("name");
1576 linkElement
= generatedDocument
.createElement("a");
1577 listItemElement
= generatedDocument
.createElement("li");
1579 linkElement
.setAttribute("href", documentURL
+ anchorLink
);
1580 linkElement
.appendChild(generatedDocument
.createTextNode(anchorLink
));
1581 listItemElement
.appendChild(linkElement
);
1582 listElement
.appendChild(listItemElement
);
1585 divElement
.appendChild(listElement
);
1588 divElement
.setAttribute("class", "output");
1589 bodyElement
.appendChild(divElement
);
1592 scriptElement
.setAttribute("defer", "defer");
1593 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
1594 scriptElement
.setAttribute("type", "text/javascript");
1595 headElement
.appendChild(scriptElement
);
1597 scriptElement
= generatedDocument
.createElement("script");
1599 scriptElement
.setAttribute("defer", "defer");
1600 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
1601 scriptElement
.setAttribute("type", "text/javascript");
1602 headElement
.appendChild(scriptElement
);
1604 // If the open tabs in background preference is set to true
1605 if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
1607 getBrowser().selectedTab
= oldTab
;
1611 // Displays all the colors on the page
1612 function webdeveloper_viewColorInformation()
1615 var colorList
= null;
1616 var colorsLength
= null;
1617 var definitionElement
= null;
1618 var definitionListElement
= null;
1619 var divElement
= null;
1620 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
1621 var documentLength
= documentList
.length
;
1622 var documentURL
= null;
1624 var oldTab
= getBrowser().selectedTab
;
1625 var oldURL
= getBrowser().currentURI
.spec
;
1626 var generatedDocument
= webdeveloper_generateDocument("");
1627 var bodyElement
= webdeveloper_getDocumentBodyElement(generatedDocument
);
1628 var headElement
= webdeveloper_getDocumentHeadElement(generatedDocument
);
1629 var headerElement
= generatedDocument
.createElement("h1");
1630 var linkElement
= generatedDocument
.createElement("link");
1631 var pageDocument
= null;
1632 var scriptElement
= generatedDocument
.createElement("script");
1633 var spanElement
= null;
1634 var termElement
= null;
1635 var title
= document
.getElementById("webdeveloper-string-bundle").getFormattedString("webdeveloper_viewColorInformationTitle", [oldURL
]);
1636 var treeWalker
= null;
1638 generatedDocument
.title
= title
;
1640 webdeveloper_addGeneratedStyles(generatedDocument
);
1642 linkElement
.setAttribute("href", "chrome://webdeveloper/content/stylesheets/generated/view_color_information.css");
1643 linkElement
.setAttribute("rel", "stylesheet");
1644 linkElement
.setAttribute("type", "text/css");
1645 headElement
.appendChild(linkElement
);
1647 headerElement
.appendChild(generatedDocument
.createTextNode(title
));
1648 bodyElement
.appendChild(headerElement
);
1650 webdeveloper_addGeneratedTools(generatedDocument
);
1652 // Loop through the documents
1653 for(var i
= 0; i
< documentLength
; i
++)
1655 colorList
= new Array();
1656 divElement
= generatedDocument
.createElement("div");
1657 headerElement
= generatedDocument
.createElement("h2");
1658 linkElement
= generatedDocument
.createElement("a");
1659 pageDocument
= documentList
[i
];
1660 documentURL
= pageDocument
.documentURI
;
1661 spanElement
= generatedDocument
.createElement("span");
1662 treeWalker
= pageDocument
.createTreeWalker(webdeveloper_getDocumentBodyElement(pageDocument
), NodeFilter
.SHOW_ELEMENT
, null, false);
1664 // Loop through the anchor elements
1665 while((element
= treeWalker
.nextNode()) != null)
1667 webdeveloper_addColor(element
, "background-color", colorList
);
1668 webdeveloper_addColor(element
, "border-bottom-color", colorList
);
1669 webdeveloper_addColor(element
, "border-left-color", colorList
);
1670 webdeveloper_addColor(element
, "border-right-color", colorList
);
1671 webdeveloper_addColor(element
, "border-top-color", colorList
);
1672 webdeveloper_addColor(element
, "color", colorList
);
1675 spanElement
.setAttribute("class", "expanded pivot");
1676 headerElement
.appendChild(spanElement
);
1677 linkElement
.setAttribute("href", documentURL
);
1678 linkElement
.appendChild(generatedDocument
.createTextNode(documentURL
));
1679 headerElement
.appendChild(linkElement
);
1680 bodyElement
.appendChild(headerElement
);
1682 colorList
= webdeveloper_tidyColors(colorList
);
1683 colorsLength
= colorList
.length
;
1685 // Loop through the colors
1686 for(var j
= 0; j
< colorsLength
; j
++)
1688 color
= colorList
[j
];
1689 definitionElement
= generatedDocument
.createElement("dd");
1690 definitionListElement
= generatedDocument
.createElement("dl");
1691 termElement
= generatedDocument
.createElement("dt");
1693 termElement
.appendChild(generatedDocument
.createTextNode(color
));
1694 definitionListElement
.appendChild(termElement
);
1696 definitionElement
.setAttribute("style", "background-color: " + color
);
1697 definitionListElement
.appendChild(definitionElement
);
1698 divElement
.appendChild(definitionListElement
);
1701 divElement
.setAttribute("class", "output");
1702 bodyElement
.appendChild(divElement
);
1705 scriptElement
.setAttribute("defer", "defer");
1706 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
1707 scriptElement
.setAttribute("type", "text/javascript");
1708 headElement
.appendChild(scriptElement
);
1710 scriptElement
= generatedDocument
.createElement("script");
1712 scriptElement
.setAttribute("defer", "defer");
1713 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
1714 scriptElement
.setAttribute("type", "text/javascript");
1715 headElement
.appendChild(scriptElement
);
1717 // If the open tabs in background preference is set to true
1718 if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
1720 getBrowser().selectedTab
= oldTab
;
1724 // Displays an outline of the page
1725 function webdeveloper_viewDocumentOutline()
1727 var divElement
= null;
1728 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
1729 var documentLength
= documentList
.length
;
1730 var documentURL
= null;
1731 var headerElementList
= null;
1732 var headerElementsLength
= null;
1733 var headerLevel
= null;
1734 var headerTagName
= null;
1735 var headerText
= null;
1736 var oldTab
= getBrowser().selectedTab
;
1737 var oldURL
= getBrowser().currentURI
.spec
;
1738 var generatedDocument
= webdeveloper_generateDocument("");
1739 var bodyElement
= webdeveloper_getDocumentBodyElement(generatedDocument
);
1740 var headElement
= webdeveloper_getDocumentHeadElement(generatedDocument
);
1741 var headerElement
= generatedDocument
.createElement("h1");
1742 var linkElement
= generatedDocument
.createElement("link");
1743 var outlineElement
= null;
1744 var pageDocument
= null;
1745 var previousHeaderLevel
= null;
1746 var scriptElement
= generatedDocument
.createElement("script");
1747 var spanElement
= null;
1748 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
1749 var title
= stringBundle
.getFormattedString("webdeveloper_viewDocumentOutlineTitle", [oldURL
]);
1750 var treeWalker
= null;
1752 generatedDocument
.title
= title
;
1754 webdeveloper_addGeneratedStyles(generatedDocument
);
1756 linkElement
.setAttribute("href", "chrome://webdeveloper/content/stylesheets/generated/view_document_outline.css");
1757 linkElement
.setAttribute("rel", "stylesheet");
1758 linkElement
.setAttribute("type", "text/css");
1759 headElement
.appendChild(linkElement
);
1761 headerElement
.appendChild(generatedDocument
.createTextNode(title
));
1762 bodyElement
.appendChild(headerElement
);
1764 webdeveloper_addGeneratedTools(generatedDocument
);
1766 // Loop through the documents
1767 for(var i
= 0; i
< documentLength
; i
++)
1769 divElement
= generatedDocument
.createElement("div");
1770 headerElement
= generatedDocument
.createElement("h2");
1771 linkElement
= generatedDocument
.createElement("a");
1772 pageDocument
= documentList
[i
];
1773 documentURL
= pageDocument
.documentURI
;
1774 headerElementList
= webdeveloper_evaluateXPath(pageDocument
, "//h1 | //h2 | //h3 | //h4 | //h5 | //h6");
1775 headerElementsLength
= headerElementList
.length
;
1776 previousHeaderLevel
= 0;
1777 spanElement
= generatedDocument
.createElement("span");
1779 spanElement
.setAttribute("class", "expanded pivot");
1780 headerElement
.appendChild(spanElement
);
1781 linkElement
.setAttribute("href", documentURL
);
1782 linkElement
.appendChild(generatedDocument
.createTextNode(documentURL
));
1783 headerElement
.appendChild(linkElement
);
1784 bodyElement
.appendChild(headerElement
);
1786 // Loop through the heading elements
1787 for(var j
= 0; j
< headerElementsLength
; j
++)
1789 headerElement
= headerElementList
[j
];
1790 headerTagName
= headerElement
.tagName
.toLowerCase();
1791 headerText
= webdeveloper_getElementText(headerElement
).trim();
1792 headerLevel
= parseInt(headerTagName
.substring(1));
1794 // Loop through any missing headers
1795 for(var k
= previousHeaderLevel
+ 1; k
< headerLevel
; k
++)
1797 outlineElement
= generatedDocument
.createElement("h" + k
);
1799 outlineElement
.setAttribute("class", "webdeveloper-document-outline webdeveloper-document-outline-missing");
1800 outlineElement
.appendChild(generatedDocument
.createTextNode(stringBundle
.getString("webdeveloper_viewDocumentOutlineMissingHeading")));
1801 divElement
.appendChild(outlineElement
);
1804 // If there is no header text
1807 headerText
= stringBundle
.getString("webdeveloper_viewDocumentOutlineEmptyHeading");
1810 outlineElement
= generatedDocument
.createElement(headerTagName
);
1812 outlineElement
.setAttribute("class", "webdeveloper-document-outline");
1813 outlineElement
.appendChild(generatedDocument
.createTextNode(headerText
));
1814 divElement
.appendChild(outlineElement
);
1816 previousHeaderLevel
= headerLevel
;
1819 divElement
.setAttribute("class", "output");
1820 bodyElement
.appendChild(divElement
);
1823 scriptElement
.setAttribute("defer", "defer");
1824 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
1825 scriptElement
.setAttribute("type", "text/javascript");
1826 headElement
.appendChild(scriptElement
);
1828 scriptElement
= generatedDocument
.createElement("script");
1830 scriptElement
.setAttribute("defer", "defer");
1831 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
1832 scriptElement
.setAttribute("type", "text/javascript");
1833 headElement
.appendChild(scriptElement
);
1835 // If the open tabs in background preference is set to true
1836 if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
1838 getBrowser().selectedTab
= oldTab
;
1843 function webdeveloper_viewJavaScript()
1845 var divElement
= null;
1846 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
1847 var documentLength
= documentList
.length
;
1848 var documentURL
= null;
1849 var linkElement
= null;
1850 var oldTab
= getBrowser().selectedTab
;
1851 var oldURL
= getBrowser().currentURI
.spec
;
1852 var generatedDocument
= webdeveloper_generateDocument("");
1853 var bodyElement
= webdeveloper_getDocumentBodyElement(generatedDocument
);
1854 var headElement
= webdeveloper_getDocumentHeadElement(generatedDocument
);
1855 var headerElement
= generatedDocument
.createElement("h1");
1856 var pageDocument
= null;
1857 var preElement
= null;
1858 var scriptElement
= null;
1859 var scriptLength
= null;
1860 var scriptList
= new Array();
1861 var scriptSource
= null;
1862 var spanElement
= null;
1863 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
1864 var title
= stringBundle
.getFormattedString("webdeveloper_viewJavaScriptTitle", [oldURL
]);
1866 generatedDocument
.title
= title
;
1868 webdeveloper_addGeneratedStyles(generatedDocument
);
1870 headerElement
.appendChild(generatedDocument
.createTextNode(title
));
1871 bodyElement
.appendChild(headerElement
);
1873 webdeveloper_addGeneratedTools(generatedDocument
);
1875 // Loop through the documents
1876 for(var i
= 0; i
< documentLength
; i
++)
1878 headerElement
= generatedDocument
.createElement("h2");
1879 linkElement
= generatedDocument
.createElement("a");
1880 pageDocument
= documentList
[i
];
1881 documentURL
= pageDocument
.documentURI
;
1882 scriptList
= pageDocument
.getElementsByTagName("script");
1883 scriptLength
= scriptList
.length
;
1885 linkElement
.setAttribute("href", pageDocument
.documentURI
);
1886 linkElement
.appendChild(generatedDocument
.createTextNode(documentURL
));
1887 headerElement
.appendChild(linkElement
);
1888 bodyElement
.appendChild(headerElement
);
1890 // Loop through the scripts
1891 for(var j
= 0; j
< scriptLength
; j
++)
1893 divElement
= generatedDocument
.createElement("div");
1894 headerElement
= generatedDocument
.createElement("h3");
1895 preElement
= generatedDocument
.createElement("pre");
1896 scriptElement
= scriptList
[j
];
1897 scriptSource
= scriptElement
.src
;
1898 spanElement
= generatedDocument
.createElement("span");
1900 // If the script is external
1903 // If this is a not chrome script
1904 if(scriptSource
.indexOf("chrome://") != 0)
1906 linkElement
= generatedDocument
.createElement("a");
1908 spanElement
.setAttribute("class", "expanded pivot");
1909 headerElement
.appendChild(spanElement
);
1910 linkElement
.setAttribute("href", scriptSource
);
1911 linkElement
.appendChild(generatedDocument
.createTextNode(scriptSource
));
1912 headerElement
.appendChild(linkElement
);
1913 bodyElement
.appendChild(headerElement
);
1915 preElement
.appendChild(generatedDocument
.createTextNode(webdeveloper_retrieveSource(scriptSource
).replace(new RegExp("\r", "gi"), "\n")));
1916 divElement
.setAttribute("class", "output");
1917 divElement
.appendChild(preElement
);
1918 bodyElement
.appendChild(divElement
);
1923 spanElement
.setAttribute("class", "expanded pivot");
1924 headerElement
.appendChild(spanElement
);
1925 headerElement
.appendChild(generatedDocument
.createTextNode(stringBundle
.getFormattedString("webdeveloper_inlineScript", [documentURL
])));
1926 bodyElement
.appendChild(headerElement
);
1928 preElement
.appendChild(generatedDocument
.createTextNode(scriptElement
.innerHTML
));
1929 divElement
.setAttribute("class", "output");
1930 divElement
.appendChild(preElement
);
1931 bodyElement
.appendChild(divElement
);
1936 scriptElement
= generatedDocument
.createElement("script");
1938 scriptElement
.setAttribute("defer", "defer");
1939 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
1940 scriptElement
.setAttribute("type", "text/javascript");
1941 headElement
.appendChild(scriptElement
);
1943 scriptElement
= generatedDocument
.createElement("script");
1945 scriptElement
.setAttribute("defer", "defer");
1946 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
1947 scriptElement
.setAttribute("type", "text/javascript");
1948 headElement
.appendChild(scriptElement
);
1950 // If the open tabs in background preference is set to true
1951 if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
1953 getBrowser().selectedTab
= oldTab
;
1957 // Displays all the links for the page
1958 function webdeveloper_viewLinkInformation()
1960 var divElement
= null;
1961 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
1962 var documentLength
= documentList
.length
;
1963 var documentURL
= null;
1965 var linkElement
= null;
1966 var linkHref
= null;
1967 var linkLength
= null;
1969 var listElement
= null;
1970 var listItemElement
= null;
1971 var oldTab
= getBrowser().selectedTab
;
1972 var oldURL
= getBrowser().currentURI
.spec
;
1973 var generatedDocument
= webdeveloper_generateDocument("");
1974 var bodyElement
= webdeveloper_getDocumentBodyElement(generatedDocument
);
1975 var headElement
= webdeveloper_getDocumentHeadElement(generatedDocument
);
1976 var headerElement
= generatedDocument
.createElement("h1");
1977 var pageDocument
= null;
1978 var pElement
= null;
1979 var scriptElement
= generatedDocument
.createElement("script");
1980 var spanElement
= null;
1981 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
1982 var title
= stringBundle
.getFormattedString("webdeveloper_viewLinkInformationTitle", [oldURL
]);
1984 generatedDocument
.title
= title
;
1986 webdeveloper_addGeneratedStyles(generatedDocument
);
1988 headerElement
.appendChild(generatedDocument
.createTextNode(title
));
1989 bodyElement
.appendChild(headerElement
);
1991 webdeveloper_addGeneratedTools(generatedDocument
);
1993 // Loop through the documents
1994 for(var i
= 0; i
< documentLength
; i
++)
1996 divElement
= generatedDocument
.createElement("div");
1997 headerElement
= generatedDocument
.createElement("h2");
1998 linkElement
= generatedDocument
.createElement("a");
1999 pageDocument
= documentList
[i
];
2000 documentURL
= pageDocument
.documentURI
;
2001 links
= pageDocument
.links
;
2002 spanElement
= generatedDocument
.createElement("span");
2004 // If the tidy information preference is set
2005 if(webdeveloper_getBooleanPreference("webdeveloper.information.tidy", true))
2007 links
= webdeveloper_tidyLinks(links
);
2010 spanElement
.setAttribute("class", "expanded pivot");
2011 headerElement
.appendChild(spanElement
);
2012 linkElement
.setAttribute("href", documentURL
);
2013 linkElement
.appendChild(generatedDocument
.createTextNode(documentURL
));
2014 headerElement
.appendChild(linkElement
);
2015 bodyElement
.appendChild(headerElement
);
2017 linkLength
= links
.length
;
2019 // If there are no links
2022 pElement
= generatedDocument
.createElement("p");
2024 pElement
.appendChild(generatedDocument
.createTextNode(stringBundle
.getString("webdeveloper_noLinks")));
2025 divElement
.appendChild(pElement
);
2029 listElement
= generatedDocument
.createElement("ol");
2031 // Loop through the links
2032 for(var j
= 0; j
< linkLength
; j
++)
2035 linkHref
= link
.href
;
2037 // If the link is set
2040 linkElement
= generatedDocument
.createElement("a");
2041 listItemElement
= generatedDocument
.createElement("li");
2043 linkElement
.setAttribute("href", linkHref
);
2044 linkElement
.appendChild(generatedDocument
.createTextNode(linkHref
));
2045 listItemElement
.appendChild(linkElement
);
2046 listElement
.appendChild(listItemElement
);
2050 divElement
.appendChild(listElement
);
2053 divElement
.setAttribute("class", "output");
2054 bodyElement
.appendChild(divElement
);
2057 scriptElement
.setAttribute("defer", "defer");
2058 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
2059 scriptElement
.setAttribute("type", "text/javascript");
2060 headElement
.appendChild(scriptElement
);
2062 scriptElement
= generatedDocument
.createElement("script");
2064 scriptElement
.setAttribute("defer", "defer");
2065 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
2066 scriptElement
.setAttribute("type", "text/javascript");
2067 headElement
.appendChild(scriptElement
);
2069 // If the open tabs in background preference is set to true
2070 if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
2072 getBrowser().selectedTab
= oldTab
;
2076 // Displays all the meta tags for the page
2077 function webdeveloper_viewMetaTagInformation()
2079 var cellDataElement
= null;
2080 var cellHeaderElement
= null;
2081 var divElement
= null;
2082 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
2083 var documentLength
= documentList
.length
;
2084 var documentURL
= null;
2085 var linkElement
= null;
2087 var metaTags
= null;
2088 var metaTagsLength
= null;
2089 var oldTab
= getBrowser().selectedTab
;
2090 var oldURL
= getBrowser().currentURI
.spec
;
2091 var generatedDocument
= webdeveloper_generateDocument("");
2092 var bodyElement
= webdeveloper_getDocumentBodyElement(generatedDocument
);
2093 var headElement
= webdeveloper_getDocumentHeadElement(generatedDocument
);
2094 var headerElement
= generatedDocument
.createElement("h1");
2095 var pageDocument
= null;
2096 var pElement
= null;
2097 var scriptElement
= generatedDocument
.createElement("script");
2098 var spanElement
= null;
2099 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
2100 var tableElement
= null;
2101 var tableRowElement
= null;
2102 var title
= stringBundle
.getFormattedString("webdeveloper_viewMetaTagInformationTitle", [oldURL
]);
2104 generatedDocument
.title
= title
;
2106 webdeveloper_addGeneratedStyles(generatedDocument
);
2108 headerElement
.appendChild(generatedDocument
.createTextNode(title
));
2109 bodyElement
.appendChild(headerElement
);
2111 webdeveloper_addGeneratedTools(generatedDocument
);
2113 // Loop through the documents
2114 for(var i
= 0; i
< documentLength
; i
++)
2116 divElement
= generatedDocument
.createElement("div");
2117 headerElement
= generatedDocument
.createElement("h2");
2118 linkElement
= generatedDocument
.createElement("a");
2119 pageDocument
= documentList
[i
];
2120 documentURL
= pageDocument
.documentURI
;
2121 metaTags
= pageDocument
.getElementsByTagName("meta");
2122 metaTagsLength
= metaTags
.length
;
2123 spanElement
= generatedDocument
.createElement("span");
2125 spanElement
.setAttribute("class", "expanded pivot");
2126 headerElement
.appendChild(spanElement
);
2127 linkElement
.setAttribute("href", documentURL
);
2128 linkElement
.appendChild(generatedDocument
.createTextNode(documentURL
));
2129 headerElement
.appendChild(linkElement
);
2130 bodyElement
.appendChild(headerElement
);
2132 // If there are no meta tags
2133 if(metaTagsLength
== 0)
2135 pElement
= generatedDocument
.createElement("p");
2137 pElement
.appendChild(generatedDocument
.createTextNode(stringBundle
.getString("webdeveloper_noMetaTags")));
2138 divElement
.appendChild(pElement
);
2142 tableElement
= generatedDocument
.createElement("table");
2143 tableRowElement
= generatedDocument
.createElement("tr");
2146 cellHeaderElement
= generatedDocument
.createElement("th");
2148 cellHeaderElement
.appendChild(generatedDocument
.createTextNode(stringBundle
.getString("webdeveloper_name")));
2149 tableRowElement
.appendChild(cellHeaderElement
);
2152 cellHeaderElement
= generatedDocument
.createElement("th");
2154 cellHeaderElement
.appendChild(generatedDocument
.createTextNode(stringBundle
.getString("webdeveloper_content")));
2155 tableRowElement
.appendChild(cellHeaderElement
);
2156 tableElement
.appendChild(tableRowElement
);
2158 // Loop through the meta tags
2159 for(var j
= 0; j
< metaTagsLength
; j
++)
2161 metaTag
= metaTags
[j
];
2162 tableRowElement
= generatedDocument
.createElement("tr");
2164 // If this is an even row
2167 tableRowElement
.setAttribute("class", "shaded");
2170 cellDataElement
= generatedDocument
.createElement("td");
2172 // If the meta tag has a name attribute
2173 if(metaTag
.hasAttribute("name"))
2175 cellDataElement
.appendChild(generatedDocument
.createTextNode(metaTag
.getAttribute("name")));
2177 else if(metaTag
.hasAttribute("http-equiv"))
2179 cellDataElement
.appendChild(generatedDocument
.createTextNode(metaTag
.getAttribute("http-equiv")));
2182 tableRowElement
.appendChild(cellDataElement
);
2185 cellDataElement
= generatedDocument
.createElement("td");
2187 cellDataElement
.appendChild(generatedDocument
.createTextNode(metaTag
.getAttribute("content")));
2188 tableRowElement
.appendChild(cellDataElement
);
2189 tableElement
.appendChild(tableRowElement
);
2192 tableElement
.setAttribute("class", "sortable");
2193 divElement
.appendChild(tableElement
);
2196 divElement
.setAttribute("class", "output");
2197 bodyElement
.appendChild(divElement
);
2200 scriptElement
.setAttribute("defer", "defer");
2201 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/common/dom.js");
2202 scriptElement
.setAttribute("type", "text/javascript");
2203 headElement
.appendChild(scriptElement
);
2205 scriptElement
= generatedDocument
.createElement("script");
2207 scriptElement
.setAttribute("defer", "defer");
2208 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
2209 scriptElement
.setAttribute("type", "text/javascript");
2210 headElement
.appendChild(scriptElement
);
2212 scriptElement
= generatedDocument
.createElement("script");
2214 scriptElement
.setAttribute("defer", "defer");
2215 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
2216 scriptElement
.setAttribute("type", "text/javascript");
2217 headElement
.appendChild(scriptElement
);
2219 scriptElement
= generatedDocument
.createElement("script");
2221 scriptElement
.setAttribute("defer", "defer");
2222 scriptElement
.setAttribute("src", "chrome://webdeveloper/content/generated/table_sort.js");
2223 scriptElement
.setAttribute("type", "text/javascript");
2224 headElement
.appendChild(scriptElement
);
2226 // If the open tabs in background preference is set to true
2227 if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
2229 getBrowser().selectedTab
= oldTab
;
2233 // View page information
2234 function webdeveloper_viewPageInformation(chromeLocation
)
2236 window
.openDialog(chromeLocation
, "webdeveloper-page-information-dialog", "chrome,dialog=no,resizable");
2239 // View the response headers
2240 function webdeveloper_viewResponseHeaders()
2242 var headerElement
= null;
2243 var oldTab
= getBrowser().selectedTab
;
2244 var oldURL
= getBrowser().currentURI
.spec
;
2245 var generatedDocument
= webdeveloper_generateDocument("");
2246 var bodyElement
= webdeveloper_getDocumentBodyElement(generatedDocument
);
2247 var preElement
= null;
2248 var request
= new XMLHttpRequest();
2249 var responseHeaders
= null;
2250 var title
= document
.getElementById("webdeveloper-string-bundle").getFormattedString("webdeveloper_viewResponseHeadersTitle", [oldURL
]);
2252 request
.open("get", oldURL
, false);
2255 responseHeaders
= request
.getAllResponseHeaders();
2256 generatedDocument
.title
= title
;
2258 webdeveloper_addGeneratedStyles(generatedDocument
);
2260 headerElement
= generatedDocument
.createElement("h1");
2261 headerElement
.appendChild(generatedDocument
.createTextNode(title
));
2262 bodyElement
.appendChild(headerElement
);
2264 preElement
= generatedDocument
.createElement("pre");
2265 preElement
.appendChild(generatedDocument
.createTextNode(responseHeaders
+ "\n" + request
.status
+ " " + request
.statusText
));
2266 bodyElement
.appendChild(preElement
);
2268 // If the open tabs in background preference is set to true
2269 if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
2271 getBrowser().selectedTab
= oldTab
;