1 // Loads the given application with the given URL
2 function webdeveloper_loadApplicationWithURL(application
, url
)
4 // If the application and URL are set
7 application
= new WebDeveloperApplication(application
);
9 application
.launchWithURL(url
);
13 // Opens the DOM Inspector
14 function webdeveloper_openDOMInspector()
16 // If the DOM Inspector is available
17 if(webdeveloper_isDOMInspectorAvailable())
19 // If the open DOM Inspector in dashboard preference is set to true
20 if(webdeveloper_getBooleanPreference("webdeveloper.dom.inspector.dashboard", true))
22 var domInspector
= document
.getElementById("webdeveloper-string-bundle").getString("webdeveloper_domInspector");
24 // If the DOM inspector is already open in the dashboard
25 if(webdeveloper_isOpenInDashboard(domInspector
))
27 webdeveloper_closeInDashboard(domInspector
);
31 webdeveloper_openInDashboard(domInspector
, "chrome://inspector/content/sidebar.xul");
32 window
.setTimeout(BrowserReload
, 1000);
37 inspectDOMDocument(webdeveloper_getContentDocument());
42 window
.openDialog("chrome://webdeveloper/content/message/message.xul", "webdeveloper-message-dialog", "centerscreen,chrome,modal", document
.getElementById("webdeveloper-string-bundle").getString("webdeveloper_domInspectorRequired"), "http://chrispederick.com/work/web-developer/documentation/faq/#dom-inspector");
46 // Opens the Java Console
47 function webdeveloper_openJavaConsole()
49 Components
.classes
["@mozilla.org/oji/jvm-mgr;1"].getService(Components
.interfaces
.nsIJVMManager
).showJavaConsole();
52 // Updates the tools menu
53 function webdeveloper_updateToolsMenu(menu
, suffix
)
55 var bookmarklet
= null;
56 var bookmarkletPreference
= null;
57 var description
= null;
58 var descriptionPreference
= null;
63 var stringBundle
= document
.getElementById("webdeveloper-string-bundle");
64 var toolPreference
= null;
65 var toolsCount
= webdeveloper_getIntegerPreference("webdeveloper.tool.count", true);
66 var toolsSeparator
= menu
.getElementsByAttribute("id", "webdeveloper-tools-separator1-" + suffix
)[0];
69 webdeveloper_removeGeneratedMenuItems(menu
);
71 // Loop through the possible tools
72 for(var i
= 1; i
<= toolsCount
; i
++)
74 bookmarklet
= "webdeveloper.tool." + i
+ ".bookmarklet";
75 description
= "webdeveloper.tool." + i
+ ".description";
76 key
= "webdeveloper.tool." + i
+ ".key";
77 path
= "webdeveloper.tool." + i
+ ".path";
78 separator
= "webdeveloper.tool." + i
+ ".separator";
79 url
= "webdeveloper.tool." + i
+ ".url";
81 // If the separator preference is set
82 if(webdeveloper_getBooleanPreference(separator
, true))
84 menuItem
= document
.createElement("menuseparator");
85 menuItem
.setAttribute("class", "webdeveloper-generated-menu");
86 menu
.insertBefore(menuItem
, toolsSeparator
);
88 else if(webdeveloper_isPreferenceSet(description
) && (webdeveloper_isPreferenceSet(bookmarklet
) || webdeveloper_isPreferenceSet(path
) || webdeveloper_isPreferenceSet(url
)))
90 descriptionPreference
= webdeveloper_getStringPreference(description
, true);
92 // If the description is not blank
93 if(descriptionPreference
!= "")
95 menuItem
= document
.createElement("menuitem");
97 menuItem
.setAttribute("class", "webdeveloper-generated-menu");
98 menuItem
.setAttribute("label", descriptionPreference
);
100 // If the bookmarklet preference is set
101 if(webdeveloper_getStringPreference(bookmarklet
, true))
103 menuItem
.setAttribute("oncommand", "webdeveloper_runBookmarklet('" + encodeURIComponent(webdeveloper_getStringPreference(bookmarklet
, true)).replace(new RegExp("'", "gi"), "\\'") + "')");
105 else if(webdeveloper_getStringPreference(path
, true))
107 menuItem
.setAttribute("oncommand", "webdeveloper_loadApplicationWithURL('" + webdeveloper_getStringPreference(path
, true).replace(/\\/gi
, "\\\\") + "', getBrowser().currentURI.spec)");
111 menuItem
.setAttribute("oncommand", "webdeveloper_loadURL('" + webdeveloper_getStringPreference(url
, true) + "' + encodeURIComponent(getBrowser().currentURI.spec))");
114 // If the key preference is set
115 if(webdeveloper_isPreferenceSet(key
))
117 menuItem
.setAttribute("key", key
);
120 menu
.insertBefore(menuItem
, toolsSeparator
);
125 menuItem
= document
.getElementById("webdeveloper-dom-inspector-" + suffix
);
127 // If the menu exists
130 // If the DOM Inspector is not available
131 if(!webdeveloper_isDOMInspectorAvailable())
133 menuItem
.setAttribute("class", "menuitem-iconic");
135 else if(menuItem
.hasAttribute("class"))
137 menuItem
.removeAttribute("class");
141 webdeveloper_configureElement(document
.getElementById("webdeveloper-dom-inspector-" + suffix
), "checked", webdeveloper_isOpenInDashboard(stringBundle
.getString("webdeveloper_domInspector")));
142 webdeveloper_configureElement(document
.getElementById("webdeveloper-display-page-validation-" + suffix
), "checked", !document
.getElementById("webdeveloper-page-validation-toolbar").hidden
);
143 webdeveloper_configureElement(document
.getElementById("webdeveloper-error-console-" + suffix
), "checked", webdeveloper_isOpenInDashboard(stringBundle
.getString("webdeveloper_errorConsole")));
146 // Validates a local HTML file for accessibility
147 function webdeveloper_validateLocalAccessibility()
149 new WebDeveloperValidateAccessibility().validateAccessibility(getBrowser().currentURI
);
152 // Validates local CSS
153 function webdeveloper_validateLocalCSS()
155 new WebDeveloperValidateCSS().validateCSS(getBrowser().currentURI
, webdeveloper_getDocuments(webdeveloper_getContentWindow()));
158 // Validates a local HTML file
159 function webdeveloper_validateLocalHTML()
161 new WebDeveloperValidateHTML().validateHTML(getBrowser().currentURI
);