8 if ( typeof gBrowser !=
'undefined' ) {
9 gBrowser.addEventListener(
"pageshow",
function(evt) {
15 window.addEventListener(
"load",
function(e) {
28 var
node =
event.target;
29 var
name = node.getAttribute(
'name');
31 if (name ==
'detectorGroup') {
34 }
else if (name ==
'charsetGroup') {
35 var
charset = node.getAttribute(
'id');
36 charset = charset.substring(
'charset.'.length, charset.length)
38 }
else if (name ==
'charsetCustomize') {
43 }
catch(ex) { alert(ex); }
48 var
uri =
event.target.getAttribute(
"id");
49 var prefvalue = uri.substring(
'chardet.'.length, uri.length);
50 if (
"off" == prefvalue) {
55 var
pref = Components.classes[
"@mozilla.org/preferences-service;1"]
56 .getService(Components.interfaces.nsIPrefBranch);
57 var
str = Components.classes[
"@mozilla.org/supports-string;1"]
58 .createInstance(Components.interfaces.nsISupportsString);
61 pref.setComplexValue(
"intl.charset.detector",
62 Components.interfaces.nsISupportsString, str);
63 if (doReload)
window.content.location.reload();
66 dump(
"Failed to set the intl.charset.detector preference.\n");
82 var docCharset =
getBrowser().selectedBrowser.docShell.QueryInterface(
83 Components.interfaces.nsIDocCharset);
84 docCharset.charset = aCharset;
90 gBrowser.selectedBrowser.documentCharsetInfo.forcedDetector =
true;
100 var wnd = document.commandDispatcher.focusedWindow;
102 menuitem = document.getElementById(
'charset.' + wnd.document.characterSet);
108 var pref_item = document.getElementById(
'charset.' + gPrevCharset);
110 pref_item.setAttribute(
'checked',
'false');
112 menuitem.setAttribute(
'checked',
'true');
121 var
pref = Components.classes[
"@mozilla.org/preferences-service;1"]
122 .getService(Components.interfaces.nsIPrefBranch);
123 prefvalue = pref.getComplexValue(
"intl.charset.detector",
124 Components.interfaces.nsIPrefLocalizedString).data;
130 if (prefvalue ==
"") prefvalue =
"off";
131 dump(
"intl.charset.detector = "+ prefvalue +
"\n");
133 prefvalue =
'chardet.' + prefvalue;
134 var menuitem = document.getElementById(prefvalue);
137 menuitem.setAttribute(
'checked',
'true');
154 var
observerService = Components.classes[
"@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
155 observerService.notifyObservers(
null,
"charsetmenu-selected",
node);
162 if (charset.length > 0 && (charset != gLastBrowserCharset)) {
164 gCharsetMenu = Components.classes[
'@mozilla.org/rdf/datasource;1?name=charset-menu'].getService().QueryInterface(Components.interfaces.nsICurrentCharsetListener);
165 gCharsetMenu.SetCurrentCharset(charset);
174 gBrowser = document.getElementById(
"content");
180 return gBrowser.selectedBrowser.markupDocumentViewer;
186 var styleSheets = frame.document.styleSheets;
187 var styleSheetsArray =
new Array(styleSheets.length);
188 for (var
i = 0;
i < styleSheets.length;
i++) {
189 styleSheetsArray[
i] = styleSheets[
i];
191 return styleSheetsArray;
197 for (var
i = 0;
i < frameset.frames.length;
i++) {
199 styleSheetsArray = styleSheetsArray.concat(frameSheets);
201 return styleSheetsArray;
206 var noStyle = menuPopup.firstChild;
207 var persistentOnly = noStyle.nextSibling;
208 var sep = persistentOnly.nextSibling;
209 while (sep.nextSibling)
210 menuPopup.removeChild(sep.nextSibling);
213 var currentStyleSheets = [];
215 var haveAltSheets =
false;
216 var altStyleSelected =
false;
218 for (var
i = 0;
i < styleSheets.length; ++
i) {
219 var currentStyleSheet = styleSheets[
i];
222 var media = currentStyleSheet.media.mediaText.toLowerCase();
223 if (media && (media.indexOf(
"screen") == -1) && (media.indexOf(
"all") == -1))
226 if (currentStyleSheet.title) {
227 if (!currentStyleSheet.disabled)
228 altStyleSelected =
true;
230 haveAltSheets =
true;
232 var lastWithSameTitle =
null;
233 if (currentStyleSheet.title in currentStyleSheets)
234 lastWithSameTitle = currentStyleSheets[currentStyleSheet.title];
236 if (!lastWithSameTitle) {
237 var
menuItem = document.createElement(
"menuitem");
238 menuItem.setAttribute(
"type",
"radio");
239 menuItem.setAttribute(
"label", currentStyleSheet.title);
240 menuItem.setAttribute(
"data", currentStyleSheet.title);
241 menuItem.setAttribute(
"checked", !currentStyleSheet.disabled && !styleDisabled);
242 menuPopup.appendChild(menuItem);
243 currentStyleSheets[currentStyleSheet.title] =
menuItem;
245 if (currentStyleSheet.disabled)
246 lastWithSameTitle.removeAttribute(
"checked");
251 noStyle.setAttribute(
"checked", styleDisabled);
252 persistentOnly.setAttribute(
"checked", !altStyleSelected && !styleDisabled);
253 persistentOnly.hidden = (
window.content.document.preferredStyleSheetSet) ? haveAltSheets :
false;
254 sep.hidden = (noStyle.hidden && persistentOnly.hidden) || !haveAltSheets;
259 var docStyleSheets = frame.document.styleSheets;
261 for (var
i = 0;
i < docStyleSheets.length; ++
i) {
262 if (docStyleSheets[
i].title == title)
269 var docStyleSheets = frame.document.styleSheets;
271 for (var
i = 0;
i < docStyleSheets.length; ++
i) {
272 var docStyleSheet = docStyleSheets[
i];
274 if (title ==
"_nostyle")
275 docStyleSheet.disabled =
true;
276 else if (docStyleSheet.title)
277 docStyleSheet.disabled = (docStyleSheet.title != title);
278 else if (docStyleSheet.disabled)
279 docStyleSheet.disabled =
false;
287 for (var
i = 0;
i < frameset.frames.length;
i++) {
304 var docCharset =
"charset=" +
aDocument.characterSet;
319 ifRequestor = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
321 webNav = ifRequestor.getInterface(nsIWebNavigation);
333 var PageLoader = webNav.QueryInterface(Components.interfaces.nsIWebPageDescriptor);
335 pageCookie = PageLoader.currentDescriptor;
345 var utils =
window.top.gViewSourceUtils;
346 if (
getBoolPref(
"view_source.editor.external",
false)) {
347 utils.openInExternalEditor(aURL, aPageDescriptor,
aDocument);
350 utils.openInInternalViewer(aURL, aPageDescriptor,
aDocument);
static nsCOMPtr< nsIObserverService > observerService
function getBoolPref(prefname, def)
_collectFormDataForFrame aDocument
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
function BrowserReloadWithFlags(reloadFlags)
_getSelectedPageStyle s i
function getWebNavigation()