1 var webdeveloper_appliedStyles
= new Array();
2 var webdeveloper_javaScriptCurrentTime
= null;
3 var webdeveloper_javaScriptPreviousTime
= null;
4 var webdeveloper_outlineElement
= null;
5 var webdeveloper_outlinedElements
= new Array();
6 var webdeveloper_selectedTab
= -1;
8 window
.addEventListener("load", webdeveloper_initialize
, false);
9 window
.addEventListener("unload", webdeveloper_uninitialize
, false);
11 // Displays the about dialog
12 function webdeveloper_about()
14 window
.openDialog("chrome://webdeveloper/content/about/about.xul", "webdeveloper-about-dialog", "centerscreen,chrome,modal");
18 function webdeveloper_addAppliedStyle(id
)
20 // If the id is not in the applied styles
21 if(!webdeveloper_contains(webdeveloper_appliedStyles
, id
))
23 webdeveloper_appliedStyles
.push(id
);
24 webdeveloper_configureElement(document
.getElementById("webdeveloper-statusbar-panel"), "hidden", false);
28 // Add applied style if the element exists
29 function webdeveloper_addAppliedStyleByElement(id
)
31 var currentDocument
= webdeveloper_getContentDocument();
33 // If the element exists
34 if(currentDocument
.getElementById(id
))
36 webdeveloper_addAppliedStyle(id
);
40 // Outlines the element in the event
41 function webdeveloper_addElementOutline(event
, currentElement
)
43 var element
= event
.target
;
45 // If the element is set and is not the same as the current outline element
46 if(element
&& element
!= currentElement
)
48 webdeveloper_removeElementOutline(currentElement
);
50 element
.style
.MozOutline
= "1px solid #ff0000";
58 // Adds the generated styles to a page
59 function webdeveloper_addGeneratedStyles(generatedDocument
)
61 var headElement
= webdeveloper_getDocumentHeadElement(generatedDocument
);
62 var linkElement
= generatedDocument
.createElement("link");
63 var styleElement
= generatedDocument
.createElement("style");
65 linkElement
.setAttribute("href", "chrome://webdeveloper/content/stylesheets/generated/generated_content.css");
66 linkElement
.setAttribute("id", "webdeveloper-generated-content-stylesheet");
67 linkElement
.setAttribute("rel", "stylesheet");
68 linkElement
.setAttribute("type", "text/css");
69 headElement
.appendChild(linkElement
);
71 styleElement
.setAttribute("type", "text/css");
72 styleElement
.appendChild(generatedDocument
.createTextNode("body, td, th { font-size: " + webdeveloper_getIntegerPreference("webdeveloper.generated.content.font.size", true) + "px !important; }"));
73 headElement
.appendChild(styleElement
);
76 // Adds the generated tools to a page
77 function webdeveloper_addGeneratedTools(generatedDocument
)
79 var linkElement
= generatedDocument
.createElement("a");
80 var listElement
= generatedDocument
.createElement("ul");
81 var listItemElement
= generatedDocument
.createElement("li");
82 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
84 linkElement
.setAttribute("href", "#");
85 linkElement
.setAttribute("id", "webdeveloper-generated-tool-collapse-all");
86 linkElement
.appendChild(generatedDocument
.createTextNode(stringBundle
.getString("webdeveloper_collapseAll")));
87 listItemElement
.appendChild(linkElement
);
88 listElement
.appendChild(listItemElement
);
90 linkElement
= generatedDocument
.createElement("a");
91 listItemElement
= generatedDocument
.createElement("li");
93 linkElement
.setAttribute("href", "#");
94 linkElement
.setAttribute("id", "webdeveloper-generated-tool-expand-all");
95 linkElement
.appendChild(generatedDocument
.createTextNode(stringBundle
.getString("webdeveloper_expandAll")));
96 listItemElement
.appendChild(linkElement
);
97 listElement
.appendChild(listItemElement
);
99 listElement
.setAttribute("id", "tools");
100 webdeveloper_getDocumentBodyElement(generatedDocument
).appendChild(listElement
);
103 // Adds a status menu item
104 function webdeveloper_addStatusMenuItem(statusMenu
, menuId
)
106 var originalMenuItem
= document
.getElementById(menuId
+ "-menu");
107 var statusMenuItem
= document
.createElement("menuitem");
109 statusMenuItem
.setAttribute("checked", true);
110 statusMenuItem
.setAttribute("class", "webdeveloper-generated-menu");
111 statusMenuItem
.setAttribute("label", originalMenuItem
.getAttribute("label"));
112 statusMenuItem
.setAttribute("oncommand", originalMenuItem
.getAttribute("oncommand"));
113 statusMenuItem
.setAttribute("type", "checkbox");
115 statusMenu
.insertBefore(statusMenuItem
, document
.getElementById("webdeveloper-separator-statusbar"));
118 // Adds the style sheet at the given location with the given id
119 function webdeveloper_addStyleSheet(location
, id
)
121 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
122 var documentLength
= documentList
.length
;
123 var linkElement
= null;
124 var pageDocument
= null;
126 // Loop through the documents
127 for(var i
= 0; i
< documentLength
; i
++)
129 pageDocument
= documentList
[i
];
130 linkElement
= pageDocument
.createElement("link");
132 linkElement
.setAttribute("href", location
);
133 linkElement
.setAttribute("id", id
);
134 linkElement
.setAttribute("rel", "stylesheet");
135 linkElement
.setAttribute("type", "text/css");
137 webdeveloper_getDocumentHeadElement(pageDocument
).appendChild(linkElement
);
140 webdeveloper_addAppliedStyle(id
);
143 // Adjusts the position of the given element
144 function webdeveloper_adjustElementPosition(element
, xPosition
, yPosition
, offset
)
146 // If the element is set
149 var clientHeight
= element
.clientHeight
;
150 var clientWidth
= element
.clientWidth
;
151 var contentWindow
= webdeveloper_getContentWindow();
152 var innerHeight
= contentWindow
.innerHeight
;
153 var innerWidth
= contentWindow
.innerWidth
;
154 var offsetX
= contentWindow
.pageXOffset
;
155 var offsetY
= contentWindow
.pageYOffset
;
157 // If the x position is less than 0
163 // If the y position is less than 0
169 // If the element will fit at the x position
170 if((xPosition
+ clientWidth
+ offset
+ 5) < (innerWidth
+ offsetX
))
172 element
.style
.left
= xPosition
+ offset
+ "px";
176 element
.style
.left
= (innerWidth
+ offsetX
- clientWidth
- offset
) + "px";
179 // If the element will fit at the y position
180 if((yPosition
+ clientHeight
+ offset
+ 5) < (innerHeight
+ offsetY
))
182 element
.style
.top
= yPosition
+ offset
+ "px";
186 element
.style
.top
= (innerHeight
+ offsetY
- clientHeight
- offset
) + "px";
191 // Applies all selected style sheets
192 function webdeveloper_applyStyleSheets(reset
)
194 var appliedStyle
= null;
195 var appliedStyles
= webdeveloper_appliedStyles
.slice(0);
196 var appliedStylesLength
= appliedStyles
.length
;
199 // Loop through the duplicated applied styles
200 for(var i
= 0; i
< appliedStylesLength
; i
++)
202 appliedStyle
= appliedStyles
[i
];
204 // Switch on the style
207 case "webdeveloper-add-user-style-sheet":
208 element
= document
.getElementById("webdeveloper-add-user-style-sheet-menu");
209 webdeveloper_configureElement(element
, "checked", !reset
);
210 webdeveloper_addUserStyleSheet(element
);
212 case "webdeveloper-disable-all-styles":
213 element
= document
.getElementById("webdeveloper-disable-all-styles-menu");
214 webdeveloper_configureElement(element
, "checked", !reset
);
215 webdeveloper_toggleStyles(element
);
217 case "webdeveloper-disable-browser-default-styles":
218 element
= document
.getElementById("webdeveloper-disable-browser-default-styles-menu");
219 webdeveloper_configureElement(element
, "checked", !reset
);
220 webdeveloper_toggleBrowserDefaultStyles(element
);
222 case "webdeveloper-disable-embedded-styles":
223 element
= document
.getElementById("webdeveloper-disable-embedded-styles-menu");
224 webdeveloper_configureElement(element
, "checked", !reset
);
225 webdeveloper_toggleEmbeddedStyles(element
);
227 case "webdeveloper-disable-inline-styles":
228 element
= document
.getElementById("webdeveloper-disable-inline-styles-menu");
229 webdeveloper_configureElement(element
, "checked", !reset
);
230 webdeveloper_toggleInlineStyles(element
);
232 case "webdeveloper-disable-linked-styles":
233 element
= document
.getElementById("webdeveloper-disable-linked-styles-menu");
234 webdeveloper_configureElement(element
, "checked", !reset
);
235 webdeveloper_toggleLinkedStyles(element
);
237 case "webdeveloper-disable-print-styles":
238 element
= document
.getElementById("webdeveloper-disable-print-styles-menu");
239 webdeveloper_configureElement(element
, "checked", !reset
);
240 webdeveloper_togglePrintStyles(element
);
242 case "webdeveloper-display-abbreviations":
243 element
= document
.getElementById("webdeveloper-display-abbreviations-menu");
244 webdeveloper_configureElement(element
, "checked", !reset
);
245 webdeveloper_displayAbbreviations(element
);
247 case "webdeveloper-display-access-keys":
248 element
= document
.getElementById("webdeveloper-display-access-keys-menu");
249 webdeveloper_configureElement(element
, "checked", !reset
);
250 webdeveloper_displayAccessKeys(element
);
252 case "webdeveloper-display-alt-attributes":
253 element
= document
.getElementById("webdeveloper-display-alt-attributes-menu");
254 webdeveloper_configureElement(element
, "checked", !reset
);
255 webdeveloper_displayAltAttributes(element
);
257 case "webdeveloper-display-anchors":
258 element
= document
.getElementById("webdeveloper-display-anchors-menu");
259 webdeveloper_configureElement(element
, "checked", !reset
);
260 webdeveloper_displayAnchors(element
);
262 case "webdeveloper-display-block-size":
263 element
= document
.getElementById("webdeveloper-display-block-size-menu");
264 webdeveloper_configureElement(element
, "checked", !reset
);
265 webdeveloper_displayBlockSize(element
);
267 case "webdeveloper-display-div-order":
268 element
= document
.getElementById("webdeveloper-display-div-order-menu");
269 webdeveloper_configureElement(element
, "checked", !reset
);
270 webdeveloper_displayDivOrder(element
);
272 case "webdeveloper-display-element-information":
273 element
= document
.getElementById("webdeveloper-display-element-information-menu");
274 webdeveloper_configureElement(element
, "checked", !reset
);
275 webdeveloper_displayElementInformation(element
);
277 case "webdeveloper-display-current-size-title":
278 element
= document
.getElementById("webdeveloper-display-current-size-title-menu");
279 webdeveloper_configureElement(element
, "checked", !reset
);
280 webdeveloper_displayWindowSizeInTitle(element
);
282 case "webdeveloper-display-form-details":
283 element
= document
.getElementById("webdeveloper-display-form-details-menu");
284 webdeveloper_configureElement(element
, "checked", !reset
);
285 webdeveloper_displayFormDetails(element
);
287 case "webdeveloper-display-handheld-css":
288 element
= document
.getElementById("webdeveloper-display-handheld-css-menu");
289 webdeveloper_configureElement(element
, "checked", !reset
);
290 webdeveloper_displayHandheldCSS(element
);
292 case "webdeveloper-display-id-class-details":
293 element
= document
.getElementById("webdeveloper-display-id-class-details-menu");
294 webdeveloper_configureElement(element
, "checked", !reset
);
295 webdeveloper_displayIdClassDetails(element
);
297 case "webdeveloper-display-image-dimensions":
298 element
= document
.getElementById("webdeveloper-display-image-dimensions-menu");
299 webdeveloper_configureElement(element
, "checked", !reset
);
300 webdeveloper_displayImageDimensions(element
);
302 case "webdeveloper-display-image-file-sizes":
303 element
= document
.getElementById("webdeveloper-display-image-file-sizes-menu");
304 webdeveloper_configureElement(element
, "checked", !reset
);
305 webdeveloper_displayImageFileSizes(element
);
307 case "webdeveloper-display-image-paths":
308 element
= document
.getElementById("webdeveloper-display-image-paths-menu");
309 webdeveloper_configureElement(element
, "checked", !reset
);
310 webdeveloper_displayImagePaths(element
);
312 case "webdeveloper-display-line-guides":
313 element
= document
.getElementById("webdeveloper-display-line-guides-menu");
314 webdeveloper_configureElement(element
, "checked", !reset
);
315 webdeveloper_displayLineGuides(element
);
317 case "webdeveloper-display-link-details":
318 element
= document
.getElementById("webdeveloper-display-link-details-menu");
319 webdeveloper_configureElement(element
, "checked", !reset
);
320 webdeveloper_displayLinkDetails(element
);
322 case "webdeveloper-display-object-information":
323 element
= document
.getElementById("webdeveloper-display-object-information-menu");
324 webdeveloper_configureElement(element
, "checked", !reset
);
325 webdeveloper_displayObjectInformation(element
);
327 case "webdeveloper-display-print-css":
328 element
= document
.getElementById("webdeveloper-display-print-css-menu");
329 webdeveloper_configureElement(element
, "checked", !reset
);
330 webdeveloper_displayPrintCSS(element
);
332 case "webdeveloper-display-ruler":
333 element
= document
.getElementById("webdeveloper-display-ruler-menu");
334 webdeveloper_configureElement(element
, "checked", !reset
);
335 webdeveloper_displayRuler(element
);
337 case "webdeveloper-display-stack-levels":
338 element
= document
.getElementById("webdeveloper-display-stack-levels-menu");
339 webdeveloper_configureElement(element
, "checked", !reset
);
340 webdeveloper_displayStackLevels(element
);
342 case "webdeveloper-display-tab-index":
343 element
= document
.getElementById("webdeveloper-display-tab-index-menu");
344 webdeveloper_configureElement(element
, "checked", !reset
);
345 webdeveloper_displayTabIndex(element
);
347 case "webdeveloper-display-table-depth":
348 element
= document
.getElementById("webdeveloper-display-table-depth-menu");
349 webdeveloper_configureElement(element
, "checked", !reset
);
350 webdeveloper_displayTableDepth(element
);
352 case "webdeveloper-display-table-information":
353 element
= document
.getElementById("webdeveloper-display-table-information-menu");
354 webdeveloper_configureElement(element
, "checked", !reset
);
355 webdeveloper_displayTableInformation(element
);
357 case "webdeveloper-display-title-attributes":
358 element
= document
.getElementById("webdeveloper-display-title-attributes-menu");
359 webdeveloper_configureElement(element
, "checked", !reset
);
360 webdeveloper_displayTitleAttributes(element
);
362 case "webdeveloper-display-topographic-information":
363 element
= document
.getElementById("webdeveloper-display-topographic-information-menu");
364 webdeveloper_configureElement(element
, "checked", !reset
);
365 webdeveloper_displayTopographicInformation(element
);
367 case "webdeveloper-display-window-size-title":
368 element
= document
.getElementById("webdeveloper-display-window-size-title-menu");
369 webdeveloper_configureElement(element
, "checked", !reset
);
370 webdeveloper_displayWindowSizeInTitle(element
);
372 case "webdeveloper-hide-background-images":
373 element
= document
.getElementById("webdeveloper-hide-background-images-menu");
374 webdeveloper_configureElement(element
, "checked", !reset
);
375 webdeveloper_hideBackgroundImages(element
);
377 case "webdeveloper-hide-images":
378 element
= document
.getElementById("webdeveloper-hide-images-menu");
379 webdeveloper_configureElement(element
, "checked", !reset
);
380 webdeveloper_hideImages(element
, "webdeveloper-hide-images");
382 case "webdeveloper-linearize-page":
383 element
= document
.getElementById("webdeveloper-linearize-page-menu");
384 webdeveloper_configureElement(element
, "checked", !reset
);
385 webdeveloper_linearizePage(element
);
387 case "webdeveloper-make-images-invisible":
388 element
= document
.getElementById("webdeveloper-make-images-invisible-menu");
389 webdeveloper_configureElement(element
, "checked", !reset
);
390 webdeveloper_makeImagesInvisible(element
, "webdeveloper-make-images-invisible");
392 case "webdeveloper-outline-absolute-positioned-elements":
393 element
= document
.getElementById("webdeveloper-outline-absolute-positioned-elements-menu");
394 webdeveloper_configureElement(element
, "checked", !reset
);
395 webdeveloper_outlinePositionedElements("absolute", element
);
397 case "webdeveloper-outline-all-images":
398 element
= document
.getElementById("webdeveloper-outline-all-images-menu");
399 webdeveloper_configureElement(element
, "checked", !reset
);
400 webdeveloper_outlineAllImages(element
);
402 case "webdeveloper-outline-all-tables":
403 element
= document
.getElementById("webdeveloper-outline-all-tables-menu");
404 webdeveloper_configureElement(element
, "checked", !reset
);
405 webdeveloper_outlineTables(element
);
407 case "webdeveloper-outline-background-images":
408 element
= document
.getElementById("webdeveloper-outline-background-images-menu");
409 webdeveloper_configureElement(element
, "checked", !reset
);
410 webdeveloper_outlineBackgroundImages(element
, true);
412 case "webdeveloper-outline-block-level-elements":
413 element
= document
.getElementById("webdeveloper-outline-block-level-elements-menu");
414 webdeveloper_configureElement(element
, "checked", !reset
);
415 webdeveloper_outlineBlockLevelElements(element
);
417 case "webdeveloper-outline-current-element":
418 element
= document
.getElementById("webdeveloper-outline-current-element-menu");
419 webdeveloper_configureElement(element
, "checked", !reset
);
420 webdeveloper_outlineCurrentElement(element
);
422 case "webdeveloper-outline-custom-elements":
423 element
= document
.getElementById("webdeveloper-outline-custom-elements-menu");
424 webdeveloper_configureElement(element
, "checked", !reset
);
425 webdeveloper_outlineElements(element
);
427 case "webdeveloper-outline-deprecated-elements":
428 element
= document
.getElementById("webdeveloper-outline-deprecated-elements-menu");
429 webdeveloper_configureElement(element
, "checked", !reset
);
430 webdeveloper_outlineDeprecatedElements(element
);
432 case "webdeveloper-outline-external-links":
433 element
= document
.getElementById("webdeveloper-outline-external-links-menu");
434 webdeveloper_configureElement(element
, "checked", !reset
);
435 webdeveloper_outlineExternalLinks(element
);
437 case "webdeveloper-outline-fixed-positioned-elements":
438 element
= document
.getElementById("webdeveloper-outline-fixed-positioned-elements-menu");
439 webdeveloper_configureElement(element
, "checked", !reset
);
440 webdeveloper_outlinePositionedElements("fixed", element
);
442 case "webdeveloper-outline-floated-elements":
443 element
= document
.getElementById("webdeveloper-outline-floated-elements-menu");
444 webdeveloper_configureElement(element
, "checked", !reset
);
445 webdeveloper_outlineFloatedElements(element
);
447 case "webdeveloper-outline-frames":
448 element
= document
.getElementById("webdeveloper-outline-frames-menu");
449 webdeveloper_configureElement(element
, "checked", !reset
);
450 webdeveloper_outlineFrames(element
);
452 case "webdeveloper-outline-headings":
453 element
= document
.getElementById("webdeveloper-outline-headings-menu");
454 webdeveloper_configureElement(element
, "checked", !reset
);
455 webdeveloper_outlineHeadings(element
);
457 case "webdeveloper-outline-images-with-adjusted-dimensions":
458 element
= document
.getElementById("webdeveloper-outline-images-with-adjusted-dimensions-menu");
459 webdeveloper_configureElement(element
, "checked", !reset
);
460 webdeveloper_outlineImagesWithAdjustedDimensions(element
);
462 case "webdeveloper-outline-images-with-empty-alt-attributes":
463 element
= document
.getElementById("webdeveloper-outline-images-with-empty-alt-attributes-menu");
464 webdeveloper_configureElement(element
, "checked", !reset
);
465 webdeveloper_outlineImagesWithEmptyAltAttributes(element
);
467 case "webdeveloper-outline-images-with-oversized-dimensions":
468 element
= document
.getElementById("webdeveloper-outline-images-with-oversized-dimensions-menu");
469 webdeveloper_configureElement(element
, "checked", !reset
);
470 webdeveloper_outlineImagesWithOversizedDimensions(element
);
472 case "webdeveloper-outline-images-without-alt-attributes":
473 element
= document
.getElementById("webdeveloper-outline-images-without-alt-attributes-menu");
474 webdeveloper_configureElement(element
, "checked", !reset
);
475 webdeveloper_outlineImagesWithoutAltAttributes(element
);
477 case "webdeveloper-outline-images-without-dimensions":
478 element
= document
.getElementById("webdeveloper-outline-images-without-dimensions-menu");
479 webdeveloper_configureElement(element
, "checked", !reset
);
480 webdeveloper_outlineImagesWithoutDimensions(element
);
482 case "webdeveloper-outline-images-without-title-attributes":
483 element
= document
.getElementById("webdeveloper-outline-images-without-title-attributes-menu");
484 webdeveloper_configureElement(element
, "checked", !reset
);
485 webdeveloper_outlineImagesWithoutTitleAttributes(element
);
487 case "webdeveloper-outline-links-with-ping-attributes":
488 element
= document
.getElementById("webdeveloper-outline-links-with-ping-attributes-menu");
489 webdeveloper_configureElement(element
, "checked", !reset
);
490 webdeveloper_outlineLinksWithPingAttributes(element
);
492 case "webdeveloper-outline-links-without-title-attributes":
493 element
= document
.getElementById("webdeveloper-outline-links-without-title-attributes-menu");
494 webdeveloper_configureElement(element
, "checked", !reset
);
495 webdeveloper_outlineLinksWithoutTitleAttributes(element
);
497 case "webdeveloper-outline-relative-positioned-elements":
498 element
= document
.getElementById("webdeveloper-outline-relative-positioned-elements-menu");
499 webdeveloper_configureElement(element
, "checked", !reset
);
500 webdeveloper_outlinePositionedElements("relative", element
);
502 case "webdeveloper-outline-table-cells":
503 element
= document
.getElementById("webdeveloper-outline-table-cells-menu");
504 webdeveloper_configureElement(element
, "checked", !reset
);
505 webdeveloper_outlineTableCells(element
);
507 case "webdeveloper-replace-images-with-alt-attributes":
508 element
= document
.getElementById("webdeveloper-replace-images-with-alt-attributes-menu");
509 webdeveloper_configureElement(element
, "checked", !reset
);
510 webdeveloper_replaceImagesWithAltAttributes(element
);
512 case "webdeveloper-show-comments":
513 element
= document
.getElementById("webdeveloper-show-comments-menu");
514 webdeveloper_configureElement(element
, "checked", !reset
);
515 webdeveloper_toggleComments(element
);
517 case "webdeveloper-small-screen-rendering":
518 element
= document
.getElementById("webdeveloper-small-screen-rendering-menu");
519 webdeveloper_configureElement(element
, "checked", !reset
);
520 webdeveloper_smallScreenRendering(element
);
522 case "webdeveloper-use-border-box-model":
523 element
= document
.getElementById("webdeveloper-use-border-box-model-menu");
524 webdeveloper_configureElement(element
, "checked", !reset
);
525 webdeveloper_toggleBorderBoxModel(element
);
527 case "webdeveloper-view-style-information":
528 element
= document
.getElementById("webdeveloper-view-style-information-menu");
529 webdeveloper_configureElement(element
, "checked", !reset
);
530 webdeveloper_viewStyleInformation(element
);
536 // Changes the options
537 function webdeveloper_changeOptions()
540 var hideContextMenuPreference
= webdeveloper_getBooleanPreference("webdeveloper.context.hide", true);
541 var hideMenuPreference
= webdeveloper_getBooleanPreference("webdeveloper.menu.hide", true);
542 var toolbar
= document
.getElementById("webdeveloper-toolbar");
544 // If the toolbar exists
547 var toolbarVisible
= window
.toolbar
.visible
;
549 // If the toolbar is visible
552 var toolbarButtons
= toolbar
.getElementsByTagName("toolbarbutton");
553 var toolbarButtonsLength
= toolbarButtons
.length
;
554 var toolbarPreference
= webdeveloper_getStringPreference("webdeveloper.toolbar.icons", true);
556 toolbar
.setAttribute("mode", toolbarPreference
);
558 // If the toolbar preference is set to icons
559 if(toolbarPreference
== "icons")
561 toolbarPreference
= "pictures";
564 toolbar
.setAttribute("buttonstyle", toolbarPreference
);
566 // Loop through the toolbar buttons
567 for(var i
= 0; i
< toolbarButtonsLength
; i
++)
569 toolbarButtons
[i
].setAttribute("buttonstyle", toolbarPreference
);
572 // If the toolbar preference is not set to text
573 if(toolbarPreference
!= "text")
575 element
= document
.getElementById("webdeveloper-javascript-statusbar");
577 // If the element exists
580 element
.removeAttribute("label");
583 element
= document
.getElementById("webdeveloper-render-mode-statusbar");
585 // If the element exists
588 element
.removeAttribute("label");
594 element
= document
.getElementById("webdeveloper-menu");
596 // If the element exists
599 element
.setAttribute("hidden", hideMenuPreference
);
602 element
= document
.getElementById("webdeveloper-context");
604 // If the element exists
607 element
.setAttribute("hidden", hideContextMenuPreference
);
610 element
= document
.getElementById("webdeveloper-context-separator1");
612 // If the element exists
615 element
.setAttribute("hidden", hideContextMenuPreference
);
619 // Clears the applied styles
620 function webdeveloper_clearAppliedStyles()
622 webdeveloper_appliedStyles
= new Array();
624 webdeveloper_configureElement(document
.getElementById("webdeveloper-statusbar-panel"), "hidden", true);
627 // Configures the element with the given attribute and value
628 function webdeveloper_configureElement(element
, attribute
, value
)
630 // If the element exists
633 // If the value is set
636 element
.setAttribute(attribute
, value
);
640 element
.removeAttribute(attribute
);
645 // Configures the element based on whether the applied style exists
646 function webdeveloper_configureElementByAppliedStyle(element
, attribute
, id
)
648 webdeveloper_configureElement(element
, attribute
, webdeveloper_contains(webdeveloper_appliedStyles
, id
));
651 // Configure the keyboard shortcuts
652 function webdeveloper_configureKeyboardShortcuts(reset
)
654 var bookmarklet
= null;
657 var keyElement
= null;
658 var keyPreference
= null;
659 var keyPreferenceValue
= null;
662 var keysLength
= null;
663 var mainDocument
= null;
666 var toolCount
= webdeveloper_getIntegerPreference("webdeveloper.tool.count", true);
668 var viewSourceWithCount
= webdeveloper_getIntegerPreference("webdeveloper.view.source.with.count", true);
669 var windowEnumeration
= Components
.classes
["@mozilla.org/appshell/window-mediator;1"].getService(Components
.interfaces
.nsIWindowMediator
).getEnumerator("navigator:browser");
671 // Loop through the open windows
672 while(windowEnumeration
.hasMoreElements())
674 mainDocument
= windowEnumeration
.getNext().document
;
676 // If a main document was found
679 keySet
= mainDocument
.getElementById("mainKeyset");
681 // If the key set was not found
684 keySet
= mainDocument
.getElementById("navKeys");
687 // If the key set was found
690 keys
= keySet
.childNodes
;
691 keysLength
= keys
.length
;
693 // Loop through the keys
694 for(var i
= 0; i
< keysLength
; i
++)
698 // If the key has an id starting with webdeveloper
699 if(key
.hasAttribute("id") && key
.getAttribute("id").indexOf("webdeveloper-") == 0)
701 id
= key
.getAttribute("id").split("-").join(".");
703 // If the key preference is set
704 if(webdeveloper_isPreferenceSet(id
))
706 keyPreferenceValue
= webdeveloper_getStringPreference(id
, true);
708 key
.setAttribute("key", keyPreferenceValue
);
710 // If the key preference value is set
711 if(keyPreferenceValue
)
713 key
.setAttribute("disabled", false);
717 key
.setAttribute("disabled", true);
722 webdeveloper_setStringPreference(id
, key
.getAttribute("key"));
729 // Loop through the possible tools
730 for(i
= 1; i
<= toolCount
; i
++)
732 bookmarklet
= "webdeveloper.tool." + i
+ ".bookmarklet";
733 keyPreference
= "webdeveloper.tool." + i
+ ".key";
734 keyElement
= mainDocument
.getElementById(keyPreference
);
735 path
= "webdeveloper.tool." + i
+ ".path";
736 url
= "webdeveloper.tool." + i
+ ".url";
738 // If the bookmarklet, path or URL preference and key preference is set
739 if((webdeveloper_isPreferenceSet(bookmarklet
) || webdeveloper_isPreferenceSet(path
) || webdeveloper_isPreferenceSet(url
)) && webdeveloper_isPreferenceSet(keyPreference
))
741 keyPreferenceValue
= webdeveloper_getStringPreference(keyPreference
, true);
743 // If the key preference value is set
744 if(keyPreferenceValue
)
746 key
= mainDocument
.createElement("key");
748 key
.setAttribute("id", keyPreference
);
749 key
.setAttribute("key", keyPreferenceValue
);
750 key
.setAttribute("modifiers", "accel,shift");
752 // If the bookmarklet preference is set
753 if(webdeveloper_getStringPreference(bookmarklet
, true))
755 key
.setAttribute("oncommand", "webdeveloper_runBookmarklet('" + encodeURIComponent(webdeveloper_getStringPreference(bookmarklet
, true)).replace(new RegExp("'", "gi"), "\\'") + "')");
757 else if(webdeveloper_getStringPreference(path
, true))
759 key
.setAttribute("oncommand", "webdeveloper_loadApplicationWithURL('" + webdeveloper_getStringPreference(path
, true).replace(/\\/gi
, "\\\\") + "', getBrowser().currentURI.spec)");
763 key
.setAttribute("oncommand", "webdeveloper_loadURL('" + webdeveloper_getStringPreference(url
, true) + "' + encodeURIComponent(getBrowser().currentURI.spec))");
766 keySet
.appendChild(key
);
771 webdeveloper_removeElement(keyElement
);
775 // Loop through the possible view source with options
776 for(i
= 1; i
<= viewSourceWithCount
; i
++)
778 keyPreference
= "webdeveloper.view.source.with." + i
+ ".key";
779 keyElement
= mainDocument
.getElementById(keyPreference
);
780 path
= "webdeveloper.view.source.with." + i
+ ".path";
782 // If the path and key preferences are set
783 if(webdeveloper_isPreferenceSet(path
) && webdeveloper_isPreferenceSet(keyPreference
))
785 keyPreferenceValue
= webdeveloper_getStringPreference(keyPreference
, true);
787 // If the key preference value is set
788 if(keyPreferenceValue
)
790 key
= mainDocument
.createElement("key");
792 key
.setAttribute("id", keyPreference
);
793 key
.setAttribute("key", keyPreferenceValue
);
794 key
.setAttribute("modifiers", "accel,shift");
795 key
.setAttribute("oncommand", "webdeveloper_loadApplicationWithSource('" + webdeveloper_getStringPreference(path
, true).replace(/\\/gi
, "\\\\") + "')");
796 keySet
.appendChild(key
);
801 webdeveloper_removeElement(keyElement
);
811 // Copies the elements ancestors to the clipboard
812 function webdeveloper_copyElementAncestors(event
)
814 var informationElement
= document
.getElementById("webdeveloper-information");
815 var keyCode
= event
.charCode
;
817 // If the information element is set and the key code is set and is 99
818 if(informationElement
&& keyCode
&& keyCode
== 99)
820 Components
.classes
["@mozilla.org/widget/clipboardhelper;1"].getService(Components
.interfaces
.nsIClipboardHelper
).copyString(informationElement
.value
);
822 event
.preventDefault();
826 // Disables the given preference
827 function webdeveloper_disablePreference(element
, preference
)
829 // If the element and preference are set
830 if(element
&& preference
)
832 webdeveloper_setBooleanPreference(preference
, !element
.getAttribute("checked"));
836 // Displays the elements ancestors in the information bar
837 function webdeveloper_displayElementAncestors(event
)
839 var eventTarget
= event
.target
;
840 var informationElement
= document
.getElementById("webdeveloper-information");
842 // If there is a target and the information element is set
843 if(eventTarget
&& informationElement
)
845 var tagName
= eventTarget
.tagName
;
847 // If the tag name is set and does not equal scrollbar
848 if(tagName
&& tagName
!= "scrollbar")
850 var ancestorList
= webdeveloper_getElementAncestors(eventTarget
);
851 var ancestorLength
= ancestorList
.length
;
852 var ancestorText
= "";
854 // Loop through the ancestors
855 for(var i
= 0; i
< ancestorLength
; i
++)
857 ancestorText
+= webdeveloper_getElementDescription(ancestorList
[i
]) + " > ";
860 informationElement
.value
= ancestorText
+ webdeveloper_getElementDescription(eventTarget
);
862 webdeveloper_configureElement(document
.getElementById("webdeveloper-information-text-toolbar"), "hidden", false);
864 event
.preventDefault();
869 // Enables the given preference
870 function webdeveloper_enablePreference(element
, preference
)
872 // If the element and preference are set
873 if(element
&& preference
)
875 var checked
= element
.getAttribute("checked");
877 // If the element is checked (explicit check required)
880 webdeveloper_setBooleanPreference(preference
, true);
884 webdeveloper_setBooleanPreference(preference
, false);
889 // Formats a file size
890 function webdeveloper_formatFileSize(fileSize
)
892 // If the file size is set
895 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
897 // If the file size is greater than a kilobyte
900 return Math
.round(fileSize
/ 1024) + " " + stringBundle
.getString("webdeveloper_kilobytes");
904 return fileSize
+ " " + stringBundle
.getString("webdeveloper_bytes");
913 // Generates a document in a new tab or window
914 function webdeveloper_generateDocument(url
)
916 var generatedPage
= null;
917 var request
= new XMLHttpRequest();
919 // If the open tabs preference is set to true
920 if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs", true))
922 getBrowser().selectedTab
= getBrowser().addTab(url
);
924 generatedPage
= window
;
928 generatedPage
= window
.open(url
);
931 // This must be done to make generated content render
932 request
.open("get", "about:blank", false);
935 return generatedPage
.content
.document
;
938 // Returns a description for an element
939 function webdeveloper_getElementDescription(element
)
941 var description
= null;
943 // If the element and tag name are set
944 if(element
&& element
.tagName
)
946 description
= element
.tagName
.toLowerCase();
948 // If the element has an id attribute
949 if(element
.hasAttribute("id"))
951 description
+= " #" + element
.getAttribute("id");
954 // If the element has a class attribute
955 if(element
.hasAttribute("class"))
957 description
+= " ." + element
.getAttribute("class");
965 function webdeveloper_help()
967 webdeveloper_loadURL("http://chrispederick.com/work/web-developer/documentation/");
970 // Initializes the extension
971 function webdeveloper_initialize(event
)
973 var windowContent
= window
.document
.getElementById("content");
975 // If the window content is set
978 var consoleService
= Components
.classes
["@mozilla.org/consoleservice;1"].getService().QueryInterface(Components
.interfaces
.nsIConsoleService
);
979 var dashboard
= document
.getElementById("webdeveloper-dashboard");
980 var tabBox
= windowContent
.mTabBox
;
982 webdeveloper_upgrade();
983 webdeveloper_setupDefaultOptions();
984 webdeveloper_setupLocalizedOptions();
985 webdeveloper_configureKeyboardShortcuts(false);
986 webdeveloper_changeOptions();
988 windowContent
.addEventListener("load", webdeveloper_pageLoad
, true);
989 windowContent
.addEventListener("unload", webdeveloper_pageUnload
, true);
991 // If the dashboard is set
994 webdeveloper_setupDashboardPosition(webdeveloper_getStringPreference("webdeveloper.dashboard.position", true));
997 // If the console service is set
1000 consoleService
.registerListener(WebDeveloperErrorConsoleListener
);
1003 // If the tab box is set
1006 tabBox
.addEventListener("select", webdeveloper_tabSelect
, false);
1009 // Try to remove the event listener
1012 window
.removeEventListener("load", webdeveloper_initialize
, false);
1021 // Returns true if the DOM Inspector is available
1022 function webdeveloper_isDOMInspectorAvailable()
1026 Components
.classes
["@mozilla.org/inspector/dom-utils;1"].getService(Components
.interfaces
.inIDOMUtils
);
1036 // Returns true if the information text toolbar is in use
1037 function webdeveloper_isInformationTextToolbarInUse()
1039 // If one of the features that use the information text toolbar is enabled
1040 if(webdeveloper_contains(webdeveloper_appliedStyles
, "webdeveloper-display-element-information") || webdeveloper_contains(webdeveloper_appliedStyles
, "webdeveloper-outline-current-element") || webdeveloper_contains(webdeveloper_appliedStyles
, "webdeveloper-view-style-information"))
1048 // Loads the given URL
1049 function webdeveloper_loadURL(url
)
1051 var oldTab
= getBrowser().selectedTab
;
1053 webdeveloper_generateDocument(url
);
1055 // If the open tabs in background preference is set to true
1056 if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
1058 getBrowser().selectedTab
= oldTab
;
1062 // Logs a debug message to the error console
1063 function webdeveloper_logDebug(message
)
1065 // If the debug preference is set
1066 if(webdeveloper_getBooleanPreference("webdeveloper.debug", true))
1068 Components
.classes
["@mozilla.org/consoleservice;1"].getService(Components
.interfaces
.nsIConsoleService
).logStringMessage("Web Developer: " + message
);
1069 webdeveloper_openErrorConsole(false);
1073 // Opens the error console
1074 function webdeveloper_openErrorConsole(toggle
)
1076 // If the open error console in dashboard preference is set to true
1077 if(webdeveloper_getBooleanPreference("webdeveloper.error.console.dashboard", true))
1079 var errorConsole
= document
.getElementById("webdeveloper-string-bundle").getString("webdeveloper_errorConsole");
1081 // If the error console is already open in the dashboard
1082 if(webdeveloper_isOpenInDashboard(errorConsole
))
1084 // If toggling the console
1087 webdeveloper_closeInDashboard(errorConsole
);
1091 webdeveloper_selectInDashboard(errorConsole
);
1096 webdeveloper_openInDashboard(errorConsole
, "chrome://global/content/console.xul");
1101 webdeveloper_javaScriptPreviousTime
= webdeveloper_javaScriptCurrentTime
;
1102 webdeveloper_javaScriptCurrentTime
= new Date().getTime();
1104 // If the previous time is not set or the current time is greater than a second different from the previous time
1105 if(!webdeveloper_javaScriptPreviousTime
|| webdeveloper_javaScriptCurrentTime
- webdeveloper_javaScriptPreviousTime
> 1500)
1107 toJavaScriptConsole();
1112 // Opens a toolbar button automatically if another toolbar button is open on the toolbar
1113 function webdeveloper_openToolbarButton(currentToolbarButton
)
1115 // If the toolbar button is set and is not open
1116 if(currentToolbarButton
&& !currentToolbarButton
.open
)
1118 var toolbarButton
= null;
1119 var toolbarButtons
= currentToolbarButton
.parentNode
.getElementsByTagName("toolbarbutton");
1120 var toolbarButtonsLength
= toolbarButtons
.length
;
1122 // Loop through the toolbar buttons
1123 for(var i
= 0; i
< toolbarButtonsLength
; i
++)
1125 toolbarButton
= toolbarButtons
.item(i
);
1127 // If the toolbar button is set, is not the same toolbar button and is open
1128 if(toolbarButton
&& toolbarButton
!= currentToolbarButton
&& toolbarButton
.open
)
1130 toolbarButton
.open
= false;
1131 currentToolbarButton
.open
= true;
1139 // Displays the options dialog
1140 function webdeveloper_options(openPage
)
1142 // If an open page is set
1145 window
.openDialog("chrome://webdeveloper/content/options/options.xul", "webdeveloper-options-dialog", "centerscreen,chrome,modal,resizable", openPage
);
1149 window
.openDialog("chrome://webdeveloper/content/options/options.xul", "webdeveloper-options-dialog", "centerscreen,chrome,modal,resizable");
1152 webdeveloper_changeOptions();
1155 // Handles the page being loaded
1156 function webdeveloper_pageLoad(event
)
1158 var eventTarget
= event
.target
;
1160 // If the browser is the target
1161 if(eventTarget
&& eventTarget
== getBrowser())
1163 var contentDocument
= eventTarget
.contentDocument
;
1165 // If the content document is set
1168 // Try to get the original target
1171 var loadedDocument
= event
.originalTarget
;
1173 // If the loaded document is set and has the same URI as the content document
1174 if(loadedDocument
&& contentDocument
.documentURI
== loadedDocument
.documentURI
)
1176 // Reset the display line guides and display ruler features
1177 webdeveloper_configureElement(document
.getElementById("webdeveloper-line-guides-toolbar"), "hidden", true);
1178 webdeveloper_configureElement(document
.getElementById("webdeveloper-ruler-toolbar"), "hidden", true);
1179 webdeveloper_removeAppliedStyle("webdeveloper-display-line-guides");
1180 webdeveloper_removeAppliedStyle("webdeveloper-display-ruler");
1182 webdeveloper_updateMetaRedirects(eventTarget
.selectedBrowser
);
1183 webdeveloper_updateRenderMode(contentDocument
);
1185 // If the persist features preference is set and is true
1186 if(webdeveloper_getBooleanPreference("webdeveloper.persist.features", true))
1188 webdeveloper_applyStyleSheets(false);
1192 // Reset the information text toolbar
1193 webdeveloper_configureElement(document
.getElementById("webdeveloper-information-text-toolbar"), "hidden", true);
1195 webdeveloper_clearAppliedStyles();
1207 // Handles the page being unloaded
1208 function webdeveloper_pageUnload(event
)
1210 var eventTarget
= event
.target
;
1212 // Try to get the original target
1215 var originalTarget
= event
.originalTarget
;
1217 // If the page is the target and the URI matches
1218 if(eventTarget
&& originalTarget
&& eventTarget
.contentDocument
&& eventTarget
== getBrowser() && eventTarget
.contentDocument
.documentURI
== originalTarget
.documentURI
)
1220 webdeveloper_updateCSSStatus();
1221 webdeveloper_updateJavaScriptStatus();
1230 // Remove applied style
1231 function webdeveloper_removeAppliedStyle(id
)
1233 // If the id is in the applied styles
1234 if(webdeveloper_contains(webdeveloper_appliedStyles
, id
))
1236 var appliedStylesLength
= webdeveloper_appliedStyles
.length
;
1238 // Loop through the applied styles
1239 for(var i
= 0; i
< appliedStylesLength
; i
++)
1241 // If this style sheet is in the applied styles
1242 if(webdeveloper_appliedStyles
[i
] == id
)
1244 webdeveloper_appliedStyles
.splice(i
, 1);
1249 // If the only applied style has been removed
1250 if(webdeveloper_appliedStyles
.length
== 0)
1252 webdeveloper_configureElement(document
.getElementById("webdeveloper-statusbar-panel"), "hidden", true);
1257 // Removes the outline from an element
1258 function webdeveloper_removeElementOutline(element
)
1260 // If the element is set
1263 element
.style
.MozOutline
= "";
1265 // If the element has an empty style attribute
1266 if(element
.hasAttribute("style") && element
.getAttribute("style") == "")
1268 element
.removeAttribute("style");
1273 // Removes all the generated menu items from the menu
1274 function webdeveloper_removeGeneratedMenuItems(menu
)
1276 var generatedMenuItems
= new Array();
1277 var menuItem
= null;
1278 var menuItems
= menu
.childNodes
;
1279 var menuItemsLength
= menuItems
.length
;
1281 // Loop through the menu items
1282 for(var i
= 0; i
< menuItemsLength
; i
++)
1284 menuItem
= menuItems
.item(i
);
1286 // If this is a generated menu item
1287 if(menuItem
&& menuItem
.hasAttribute("class") && menuItem
.getAttribute("class") == "webdeveloper-generated-menu")
1289 generatedMenuItems
.push(menuItem
);
1293 menuItemsLength
= generatedMenuItems
.length
;
1295 // Loop through the generated menu items
1296 for(i
= 0; i
< menuItemsLength
; i
++)
1298 menu
.removeChild(generatedMenuItems
[i
]);
1302 // Removes the style sheet with the given id
1303 function webdeveloper_removeStyleSheet(id
)
1305 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
1306 var documentLength
= documentList
.length
;
1308 // Loop through the documents
1309 for(var i
= 0; i
< documentLength
; i
++)
1311 webdeveloper_removeElement(documentList
[i
].getElementById(id
));
1314 webdeveloper_removeAppliedStyle(id
);
1317 // Resets the CSS status button
1318 function webdeveloper_resetCSSStatus()
1320 var cssButton
= document
.getElementById("webdeveloper-css-statusbar");
1322 webdeveloper_javaScriptCurrentTime
= null;
1323 webdeveloper_javaScriptPreviousTime
= null;
1325 // If the CSS button exists
1328 // If the CSS button has a class attribute
1329 if(cssButton
.hasAttribute("class"))
1331 cssButton
.removeAttribute("class");
1334 // If the CSS button has a tooltip text attribute
1335 if(cssButton
.hasAttribute("tooltiptext"))
1337 cssButton
.removeAttribute("tooltiptext");
1340 // If the toolbar preference is set to text and the CSS button has a label attribute
1341 if(webdeveloper_getStringPreference("webdeveloper.toolbar.icons", true) == "text" && cssButton
.hasAttribute("label"))
1343 cssButton
.removeAttribute("label");
1348 // Resets the JavaScript status button
1349 function webdeveloper_resetJavaScriptStatus()
1351 var javaScriptButton
= document
.getElementById("webdeveloper-javascript-statusbar");
1353 webdeveloper_javaScriptCurrentTime
= null;
1354 webdeveloper_javaScriptPreviousTime
= null;
1356 // If the JavaScript button exists
1357 if(javaScriptButton
)
1359 // If JavaScript is enabled
1360 if(webdeveloper_getBooleanPreference("javascript.enabled", false))
1362 // If the JavaScript button has a class attribute
1363 if(javaScriptButton
.hasAttribute("class"))
1365 javaScriptButton
.removeAttribute("class");
1368 // If the JavaScript button has a tooltip text attribute
1369 if(javaScriptButton
.hasAttribute("tooltiptext"))
1371 javaScriptButton
.removeAttribute("tooltiptext");
1374 // If the toolbar preference is set to text and the JavaScript button has a label attribute
1375 if(webdeveloper_getStringPreference("webdeveloper.toolbar.icons", true) == "text" && javaScriptButton
.hasAttribute("label"))
1377 javaScriptButton
.removeAttribute("label");
1382 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
1384 // If the JavaScript button does not have a class attribute or it is not set to disabled
1385 if(!javaScriptButton
.hasAttribute("class") || javaScriptButton
.getAttribute("class") != "disabled")
1387 javaScriptButton
.setAttribute("class", "disabled");
1388 javaScriptButton
.setAttribute("tooltiptext", stringBundle
.getString("webdeveloper_javaScriptDisabledTooltip"));
1390 // If the toolbar preference is set to text
1391 if(webdeveloper_getStringPreference("webdeveloper.toolbar.icons", true) == "text")
1393 javaScriptButton
.setAttribute("label", stringBundle
.getString("webdeveloper_javaScriptDisabledLabel"));
1401 function webdeveloper_resetPage()
1403 webdeveloper_applyStyleSheets(true);
1404 webdeveloper_clearAppliedStyles();
1406 webdeveloper_outlinedElements
= new Array();
1409 // Runs the given bookmarklet
1410 function webdeveloper_runBookmarklet(bookmarklet
)
1412 eval(decodeURIComponent(bookmarklet
));
1415 // Sets up the default options
1416 function webdeveloper_setupDefaultOptions()
1418 // Set default custom colors
1419 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.custom.1.color", "#ff0000");
1420 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.custom.2.color", "#33ff33");
1421 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.custom.3.color", "#3333ff");
1422 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.custom.4.color", "#ff0000");
1423 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.custom.5.color", "#33ff33");
1425 // Set default dashboard position
1426 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.dashboard.position", "bottom");
1428 // Set default edit CSS preferences
1429 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.edit.color.background", "#ffffff");
1430 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.edit.color.text", "#000000");
1431 webdeveloper_setIntegerPreferenceIfNotSet("webdeveloper.edit.font.size", 12);
1432 webdeveloper_setIntegerPreferenceIfNotSet("webdeveloper.edit.update.frequency", 2000);
1434 // Set default feature tooltip colors
1435 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.feature.tooltip.color.background", "#ffff99");
1436 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.feature.tooltip.color.border", "#ffcc66");
1437 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.feature.tooltip.color.text", "#000000");
1438 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.feature.tooltip.opacity", "0.9");
1440 // Set default generated content font size
1441 webdeveloper_setIntegerPreferenceIfNotSet("webdeveloper.generated.content.font.size", 12);
1443 // Set default information preference
1444 webdeveloper_setBooleanPreferenceIfNotSet("webdeveloper.information.tidy", true);
1446 // Set default line guides preference
1447 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.line.guides.color", "#000000");
1449 // Set default magnification preference
1450 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.magnification.level", "2");
1452 // Set default open tabs preference
1453 webdeveloper_setBooleanPreferenceIfNotSet("webdeveloper.open.tabs", true);
1455 // Set default populate form fields email
1456 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.populate.form.fields.email", "example@example.com");
1458 // Set default style information preference
1459 webdeveloper_setBooleanPreferenceIfNotSet("webdeveloper.style.information.dashboard", true);
1461 // Set default accessibility preferences
1462 webdeveloper_setBooleanPreferenceIfNotSet("webdeveloper.validate.local.accessibility.section508", true);
1463 webdeveloper_setBooleanPreferenceIfNotSet("webdeveloper.validate.local.accessibility.wai.priority1", true);
1465 // Set default CSS profile preference
1466 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.validate.local.css.profile", "css21");
1469 // Sets up the localized options
1470 function webdeveloper_setupLocalizedOptions()
1472 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
1474 // If the string bundle is set
1477 // Set default resize count
1478 webdeveloper_setIntegerPreferenceIfNotSet("webdeveloper.resize.count", 1);
1481 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.resize.1.description", stringBundle
.getString("webdeveloper_resize800x600"));
1482 webdeveloper_setIntegerPreferenceIfNotSet("webdeveloper.resize.1.width", 800);
1483 webdeveloper_setIntegerPreferenceIfNotSet("webdeveloper.resize.1.height", 600);
1485 // Set default tool count
1486 webdeveloper_setIntegerPreferenceIfNotSet("webdeveloper.tool.count", 8);
1488 // Set CSS validator
1489 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.1.description", stringBundle
.getString("webdeveloper_validateCSS"));
1490 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.1.url", "http://jigsaw.w3.org/css-validator/validator?profile=css21&warning=0&uri=");
1492 // Set feed validator
1493 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.2.description", stringBundle
.getString("webdeveloper_validateFeed"));
1494 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.2.url", "http://validator.w3.org/feed/check.cgi?url=");
1496 // Set HTML validator
1497 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.3.description", stringBundle
.getString("webdeveloper_validateHTML"));
1498 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.3.key", "H");
1499 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.3.url", "http://validator.w3.org/check?verbose=1&uri=");
1501 // Set links validator
1502 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.4.description", stringBundle
.getString("webdeveloper_validateLinks"));
1503 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.4.url", "http://validator.w3.org/checklink?check=Check&hide_type=all&summary=on&uri=");
1505 // Set section 508 validator
1506 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.5.description", stringBundle
.getString("webdeveloper_validateSection508"));
1507 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.5.url", "http://www.cynthiasays.com/mynewtester/cynthia.exe?rptmode=-1&url1=");
1509 // Set WAI validator
1510 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.6.description", stringBundle
.getString("webdeveloper_validateWAI"));
1511 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.6.url", "http://www.cynthiasays.com/mynewtester/cynthia.exe?rptmode=2&url1=");
1514 webdeveloper_setBooleanPreferenceIfNotSet("webdeveloper.tool.7.separator", true);
1517 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.8.description", stringBundle
.getString("webdeveloper_viewSpeedReport"));
1518 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.8.url", "http://www.websiteoptimization.com/cgi-bin/wso/wso.pl?url=");
1523 function webdeveloper_sortImages(imageOne
, imageTwo
)
1525 // If both images are set
1526 if(imageOne
&& imageTwo
)
1528 var imageOneSrc
= imageOne
.src
;
1529 var imageTwoSrc
= imageTwo
.src
;
1531 // If the images are equal
1532 if(imageOneSrc
== imageTwoSrc
)
1536 else if(imageOneSrc
< imageTwoSrc
)
1545 // Handles a tab being selected
1546 function webdeveloper_tabSelect(event
)
1548 var selectedTab
= getBrowser().mTabBox
.selectedIndex
;
1550 // If the selected tab is different
1551 if(selectedTab
!= webdeveloper_selectedTab
)
1553 webdeveloper_selectedTab
= selectedTab
;
1555 webdeveloper_resetCSSStatus();
1556 webdeveloper_resetJavaScriptStatus();
1557 webdeveloper_updateAppliedStyles();
1558 webdeveloper_updateRenderMode(webdeveloper_getContentDocument());
1560 // Reset the display line guides and display ruler toolbars
1561 webdeveloper_configureElement(document
.getElementById("webdeveloper-line-guides-toolbar"), "hidden", !webdeveloper_contains(webdeveloper_appliedStyles
, "webdeveloper-display-line-guides"));
1562 webdeveloper_configureElement(document
.getElementById("webdeveloper-ruler-toolbar"), "hidden", !webdeveloper_contains(webdeveloper_appliedStyles
, "webdeveloper-display-ruler"));
1564 // Reset the information text toolbar
1565 webdeveloper_configureElement(document
.getElementById("webdeveloper-information-text-toolbar"), "hidden", !webdeveloper_isInformationTextToolbarInUse());
1569 // Tidies a list of images by removing duplicates and sorting
1570 function webdeveloper_tidyImages(imageList
)
1573 var imageListLength
= imageList
.length
;
1574 var imageSrc
= null;
1575 var newImageList
= new Array();
1576 var newImageListLength
= null;
1577 var tidiedImageList
= new Array();
1579 // Loop through the images
1580 for(var i
= 0; i
< imageListLength
; i
++)
1582 image
= imageList
[i
];
1583 imageSrc
= image
.src
;
1585 // If the image src is set and does not end in '.xul'
1586 if(imageSrc
&& !imageSrc
.endsWith(".xul"))
1588 newImageList
.push(image
);
1592 newImageList
.sort(webdeveloper_sortImages
);
1594 newImageListLength
= newImageList
.length
;
1596 // Loop through the images
1597 for(i
= 0; i
< newImageListLength
; i
++)
1599 image
= newImageList
[i
];
1601 // If this is not the last image and the image is the same as the next image
1602 if(i
+ 1 < newImageListLength
&& image
.src
== newImageList
[i
+ 1].src
)
1607 tidiedImageList
.push(image
);
1610 return tidiedImageList
;
1613 // Toggles the applied style with the given id
1614 function webdeveloper_toggleAppliedStyle(element
, id
)
1616 webdeveloper_removeAppliedStyle(id
);
1618 // If the menu is checked
1619 if(element
&& element
.getAttribute("checked"))
1621 webdeveloper_addAppliedStyle(id
);
1625 // Toggles the feature tooltip styles
1626 function webdeveloper_toggleFeatureTooltipStyles(element
, styleSheetId
, selectors
)
1628 webdeveloper_removeStyleSheet(styleSheetId
, false);
1630 // If the menu is checked
1631 if(element
.getAttribute("checked"))
1633 var colors
= " background-color: " + webdeveloper_getStringPreference("webdeveloper.feature.tooltip.color.background", true) + " !important; border-color: " + webdeveloper_getStringPreference("webdeveloper.feature.tooltip.color.border", true) + " !important; color: " + webdeveloper_getStringPreference("webdeveloper.feature.tooltip.color.text", true) + " !important; ";
1634 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
1635 var documentLength
= documentList
.length
;
1636 var opacityValue
= webdeveloper_getStringPreference("webdeveloper.feature.tooltip.opacity", true);
1637 var opacity
= " -moz-opacity: " + opacityValue
+ " !important; opacity: " + opacityValue
+ " !important; ";
1638 var pageDocument
= null;
1639 var styleElement
= null;
1641 // Loop through the documents
1642 for(var i
= 0; i
< documentLength
; i
++)
1644 pageDocument
= documentList
[i
];
1645 styleElement
= pageDocument
.createElement("style");
1647 styleElement
.appendChild(pageDocument
.createTextNode(selectors
+ " {" + colors
+ opacity
+ "}"));
1648 styleElement
.setAttribute("id", styleSheetId
);
1649 styleElement
.setAttribute("type", "text/css");
1651 webdeveloper_getDocumentHeadElement(pageDocument
).appendChild(styleElement
);
1656 // Toggles an individual style sheet
1657 function webdeveloper_toggleIndividualStyleSheet(selectedStyleSheetHref
)
1659 var currentDocument
= webdeveloper_getContentDocument();
1660 var styleSheet
= null;
1661 var styleSheetHref
= null;
1662 var styleSheetList
= currentDocument
.styleSheets
;
1663 var styleSheetLength
= styleSheetList
.length
;
1665 // Loop through the style sheets
1666 for(var i
= 0; i
< styleSheetLength
; i
++)
1668 styleSheet
= styleSheetList
[i
];
1669 styleSheetHref
= styleSheet
.href
;
1671 // If this is the selected style sheet
1672 if(styleSheetHref
== selectedStyleSheetHref
)
1674 styleSheet
.disabled
= !styleSheet
.disabled
;
1679 // Toggles the style sheet with the given id
1680 function webdeveloper_toggleStyleSheet(element
, location
, id
)
1682 webdeveloper_removeStyleSheet(id
);
1684 // If the menu is checked
1685 if(element
&& element
.getAttribute("checked"))
1687 webdeveloper_addStyleSheet(location
, id
);
1691 // Toggles the toolbar
1692 function webdeveloper_toggleToolbar()
1694 var toolbar
= document
.getElementById("webdeveloper-toolbar");
1696 toolbar
.collapsed
= !toolbar
.collapsed
;
1698 document
.persist("webdeveloper-toolbar", "collapsed");
1701 // Uninitializes the extension
1702 function webdeveloper_uninitialize(event
)
1704 var windowContent
= window
.document
.getElementById("content");
1706 // If the window content is set
1709 var consoleService
= Components
.classes
["@mozilla.org/consoleservice;1"].getService().QueryInterface(Components
.interfaces
.nsIConsoleService
);
1710 var tabBox
= windowContent
.mTabBox
;
1712 // Try to remove the event listener
1715 windowContent
.removeEventListener("load", webdeveloper_pageLoad
, true);
1722 // Try to remove the event listener
1725 windowContent
.removeEventListener("unload", webdeveloper_pageUnload
, true);
1732 // If the console service is set
1735 // Try to remove the console listener
1738 consoleService
.unregisterListener(WebDeveloperErrorConsoleListener
);
1746 // If the tab box is set
1749 // Try to remove the event listener
1752 tabBox
.removeEventListener("select", webdeveloper_tabSelect
, false);
1760 // Try to remove the event listener
1763 window
.removeEventListener("close", webdeveloper_uninitialize
, false);
1772 // Updates the applied styles
1773 function webdeveloper_updateAppliedStyles()
1775 webdeveloper_clearAppliedStyles();
1776 webdeveloper_addAppliedStyleByElement("webdeveloper-add-user-style-sheet");
1777 webdeveloper_addAppliedStyleByElement("webdeveloper-disable-all-styles");
1778 webdeveloper_addAppliedStyleByElement("webdeveloper-disable-browser-default-styles");
1779 webdeveloper_addAppliedStyleByElement("webdeveloper-disable-all-styles");
1780 webdeveloper_addAppliedStyleByElement("webdeveloper-disable-embedded-styles");
1781 webdeveloper_addAppliedStyleByElement("webdeveloper-disable-inline-styles");
1782 webdeveloper_addAppliedStyleByElement("webdeveloper-disable-linked-styles");
1783 webdeveloper_addAppliedStyleByElement("webdeveloper-disable-print-styles");
1784 webdeveloper_addAppliedStyleByElement("webdeveloper-display-abbreviations");
1785 webdeveloper_addAppliedStyleByElement("webdeveloper-display-access-keys");
1786 webdeveloper_addAppliedStyleByElement("webdeveloper-display-alt-attributes");
1787 webdeveloper_addAppliedStyleByElement("webdeveloper-display-anchors");
1788 webdeveloper_addAppliedStyleByElement("webdeveloper-display-block-size");
1789 webdeveloper_addAppliedStyleByElement("webdeveloper-display-div-order");
1790 webdeveloper_addAppliedStyleByElement("webdeveloper-display-element-information");
1791 webdeveloper_addAppliedStyleByElement("webdeveloper-display-form-details");
1792 webdeveloper_addAppliedStyleByElement("webdeveloper-display-handheld-css");
1793 webdeveloper_addAppliedStyleByElement("webdeveloper-display-id-class-details");
1794 webdeveloper_addAppliedStyleByElement("webdeveloper-display-image-dimensions");
1795 webdeveloper_addAppliedStyleByElement("webdeveloper-display-image-file-sizes");
1796 webdeveloper_addAppliedStyleByElement("webdeveloper-display-image-paths");
1797 webdeveloper_addAppliedStyleByElement("webdeveloper-display-line-guides");
1798 webdeveloper_addAppliedStyleByElement("webdeveloper-display-link-details");
1799 webdeveloper_addAppliedStyleByElement("webdeveloper-display-object-information");
1800 webdeveloper_addAppliedStyleByElement("webdeveloper-display-print-css");
1801 webdeveloper_addAppliedStyleByElement("webdeveloper-display-ruler");
1802 webdeveloper_addAppliedStyleByElement("webdeveloper-display-stack-levels");
1803 webdeveloper_addAppliedStyleByElement("webdeveloper-display-tab-index");
1804 webdeveloper_addAppliedStyleByElement("webdeveloper-display-table-depth");
1805 webdeveloper_addAppliedStyleByElement("webdeveloper-display-table-information");
1806 webdeveloper_addAppliedStyleByElement("webdeveloper-display-title-attributes");
1807 webdeveloper_addAppliedStyleByElement("webdeveloper-display-topographic-information");
1808 webdeveloper_addAppliedStyleByElement("webdeveloper-display-window-size-title");
1809 webdeveloper_addAppliedStyleByElement("webdeveloper-hide-background-images");
1810 webdeveloper_addAppliedStyleByElement("webdeveloper-hide-images");
1811 webdeveloper_addAppliedStyleByElement("webdeveloper-linearize-page");
1812 webdeveloper_addAppliedStyleByElement("webdeveloper-make-images-invisible");
1813 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-absolute-positioned-elements");
1814 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-all-images");
1815 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-background-images");
1816 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-block-level-elements");
1817 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-current-element");
1818 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-custom-elements");
1819 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-deprecated-elements");
1820 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-external-links");
1821 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-fixed-positioned-elements");
1822 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-floated-elements");
1823 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-frames");
1824 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-headings");
1825 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-images-with-adjusted-dimensions");
1826 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-images-with-empty-alt-attributes");
1827 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-images-without-alt-attributes");
1828 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-images-without-dimensions");
1829 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-images-without-title-attributes");
1830 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-links-with-ping-attributes");
1831 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-links-without-title-attributes");
1832 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-relative-positioned-elements");
1833 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-table-captions");
1834 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-table-cells");
1835 webdeveloper_addAppliedStyleByElement("webdeveloper-outline-all-tables");
1836 webdeveloper_addAppliedStyleByElement("webdeveloper-replace-images-with-alt-attributes");
1837 webdeveloper_addAppliedStyleByElement("webdeveloper-show-comments");
1838 webdeveloper_addAppliedStyleByElement("webdeveloper-small-screen-rendering");
1839 webdeveloper_addAppliedStyleByElement("webdeveloper-use-border-box-model");
1840 webdeveloper_addAppliedStyleByElement("webdeveloper-view-style-information");
1843 // Updates the CSS status button
1844 function webdeveloper_updateCSSStatus(error
)
1846 var cssButton
= document
.getElementById("webdeveloper-css-statusbar");
1848 // If the CSS button is set
1851 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
1853 // If the error is set
1856 var errorMessage
= error
.errorMessage
;
1858 cssButton
.setAttribute("tooltiptext", stringBundle
.getFormattedString("webdeveloper_cssErrorTooltip", [errorMessage
]));
1860 // If the CSS button does not have a class attribute or it is not set to error
1861 if(!cssButton
.hasAttribute("class") || cssButton
.getAttribute("class") != "error")
1863 cssButton
.setAttribute("class", "error");
1865 // If the toolbar preference is set to text
1866 if(webdeveloper_getStringPreference("webdeveloper.toolbar.icons", true) == "text")
1868 cssButton
.setAttribute("label", stringBundle
.getString("webdeveloper_cssErrorLabel"));
1872 // If the open CSS console error preference is set
1873 if(webdeveloper_getBooleanPreference("webdeveloper.open.css.console.error", true))
1875 webdeveloper_openErrorConsole(false);
1878 else if(!cssButton
.hasAttribute("class") || cssButton
.getAttribute("class") != "valid")
1880 cssButton
.setAttribute("class", "valid");
1881 cssButton
.setAttribute("tooltiptext", stringBundle
.getString("webdeveloper_cssNoErrorsTooltip"));
1883 // If the toolbar preference is set to text
1884 if(webdeveloper_getStringPreference("webdeveloper.toolbar.icons", true) == "text")
1886 cssButton
.setAttribute("label", stringBundle
.getString("webdeveloper_cssNoErrorsLabel"));
1892 // Updates the JavaScript status button
1893 function webdeveloper_updateJavaScriptStatus(error
)
1895 var javaScriptButton
= document
.getElementById("webdeveloper-javascript-statusbar");
1897 // If the JavaScript button is set
1898 if(javaScriptButton
)
1900 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
1902 // If the error is set
1905 var errorMessage
= error
.errorMessage
;
1906 var warning
= error
.flags
& error
.warningFlag
!= 0;
1908 // If this is a warning
1911 javaScriptButton
.setAttribute("tooltiptext", stringBundle
.getFormattedString("webdeveloper_javaScriptWarningTooltip", [errorMessage
]));
1913 // If the JavaScript button does not have a class attribute or it is not set to warning
1914 if(!javaScriptButton
.hasAttribute("class") || javaScriptButton
.getAttribute("class") != "warning")
1916 javaScriptButton
.setAttribute("class", "warning");
1918 // If the toolbar preference is set to text
1919 if(webdeveloper_getStringPreference("webdeveloper.toolbar.icons", true) == "text")
1921 javaScriptButton
.setAttribute("label", stringBundle
.getString("webdeveloper_javaScriptWarningLabel"));
1925 // If the open JavaScript console warning preference is set
1926 if(webdeveloper_getBooleanPreference("webdeveloper.open.javascript.console.warning", true))
1928 webdeveloper_openErrorConsole(false);
1933 javaScriptButton
.setAttribute("tooltiptext", stringBundle
.getFormattedString("webdeveloper_javaScriptErrorTooltip", [errorMessage
]));
1935 // If the JavaScript button does not have a class attribute or it is not set to error
1936 if(!javaScriptButton
.hasAttribute("class") || javaScriptButton
.getAttribute("class") != "error")
1938 javaScriptButton
.setAttribute("class", "error");
1940 // If the toolbar preference is set to text
1941 if(webdeveloper_getStringPreference("webdeveloper.toolbar.icons", true) == "text")
1943 javaScriptButton
.setAttribute("label", stringBundle
.getString("webdeveloper_javaScriptErrorLabel"));
1947 // If the open JavaScript console error preference is set
1948 if(webdeveloper_getBooleanPreference("webdeveloper.open.javascript.console.error", true))
1950 webdeveloper_openErrorConsole(false);
1954 else if(!javaScriptButton
.hasAttribute("class") || javaScriptButton
.getAttribute("class") != "valid")
1956 javaScriptButton
.setAttribute("class", "valid");
1957 javaScriptButton
.setAttribute("tooltiptext", stringBundle
.getString("webdeveloper_javaScriptNoErrorsTooltip"));
1959 // If the toolbar preference is set to text
1960 if(webdeveloper_getStringPreference("webdeveloper.toolbar.icons", true) == "text")
1962 javaScriptButton
.setAttribute("label", stringBundle
.getString("webdeveloper_javaScriptNoErrorsLabel"));
1968 // Updates the meta redirects status
1969 function webdeveloper_updateMetaRedirects(browser
)
1971 browser
.docShell
.allowMetaRedirects
= !webdeveloper_getBooleanPreference("webdeveloper.meta.redirects.disable", true);
1974 // Updates the options menu
1975 function webdeveloper_updateOptionsMenu(suffix
)
1977 var appliedStyles
= true;
1979 // If there are no applied styles
1980 if(webdeveloper_appliedStyles
.length
== 0)
1982 appliedStyles
= false;
1985 webdeveloper_configureElement(document
.getElementById("webdeveloper-persist-features-" + suffix
), "checked", webdeveloper_getBooleanPreference("webdeveloper.persist.features", true));
1986 webdeveloper_configureElement(document
.getElementById("webdeveloper-reset-page-" + suffix
), "disabled", !appliedStyles
);
1989 // Updates the render mode status button
1990 function webdeveloper_updateRenderMode(currentDocument
)
1992 var element
= document
.getElementById("webdeveloper-render-mode-statusbar");
1994 // If the render mode button exists
1997 var renderMode
= currentDocument
.compatMode
;
1998 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
1999 var textToolbar
= false;
2001 // If the toolbar preference has a value and is set to text
2002 if(webdeveloper_getStringPreference("webdeveloper.toolbar.icons", true) == "text")
2007 // If the render mode is quirks mode
2008 if(renderMode
== "BackCompat")
2010 element
.setAttribute("class", "quirks");
2011 element
.setAttribute("tooltiptext", stringBundle
.getString("webdeveloper_quirksModeTooltip"));
2013 // If the toolbar is in text mode
2016 element
.setAttribute("label", stringBundle
.getString("webdeveloper_quirksModeLabel"));
2021 // If the render mode button has a class attribute
2022 if(element
.hasAttribute("class"))
2024 element
.removeAttribute("class");
2027 element
.setAttribute("tooltiptext", stringBundle
.getString("webdeveloper_standardsComplianceModeTooltip"));
2029 // If the toolbar is in text mode
2032 element
.setAttribute("label", stringBundle
.getString("webdeveloper_standardsComplianceModeLabel"));
2038 // Updates the status menu
2039 function webdeveloper_updateStatusMenu(statusMenu
)
2041 var appliedStylesLength
= webdeveloper_appliedStyles
.length
;
2043 webdeveloper_removeGeneratedMenuItems(statusMenu
);
2045 // Loop through the applied styles
2046 for(var i
= 0; i
< appliedStylesLength
; i
++)
2048 webdeveloper_addStatusMenuItem(statusMenu
,webdeveloper_appliedStyles
[i
]);
2051 // If the status menu has only two children
2052 if(statusMenu
.childNodes
.length
== 2)
2060 // Error console listener
2061 var WebDeveloperErrorConsoleListener
=
2063 // Observes changes in the console
2064 observe: function(error
)
2066 // If the document and error are set
2067 if(document
&& error
)
2069 // Try to convert the error to a script error
2072 error
= error
.QueryInterface(Components
.interfaces
.nsIScriptError
);
2074 var errorCategory
= error
.category
;
2075 var sourceName
= error
.sourceName
;
2077 // If the error category is set and is content javascript
2078 if(errorCategory
&& errorCategory
== "content javascript")
2080 webdeveloper_updateJavaScriptStatus(error
);
2082 else if(errorCategory
&& errorCategory
== "CSS Parser")
2084 webdeveloper_updateCSSStatus(error
);
2086 else if(sourceName
&& sourceName
.indexOf("chrome://webdeveloper/") != -1 && webdeveloper_getBooleanPreference("webdeveloper.debug", true))
2088 webdeveloper_openErrorConsole(false);