1 // Clears all private data
2 function webdeveloper_clearAllPrivateData()
4 // If the browser glue is found
5 if(Components
.classes
["@mozilla.org/browser/browserglue;1"])
7 Components
.classes
["@mozilla.org/browser/browserglue;1"].getService(nsCI
.nsIBrowserGlue
).sanitize(window
|| null);
11 window
.openDialog("chrome://webdeveloper/content/message/message.xul", "webdeveloper-message-dialog", "centerscreen,chrome,modal", document
.getElementById("webdeveloper-string-bundle").getString("webdeveloper_firefox15Required"));
16 function webdeveloper_clearCache()
18 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
20 // If the clearing is confirmed
21 if(webdeveloper_clearConfirmation(stringBundle
.getString("webdeveloper_clearCacheConfirmation")))
23 var cacheInterface
= Components
.interfaces
.nsICache
;
24 var cacheService
= Components
.classes
["@mozilla.org/network/cache-service;1"].getService(Components
.interfaces
.nsICacheService
);
28 cacheService
.evictEntries(cacheInterface
.STORE_ON_DISK
);
29 cacheService
.evictEntries(cacheInterface
.STORE_IN_MEMORY
);
31 // If the hide informational dialogs preference is not set
32 if(!webdeveloper_getBooleanPreference("webdeveloper.informational.dialogs.hide", true))
34 webdeveloper_informationalDialog(stringBundle
.getString("webdeveloper_clearCache"), stringBundle
.getString("webdeveloper_clearCacheResult"));
45 function webdeveloper_clearHistory()
47 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
49 // If the clearing is confirmed
50 if(webdeveloper_clearConfirmation(stringBundle
.getString("webdeveloper_clearHistoryConfirmation")))
52 webdeveloper_removeAllFromHistory();
54 // If the hide informational dialogs preference is not set
55 if(!webdeveloper_getBooleanPreference("webdeveloper.informational.dialogs.hide", true))
57 webdeveloper_informationalDialog(stringBundle
.getString("webdeveloper_clearHistory"), stringBundle
.getString("webdeveloper_clearHistoryResult"));
62 // Clears the HTTP authentication
63 function webdeveloper_clearHTTPAuthentication()
65 var authenticationManager
= Components
.classes
["@mozilla.org/network/http-auth-manager;1"].getService(Components
.interfaces
.nsIHttpAuthManager
);
67 authenticationManager
.clearAll();
69 // If the hide informational dialogs preference is not set
70 if(!webdeveloper_getBooleanPreference("webdeveloper.informational.dialogs.hide", true))
72 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
74 webdeveloper_informationalDialog(stringBundle
.getString("webdeveloper_clearHTTPAuthentication"), stringBundle
.getString("webdeveloper_clearHTTPAuthenticationResult"));
78 // Allows the user to edit the HTML of the current page
79 function webdeveloper_editHTML()
81 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
82 var editHTML
= stringBundle
.getString("webdeveloper_editHTML");
84 // If edit HTML is open in the dashboard
85 if(webdeveloper_isOpenInDashboard(editHTML
))
87 webdeveloper_closeInDashboard(editHTML
);
89 else if(webdeveloper_pageHasFrames())
91 window
.openDialog("chrome://webdeveloper/content/message/message.xul", "webdeveloper-message-dialog", "centerscreen,chrome,modal", stringBundle
.getString("webdeveloper_framesNotSupported"));
95 webdeveloper_openInDashboard(editHTML
, "chrome://webdeveloper/content/dashboard/edit_html.xul");
99 // Linearizes all elements
100 function webdeveloper_linearizePage(element
)
102 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/linearize_page.css", "webdeveloper-linearize-page");
105 // Makes all the frames resizable
106 function webdeveloper_makeFramesResizable()
108 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
109 var documentLength
= documentList
.length
;
111 var framesList
= null;
112 var framesLength
= null;
113 var pageDocument
= null;
114 var resizableFrames
= 0;
116 // Loop through the documents
117 for(var i
= 0; i
< documentLength
; i
++)
119 pageDocument
= documentList
[i
];
120 framesList
= pageDocument
.getElementsByTagName("frame");
121 framesLength
= framesList
.length
;
123 // Loop through all the frames
124 for(var j
= 0; j
< framesLength
; j
++)
126 frame
= framesList
[j
];
128 // If the frame has a no resize attribute
129 if(frame
.hasAttribute("noresize"))
131 frame
.removeAttribute("noresize");
137 // If the hide informational dialogs preference is not set
138 if(!webdeveloper_getBooleanPreference("webdeveloper.informational.dialogs.hide", true))
140 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
141 var title
= stringBundle
.getString("webdeveloper_makeFramesResizable");
143 // If one frame was made resizable
144 if(resizableFrames
== 1)
146 webdeveloper_informationalDialog(title
, stringBundle
.getString("webdeveloper_makeFramesResizableSingleResult"));
150 webdeveloper_informationalDialog(title
, stringBundle
.getFormattedString("webdeveloper_makeFramesResizableMultipleResult", [resizableFrames
]));
155 // Shows all hidden elements
156 function webdeveloper_showHiddenElements()
158 var computedStyle
= null;
160 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
161 var documentLength
= documentList
.length
;
163 var hiddenElements
= new Array("area", "base", "basefont", "head", "meta", "param", "script", "style", "title");
164 var pageDocument
= null;
166 var treeWalker
= null;
168 // Loop through the documents
169 for(var i
= 0; i
< documentLength
; i
++)
171 pageDocument
= documentList
[i
];
172 treeWalker
= pageDocument
.createTreeWalker(webdeveloper_getDocumentBodyElement(pageDocument
), NodeFilter
.SHOW_ELEMENT
, null, false);
174 // While the tree walker has more nodes
175 while((element
= treeWalker
.nextNode()) != null)
177 computedStyle
= element
.ownerDocument
.defaultView
.getComputedStyle(element
, null);
179 // If the computed style is set
182 display
= computedStyle
.getPropertyCSSValue("display");
183 tagName
= element
.tagName
;
185 // If this element has a display and tag name, the display is set to none and the tag name is not script
186 if(display
&& tagName
&& display
.cssText
== "none" && !webdeveloper_contains(hiddenElements
, tagName
.toLowerCase()))
188 element
.style
.display
= "";
195 // Shows the window chrome
196 function webdeveloper_showWindowChrome()
198 var browserWindow
= null;
199 var windowEnumeration
= Components
.classes
["@mozilla.org/appshell/window-mediator;1"].getService(Components
.interfaces
.nsIWindowMediator
).getEnumerator("navigator:browser");
201 // Loop through the open windows
202 while(windowEnumeration
.hasMoreElements())
204 browserWindow
= windowEnumeration
.getNext();
206 browserWindow
.locationbar
.visible
= true;
207 browserWindow
.menubar
.visible
= true;
208 browserWindow
.personalbar
.visible
= true;
209 browserWindow
.statusbar
.visible
= true;
210 browserWindow
.toolbar
.visible
= true;
214 // Renders the page for a small screen
215 function webdeveloper_smallScreenRendering(element
)
217 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
218 var documentLength
= documentList
.length
;
219 var styleSheetList
= new Array();
221 // Loop through the documents
222 for(var i
= 0; i
< documentLength
; i
++)
224 styleSheetList
= styleSheetList
.concat(webdeveloper_getStyleSheetsForDocument(documentList
[i
], false, false));
227 // If there is a handheld style sheet
228 if(webdeveloper_hasStyleSheetForMedia(styleSheetList
, "handheld"))
230 webdeveloper_displayCSSMediaType("handheld", !element
.getAttribute("checked"));
231 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/empty.css", "webdeveloper-small-screen-rendering");
235 webdeveloper_toggleStyleSheet(element
, "chrome://webdeveloper/content/stylesheets/small_screen_rendering.css", "webdeveloper-small-screen-rendering");
239 // Toggles all links on the page between visited and unvisited
240 function webdeveloper_toggleVisitedLinks(visited
)
242 var documentList
= webdeveloper_getDocuments(webdeveloper_getContentWindow());
243 var documentLength
= documentList
.length
;
246 var linkLength
= null;
248 var pageDocument
= null;
250 // Loop through the documents
251 for(var i
= 0; i
< documentLength
; i
++)
253 pageDocument
= documentList
[i
];
254 linkList
= pageDocument
.links
;
255 linkLength
= linkList
.length
;
257 // Loop through all the links
258 for(var j
= 0; j
< linkLength
; j
++)
263 // If this link has an href
266 // If marking links as visited
269 webdeveloper_addToHistory(href
);
273 webdeveloper_removeFromHistory(href
);
276 // Force the browser to recheck the history by changing the href
283 // Updates the clear private data menu
284 function webdeveloper_updateClearPrivateDataMenu(suffix
)
286 var menu
= document
.getElementById("webdeveloper-clear-all-private-data-" + suffix
);
288 // If the menu exists
291 // If the browser glue is not found
292 if(!Components
.classes
["@mozilla.org/browser/browserglue;1"])
294 menu
.setAttribute("class", "menuitem-iconic");
296 else if(menu
.hasAttribute("class"))
298 menu
.removeAttribute("class");
303 // Updates the miscellaneous menu
304 function webdeveloper_updateMiscellaneousMenu(suffix
)
306 var menu
= document
.getElementById("webdeveloper-edit-html-" + suffix
);
307 var pageHasFrames
= webdeveloper_pageHasFrames();
309 // If the menu exists
312 var editHTMLOpen
= webdeveloper_isOpenInDashboard(document
.getElementById("webdeveloper-string-bundle").getString("webdeveloper_editHTML"));
314 webdeveloper_configureElement(menu
, "checked", editHTMLOpen
);
316 // If edit HTML is not open and the page has frames
317 if(!editHTMLOpen
&& pageHasFrames
)
319 menu
.setAttribute("class", "menuitem-iconic");
321 else if(menu
.hasAttribute("class"))
323 menu
.removeAttribute("class");
327 menu
= document
.getElementById("webdeveloper-display-line-guides-" + suffix
);
329 // If the menu exists
332 // If the page has frames
335 menu
.setAttribute("class", "menuitem-iconic");
337 else if(menu
.hasAttribute("class"))
339 menu
.removeAttribute("class");
343 menu
= document
.getElementById("webdeveloper-display-page-magnifier-" + suffix
);
345 // If the menu exists
348 var canvas
= document
.getElementById("webdeveloper-page-magnifier");
350 // If the canvas is not set or has no context
351 if(!canvas
|| !canvas
.getContext
)
353 menu
.setAttribute("class", "menuitem-iconic");
355 else if(menu
.hasAttribute("class"))
357 menu
.removeAttribute("class");
361 menu
= document
.getElementById("webdeveloper-display-ruler-" + suffix
);
363 // If the menu exists
366 // If the page has frames
369 menu
.setAttribute("class", "menuitem-iconic");
371 else if(menu
.hasAttribute("class"))
373 menu
.removeAttribute("class");
377 webdeveloper_configureElement(document
.getElementById("webdeveloper-display-page-magnifier-" + suffix
), "checked", !document
.getElementById("webdeveloper-page-magnifier-toolbar").hidden
);
378 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-line-guides-" + suffix
), "checked", "webdeveloper-display-line-guides");
379 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-display-ruler-" + suffix
), "checked", "webdeveloper-display-ruler");
380 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-linearize-page-" + suffix
), "checked", "webdeveloper-linearize-page");
381 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-show-comments-" + suffix
), "checked", "webdeveloper-show-comments");
382 webdeveloper_configureElementByAppliedStyle(document
.getElementById("webdeveloper-small-screen-rendering-" + suffix
), "checked", "webdeveloper-small-screen-rendering");