Fix for bug 108236. "intl.charset.detector" should not be treated as both a char pref and a unichar pref. Also whitespace cleanup. r=yokoyama, sr=alecf.

This commit is contained in:
bnesse%netscape.com 2001-11-29 22:46:42 +00:00
Родитель 4bc4b71f73
Коммит e363d9a25f
1 изменённых файлов: 100 добавлений и 93 удалений

Просмотреть файл

@ -1,89 +1,90 @@
function MultiplexHandler(event)
{
var node = event.target;
var name = node.getAttribute('name');
var charset;
var node = event.target;
var name = node.getAttribute('name');
if (name == 'detectorGroup') {
SetForcedDetector();
SelectDetector(event, true);
} else if (name == 'charsetGroup') {
charset = node.getAttribute('id');
charset = charset.substring('charset.'.length, charset.length)
SetForcedCharset(charset);
SetDefaultCharacterSet(charset);
} else if (name == 'charsetCustomize') {
//do nothing - please remove this else statement, once the charset prefs moves to the pref window
} else {
SetForcedCharset(node.getAttribute('id'));
SetDefaultCharacterSet(node.getAttribute('id'));
}
if (name == 'detectorGroup') {
SetForcedDetector();
SelectDetector(event, true);
} else if (name == 'charsetGroup') {
var charset = node.getAttribute('id');
charset = charset.substring('charset.'.length, charset.length)
SetForcedCharset(charset);
SetDefaultCharacterSet(charset);
} else if (name == 'charsetCustomize') {
//do nothing - please remove this else statement, once the charset prefs moves to the pref window
} else {
SetForcedCharset(node.getAttribute('id'));
SetDefaultCharacterSet(node.getAttribute('id'));
}
}
function MailMultiplexHandler(event)
{
var node = event.target;
var name = node.getAttribute('name');
var charset;
var node = event.target;
var name = node.getAttribute('name');
if (name == 'detectorGroup') {
SelectDetector(event, false);
} else if (name == 'charsetGroup') {
charset = node.getAttribute('id');
charset = charset.substring('charset.'.length, charset.length)
MessengerSetDefaultCharacterSet(charset);
} else if (name == 'charsetCustomize') {
//do nothing - please remove this else statement, once the charset prefs moves to the pref window
} else {
MessengerSetDefaultCharacterSet(node.getAttribute('id'));
}
if (name == 'detectorGroup') {
SelectDetector(event, false);
} else if (name == 'charsetGroup') {
var charset = node.getAttribute('id');
charset = charset.substring('charset.'.length, charset.length)
MessengerSetDefaultCharacterSet(charset);
} else if (name == 'charsetCustomize') {
//do nothing - please remove this else statement, once the charset prefs moves to the pref window
} else {
MessengerSetDefaultCharacterSet(node.getAttribute('id'));
}
}
function ComposerMultiplexHandler(event)
{
var node = event.target;
var name = node.getAttribute('name');
var charset;
var node = event.target;
var name = node.getAttribute('name');
if (name == 'detectorGroup') {
ComposerSelectDetector(event, true);
} else if (name == 'charsetGroup') {
charset = node.getAttribute('id');
charset = charset.substring('charset.'.length, charset.length)
EditorSetDocumentCharacterSet(charset);
} else if (name == 'charsetCustomize') {
//do nothing - please remove this else statement, once the charset prefs moves to the pref window
} else {
EditorSetDocumentCharacterSet(node.getAttribute('id'));
}
if (name == 'detectorGroup') {
ComposerSelectDetector(event, true);
} else if (name == 'charsetGroup') {
var charset = node.getAttribute('id');
charset = charset.substring('charset.'.length, charset.length)
EditorSetDocumentCharacterSet(charset);
} else if (name == 'charsetCustomize') {
//do nothing - please remove this else statement, once the charset prefs moves to the pref window
} else {
EditorSetDocumentCharacterSet(node.getAttribute('id'));
}
}
function SetDefaultCharacterSet(charset)
{
dump("Charset Overlay menu item pressed: " + charset + "\n");
dump("Charset Overlay menu item pressed: " + charset + "\n");
BrowserSetDefaultCharacterSet(charset);
}
function SelectDetector(event, doReload)
{
dump("Charset Detector menu item pressed: " + event.target.getAttribute('id') + "\n");
dump("Charset Detector menu item pressed: " + event.target.getAttribute('id') + "\n");
var uri = event.target.getAttribute("id");
var prefvalue = uri.substring('chardet.'.length, uri.length);
if("off" == prefvalue) { // "off" is special value to turn off the detectors
if ("off" == prefvalue) { // "off" is special value to turn off the detectors
prefvalue = "";
}
var pref = Components.classes['@mozilla.org/preferences-service;1'];
if (pref) {
pref = pref.getService();
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
}
if (pref) {
pref.setCharPref("intl.charset.detector", prefvalue);
try {
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var str = Components.classes["@mozilla.org/supports-wstring;1"]
.createInstance(Components.interfaces.nsISupportsWString);
str.data = prefvalue;
pref.setComplexValue("intl.charset.detector",
Components.interfaces.nsISupportsWString, str);
if (doReload) window._content.location.reload();
}
catch (ex) {
dump("Failed to set the intl.charset.detector preference.\n");
}
}
function ComposerSelectDetector(event)
@ -92,30 +93,34 @@ function ComposerSelectDetector(event)
var uri = event.target.getAttribute("id");
var prefvalue = uri.substring('chardet.'.length, uri.length);
if("off" == prefvalue) { // "off" is special value to turn off the detectors
if ("off" == prefvalue) { // "off" is special value to turn off the detectors
prefvalue = "";
}
var pref = Components.classes['@mozilla.org/preferences-service;1'];
if (pref) {
pref = pref.getService();
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
}
try {
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var str = Components.classes["@mozilla.org/supports-wstring;1"]
.createInstance(Components.interfaces.nsISupportsWString);
if (pref) {
pref.setCharPref("intl.charset.detector", prefvalue);
editorShell.LoadUrl(editorShell.editorDocument.location);
str.data = prefvalue;
pref.setComplexValue("intl.charset.detector",
Components.interfaces.nsISupportsWString, str);
editorShell.LoadUrl(editorShell.editorDocument.location);
}
catch (ex) {
dump("Failed to set the intl.charset.detector preference.\n");
}
}
function SetForcedDetector()
{
BrowserSetForcedDetector();
BrowserSetForcedDetector();
}
function SetForcedCharset(charset)
{
BrowserSetForcedCharacterSet(charset);
BrowserSetForcedCharacterSet(charset);
}
function UpdateCurrentCharset()
@ -151,20 +156,22 @@ function UpdateCurrentMailCharset()
function UpdateCharsetDetector()
{
var pref = Components.classes['@mozilla.org/preferences-service;1'];
if (pref) {
pref = pref.getService();
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
}
if (pref) {
var prefvalue;
try {
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefvalue = pref.getComplexValue("intl.charset.detector",
Components.interfaces.nsIPrefLocalizedString).data;
if (prefvalue == "") prefvalue = "off";
dump("intl.charset.detector = "+ prefvalue + "\n");
}
catch (ex) {
prefvalue = "";
}
var prefvalue = 'chardet.' + prefvalue;
if (prefvalue == "") prefvalue = "off";
dump("intl.charset.detector = "+ prefvalue + "\n");
prefvalue = 'chardet.' + prefvalue;
var menuitem = document.getElementById(prefvalue);
if (menuitem) {
@ -218,29 +225,29 @@ var gLastMailCharset = null;
function mailCharsetLoadListener (event)
{
if (msgWindow) {
var charset = msgWindow.mailCharacterSet;
if (charset.length > 0 && (charset != gLastMailCharset)) {
gCharsetMenu.SetCurrentMailCharset(charset);
gLastMailCharset = charset;
dump("mailCharsetLoadListener: " + charset + " \n");
}
var charset = msgWindow.mailCharacterSet;
if (charset.length > 0 && (charset != gLastMailCharset)) {
gCharsetMenu.SetCurrentMailCharset(charset);
gLastMailCharset = charset;
dump("mailCharsetLoadListener: " + charset + " \n");
}
}
}
var wintype = document.firstChild.getAttribute('windowtype');
if (window && (wintype == "navigator:browser"))
{
var contentArea = window.document.getElementById("appcontent");
if (contentArea)
contentArea.addEventListener("load", charsetLoadListener, true);
var contentArea = window.document.getElementById("appcontent");
if (contentArea)
contentArea.addEventListener("load", charsetLoadListener, true);
}
else
{
var arrayOfStrings = wintype.split(":");
if (window && arrayOfStrings[0] == "mail")
{
var messageContent = window.document.getElementById("messagepane");
if (messageContent)
messageContent.addEventListener("load", mailCharsetLoadListener, true);
}
var arrayOfStrings = wintype.split(":");
if (window && arrayOfStrings[0] == "mail")
{
var messageContent = window.document.getElementById("messagepane");
if (messageContent)
messageContent.addEventListener("load", mailCharsetLoadListener, true);
}
}