1999-08-19 18:28:44 +04:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
* March 31, 1998.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*/
|
|
|
|
|
2000-04-14 07:19:31 +04:00
|
|
|
var MisspelledWord;
|
1999-07-14 19:24:33 +04:00
|
|
|
var spellChecker;
|
1999-08-28 06:40:18 +04:00
|
|
|
var allowSelectWord = true;
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
var PreviousReplaceWord = "";
|
1999-05-14 00:59:08 +04:00
|
|
|
|
|
|
|
// dialog initialization code
|
|
|
|
function Startup()
|
|
|
|
{
|
1999-07-14 19:24:33 +04:00
|
|
|
if (!InitEditorShell())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Get the spellChecker shell
|
|
|
|
spellChecker = editorShell.QueryInterface(Components.interfaces.nsIEditorSpellCheck);
|
|
|
|
if (!spellChecker) {
|
|
|
|
dump("SpellChecker not found!!!\n");
|
1999-05-27 01:40:51 +04:00
|
|
|
window.close();
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create dialog object to store controls for easy access
|
|
|
|
dialog = new Object;
|
|
|
|
if (!dialog)
|
|
|
|
{
|
|
|
|
dump("Failed to create dialog object!!!\n");
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
Close();
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
2000-04-14 07:19:31 +04:00
|
|
|
dialog.MisspelledWordLabel = document.getElementById("MisspelledWordLabel");
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
dialog.MisspelledWord = document.getElementById("MisspelledWord");
|
|
|
|
dialog.ReplaceButton = document.getElementById("Replace");
|
|
|
|
dialog.IgnoreButton = document.getElementById("Ignore");
|
|
|
|
dialog.CloseButton = document.getElementById("Close");
|
|
|
|
dialog.ReplaceWordInput = document.getElementById("ReplaceWord");
|
|
|
|
dialog.SuggestedList = document.getElementById("SuggestedList");
|
|
|
|
dialog.LanguageMenulist = document.getElementById("LanguageMenulist");
|
1999-05-14 00:59:08 +04:00
|
|
|
|
2000-04-14 07:19:31 +04:00
|
|
|
if (!dialog.MisspelledWord ||
|
|
|
|
!dialog.ReplaceWordInput ||
|
|
|
|
!dialog.SuggestedList ||
|
2000-04-17 00:29:08 +04:00
|
|
|
!dialog.LanguageMenulist )
|
1999-05-14 00:59:08 +04:00
|
|
|
{
|
2001-02-16 06:34:29 +03:00
|
|
|
return;
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
// NOTE: We shouldn't have been created if there was no misspelled word
|
|
|
|
|
1999-05-27 01:40:51 +04:00
|
|
|
// The first misspelled word is passed as the 2nd extra parameter in window.openDialog()
|
2000-04-14 07:19:31 +04:00
|
|
|
MisspelledWord = window.arguments[1];
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
// Initial replace word is the misspelled word;
|
|
|
|
dialog.ReplaceWordInput.value = MisspelledWord;
|
|
|
|
PreviousReplaceWord = MisspelledWord;
|
1999-05-14 00:59:08 +04:00
|
|
|
|
2000-04-14 07:19:31 +04:00
|
|
|
if (MisspelledWord.length > 0) {
|
2000-01-19 00:53:21 +03:00
|
|
|
// Put word in the borderless button used to show the misspelled word
|
2000-04-14 07:19:31 +04:00
|
|
|
dialog.MisspelledWord.setAttribute("value", MisspelledWord);
|
1999-05-27 01:40:51 +04:00
|
|
|
// Get the list of suggested replacements
|
1999-05-14 00:59:08 +04:00
|
|
|
FillSuggestedList();
|
|
|
|
}
|
2000-01-19 00:53:21 +03:00
|
|
|
|
2000-05-04 18:37:56 +04:00
|
|
|
if (dialog.LanguageMenulist)
|
2000-05-05 18:58:43 +04:00
|
|
|
{
|
|
|
|
// Fill in the language menulist and sync it up
|
|
|
|
// with the spellchecker's current language.
|
|
|
|
|
|
|
|
var curLang;
|
|
|
|
|
|
|
|
try {
|
|
|
|
curLang = spellChecker.GetCurrentDictionary();
|
|
|
|
} catch(ex) {
|
|
|
|
curLang = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
InitLanguageMenu(curLang);
|
|
|
|
}
|
1999-05-14 00:59:08 +04:00
|
|
|
|
2000-04-14 07:19:31 +04:00
|
|
|
DoEnabling();
|
|
|
|
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
SetTextfieldFocus(dialog.ReplaceWordInput);
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
|
|
|
|
SetWindowLocation();
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
1999-05-27 01:40:51 +04:00
|
|
|
|
2000-05-05 18:58:43 +04:00
|
|
|
function InitLanguageMenu(curLang)
|
2000-05-04 18:37:56 +04:00
|
|
|
{
|
|
|
|
ClearMenulist(dialog.LanguageMenulist);
|
|
|
|
|
|
|
|
var o1 = {};
|
|
|
|
var o2 = {};
|
|
|
|
|
|
|
|
// Get the list of dictionaries from
|
|
|
|
// the spellchecker.
|
|
|
|
|
|
|
|
spellChecker.GetDictionaryList(o1, o2);
|
|
|
|
|
|
|
|
var dictList = o1.value;
|
|
|
|
var count = o2.value;
|
|
|
|
|
2000-10-20 01:09:06 +04:00
|
|
|
// Load the string bundles that will help us map
|
2000-05-04 18:37:56 +04:00
|
|
|
// RFC 1766 strings to UI strings.
|
|
|
|
|
2000-10-20 01:09:06 +04:00
|
|
|
var languageBundle;
|
|
|
|
var regionBundle;
|
2000-05-04 18:37:56 +04:00
|
|
|
var menuStr;
|
2000-10-20 01:09:06 +04:00
|
|
|
var menuStr2;
|
|
|
|
var isoStrArray;
|
2000-05-04 18:37:56 +04:00
|
|
|
var defaultIndex = 0;
|
|
|
|
|
2000-10-20 01:09:06 +04:00
|
|
|
// Try to load the language string bundle.
|
|
|
|
|
|
|
|
try {
|
|
|
|
languageBundle = srGetStrBundle("chrome://global/locale/languageNames.properties");
|
|
|
|
} catch(ex) {
|
|
|
|
languageBundle = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we have a language string bundle, try to load the region string bundle.
|
|
|
|
|
|
|
|
if (languageBundle)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
regionBundle = srGetStrBundle("chrome://global/locale/regionNames.properties");
|
|
|
|
} catch(ex) {
|
|
|
|
regionBundle = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-04 18:37:56 +04:00
|
|
|
for (var i = 0; i < dictList.length; i++)
|
|
|
|
{
|
|
|
|
try {
|
2000-10-20 01:09:06 +04:00
|
|
|
isoStrArray = dictList[i].split("-");
|
|
|
|
|
|
|
|
if (languageBundle && isoStrArray[0])
|
|
|
|
menuStr = languageBundle.GetStringFromName(isoStrArray[0].toLowerCase());
|
|
|
|
|
|
|
|
if (regionBundle && menuStr && isoStrArray.length > 1 && isoStrArray[1])
|
|
|
|
{
|
|
|
|
menuStr2 = regionBundle.GetStringFromName(isoStrArray[1].toLowerCase());
|
|
|
|
if (menuStr2)
|
|
|
|
menuStr = menuStr + "/" + menuStr2;
|
|
|
|
}
|
2000-05-04 18:37:56 +04:00
|
|
|
|
|
|
|
if (!menuStr)
|
|
|
|
menuStr = dictList[i];
|
|
|
|
} catch (ex) {
|
|
|
|
// GetStringFromName throws an exception when
|
|
|
|
// a key is not found in the bundle. In that
|
|
|
|
// case, just use the original dictList string.
|
|
|
|
|
|
|
|
menuStr = dictList[i];
|
|
|
|
}
|
|
|
|
|
2000-10-20 01:09:06 +04:00
|
|
|
if (curLang && dictList[i] == curLang)
|
|
|
|
defaultIndex = i;
|
|
|
|
|
2000-05-04 18:37:56 +04:00
|
|
|
AppendValueAndDataToMenulist(dialog.LanguageMenulist, menuStr, dictList[i]);
|
|
|
|
}
|
|
|
|
|
2000-05-05 18:58:43 +04:00
|
|
|
// Now make sure the correct item in the menu list is selected.
|
2000-05-04 18:37:56 +04:00
|
|
|
|
|
|
|
if (dictList.length > 0)
|
|
|
|
dialog.LanguageMenulist.selectedIndex = defaultIndex;
|
|
|
|
}
|
|
|
|
|
2000-04-14 07:19:31 +04:00
|
|
|
function DoEnabling()
|
1999-05-14 00:59:08 +04:00
|
|
|
{
|
2000-04-14 07:19:31 +04:00
|
|
|
if (MisspelledWord.length == 0)
|
|
|
|
{
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
// No more misspelled words
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
dialog.MisspelledWord.setAttribute("value",GetString("CheckSpellingDone"));
|
2000-04-14 07:19:31 +04:00
|
|
|
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
dialog.ReplaceButton.removeAttribute("default");
|
|
|
|
dialog.IgnoreButton.removeAttribute("default");
|
|
|
|
dialog.CloseButton.setAttribute("default","true");
|
|
|
|
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
SetElementEnabledById("MisspelledWordLabel", false);
|
2000-04-17 00:29:08 +04:00
|
|
|
SetElementEnabledById("ReplaceWordLabel", false);
|
|
|
|
SetElementEnabledById("ReplaceWord", false);
|
|
|
|
SetElementEnabledById("CheckWord", false);
|
|
|
|
SetElementEnabledById("SuggestedListLabel", false);
|
|
|
|
SetElementEnabledById("SuggestedList", false);
|
|
|
|
SetElementEnabledById("Ignore", false);
|
|
|
|
SetElementEnabledById("IgnoreAll", false);
|
|
|
|
SetElementEnabledById("Replace", false);
|
|
|
|
SetElementEnabledById("ReplaceAll", false);
|
|
|
|
SetElementEnabledById("AddToDictionary", false);
|
1999-05-14 00:59:08 +04:00
|
|
|
} else {
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
SetElementEnabledById("MisspelledWordLabel", true);
|
2000-04-17 00:29:08 +04:00
|
|
|
SetElementEnabledById("ReplaceWordLabel", true);
|
2001-03-05 18:41:39 +03:00
|
|
|
SetElementEnabledById("ReplaceWord", true);
|
2000-04-17 00:29:08 +04:00
|
|
|
SetElementEnabledById("CheckWord", true);
|
|
|
|
SetElementEnabledById("SuggestedListLabel", true);
|
|
|
|
SetElementEnabledById("SuggestedList", true);
|
|
|
|
SetElementEnabledById("Ignore", true);
|
|
|
|
SetElementEnabledById("IgnoreAll", true);
|
|
|
|
SetElementEnabledById("AddToDictionary", true);
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
dialog.CloseButton.removeAttribute("default");
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
SetReplaceEnable();
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
2000-04-14 07:19:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function NextWord()
|
|
|
|
{
|
|
|
|
MisspelledWord = spellChecker.GetNextMisspelledWord();
|
|
|
|
SetWidgetsForMisspelledWord();
|
|
|
|
}
|
|
|
|
|
|
|
|
function SetWidgetsForMisspelledWord()
|
|
|
|
{
|
|
|
|
dialog.MisspelledWord.setAttribute("value",MisspelledWord);
|
|
|
|
|
|
|
|
|
2000-01-19 00:53:21 +03:00
|
|
|
// Initial replace word is misspelled word
|
2000-04-14 07:19:31 +04:00
|
|
|
dialog.ReplaceWordInput.value = MisspelledWord;
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
PreviousReplaceWord = MisspelledWord;
|
2001-02-16 06:34:29 +03:00
|
|
|
|
|
|
|
// This sets dialog.ReplaceWordInput to first suggested word in list
|
|
|
|
FillSuggestedList();
|
2000-04-14 07:19:31 +04:00
|
|
|
|
|
|
|
DoEnabling();
|
|
|
|
|
|
|
|
if (MisspelledWord)
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
SetTextfieldFocus(dialog.ReplaceWordInput);
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function CheckWord()
|
|
|
|
{
|
2000-04-14 07:19:31 +04:00
|
|
|
word = dialog.ReplaceWordInput.value;
|
1999-05-14 00:59:08 +04:00
|
|
|
if (word != "") {
|
1999-07-14 19:24:33 +04:00
|
|
|
isMisspelled = spellChecker.CheckCurrentWord(word);
|
1999-05-27 01:40:51 +04:00
|
|
|
if (isMisspelled) {
|
2000-04-14 07:19:31 +04:00
|
|
|
MisspelledWord = word;
|
1999-05-27 01:40:51 +04:00
|
|
|
FillSuggestedList();
|
2001-02-16 06:34:29 +03:00
|
|
|
SetReplaceEnable();
|
1999-05-27 01:40:51 +04:00
|
|
|
} else {
|
2000-04-17 00:29:08 +04:00
|
|
|
ClearTreelist(dialog.SuggestedList);
|
|
|
|
var item = AppendStringToTreelistById(dialog.SuggestedList, "CorrectSpelling");
|
|
|
|
if (item) item.setAttribute("disabled", "true");
|
1999-08-28 06:40:18 +04:00
|
|
|
// Suppress being able to select the message text
|
|
|
|
allowSelectWord = false;
|
1999-05-27 01:40:51 +04:00
|
|
|
}
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function SelectSuggestedWord()
|
|
|
|
{
|
1999-08-28 06:40:18 +04:00
|
|
|
if (allowSelectWord)
|
2000-04-21 19:00:23 +04:00
|
|
|
{
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
var index = dialog.SuggestedList.selectedIndex;
|
|
|
|
if (index == -1)
|
|
|
|
{
|
|
|
|
dialog.ReplaceWordInput.value = PreviousReplaceWord;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var selValue = GetSelectedTreelistValue(dialog.SuggestedList);
|
|
|
|
dialog.ReplaceWordInput.value = selValue;
|
2001-02-16 06:34:29 +03:00
|
|
|
PreviousReplaceWord = selValue;
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
}
|
|
|
|
SetReplaceEnable();
|
2000-04-21 19:00:23 +04:00
|
|
|
}
|
2000-01-19 00:53:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function ChangeReplaceWord()
|
|
|
|
{
|
2000-05-13 02:11:06 +04:00
|
|
|
// Calling this triggers SelectSuggestedWord(),
|
|
|
|
// so temporarily suppress the effect of that
|
|
|
|
var saveAllow = allowSelectWord;
|
|
|
|
allowSelectWord = false;
|
|
|
|
|
2000-01-19 00:53:21 +03:00
|
|
|
// Unselect the word in the suggested list when user edits the replacement word
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
dialog.SuggestedList.selectedIndex = -1;
|
2000-05-13 02:11:06 +04:00
|
|
|
|
|
|
|
allowSelectWord = saveAllow;
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
|
|
|
|
// Remember the new word
|
|
|
|
PreviousReplaceWord = dialog.ReplaceWordInput.value;
|
|
|
|
|
|
|
|
SetReplaceEnable();
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function Ignore()
|
|
|
|
{
|
|
|
|
NextWord();
|
|
|
|
}
|
|
|
|
|
|
|
|
function IgnoreAll()
|
|
|
|
{
|
2000-04-14 07:19:31 +04:00
|
|
|
if (MisspelledWord != "") {
|
|
|
|
spellChecker.IgnoreWordAllOccurrences(MisspelledWord);
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
NextWord();
|
|
|
|
}
|
|
|
|
|
|
|
|
function Replace()
|
|
|
|
{
|
2000-04-14 07:19:31 +04:00
|
|
|
newWord = dialog.ReplaceWordInput.value;
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
if (MisspelledWord != "" && MisspelledWord != newWord)
|
|
|
|
{
|
|
|
|
editorShell.BeginBatchChanges();
|
2000-04-14 07:19:31 +04:00
|
|
|
isMisspelled = spellChecker.ReplaceWord(MisspelledWord, newWord, false);
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
editorShell.EndBatchChanges();
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
NextWord();
|
|
|
|
}
|
|
|
|
|
|
|
|
function ReplaceAll()
|
|
|
|
{
|
2000-04-14 07:19:31 +04:00
|
|
|
newWord = dialog.ReplaceWordInput.value;
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
if (MisspelledWord != "" && MisspelledWord != newWord)
|
|
|
|
{
|
|
|
|
editorShell.BeginBatchChanges();
|
2000-04-14 07:19:31 +04:00
|
|
|
isMisspelled = spellChecker.ReplaceWord(MisspelledWord, newWord, true);
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
editorShell.EndBatchChanges();
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
NextWord();
|
|
|
|
}
|
|
|
|
|
|
|
|
function AddToDictionary()
|
|
|
|
{
|
2000-04-14 07:19:31 +04:00
|
|
|
if (MisspelledWord != "") {
|
|
|
|
spellChecker.AddWordToDictionary(MisspelledWord);
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
2000-06-22 07:13:08 +04:00
|
|
|
NextWord();
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function EditDictionary()
|
|
|
|
{
|
2000-04-14 07:19:31 +04:00
|
|
|
window.openDialog("chrome://editor/content/EdDictionary.xul", "_blank", "chrome,close,titlebar,modal", "", MisspelledWord);
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function SelectLanguage()
|
|
|
|
{
|
2000-05-04 18:37:56 +04:00
|
|
|
var item = dialog.LanguageMenulist.selectedItem;
|
|
|
|
|
|
|
|
try {
|
|
|
|
spellChecker.SetCurrentDictionary(item.data);
|
|
|
|
} catch (ex) {
|
|
|
|
dump(ex);
|
|
|
|
}
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
|
2000-04-14 07:19:31 +04:00
|
|
|
function Recheck()
|
|
|
|
{
|
|
|
|
//TODO: Should we bother to add a "Recheck" method to interface?
|
2000-05-05 18:58:43 +04:00
|
|
|
try {
|
|
|
|
var curLang = spellChecker.GetCurrentDictionary();
|
|
|
|
|
|
|
|
spellChecker.UninitSpellChecker();
|
|
|
|
spellChecker.InitSpellChecker();
|
|
|
|
spellChecker.SetCurrentDictionary(curLang);
|
|
|
|
MisspelledWord = spellChecker.GetNextMisspelledWord();
|
|
|
|
SetWidgetsForMisspelledWord();
|
|
|
|
} catch(ex) {
|
|
|
|
dump(ex);
|
|
|
|
}
|
2000-04-14 07:19:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function FillSuggestedList()
|
1999-05-14 00:59:08 +04:00
|
|
|
{
|
2001-02-16 06:34:29 +03:00
|
|
|
var list = dialog.SuggestedList;
|
1999-05-14 00:59:08 +04:00
|
|
|
|
|
|
|
// Clear the current contents of the list
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
allowSelectWord = false;
|
2000-04-17 00:29:08 +04:00
|
|
|
ClearTreelist(list);
|
1999-05-27 01:40:51 +04:00
|
|
|
|
2000-04-14 07:19:31 +04:00
|
|
|
if (MisspelledWord.length > 0)
|
|
|
|
{
|
|
|
|
// Get suggested words until an empty string is returned
|
2000-04-21 19:00:23 +04:00
|
|
|
var count = 0;
|
2001-02-16 06:34:29 +03:00
|
|
|
var firstWord = 0;
|
2000-04-14 07:19:31 +04:00
|
|
|
do {
|
|
|
|
word = spellChecker.GetSuggestedWord();
|
2001-02-16 06:34:29 +03:00
|
|
|
if (count==0)
|
|
|
|
firstWord = word;
|
2000-04-17 00:29:08 +04:00
|
|
|
if (word.length > 0) {
|
|
|
|
AppendStringToTreelist(list, word);
|
2000-04-21 19:00:23 +04:00
|
|
|
count++;
|
2000-04-14 07:19:31 +04:00
|
|
|
}
|
2000-04-17 00:29:08 +04:00
|
|
|
} while (word.length > 0);
|
2000-04-21 19:00:23 +04:00
|
|
|
|
|
|
|
var len = list.getAttribute("length");
|
|
|
|
|
|
|
|
if (count == 0) {
|
2000-04-14 07:19:31 +04:00
|
|
|
// No suggestions - show a message but don't let user select it
|
2000-04-17 00:29:08 +04:00
|
|
|
var item = AppendStringToTreelistById(list, "NoSuggestedWords");
|
|
|
|
if (item) item.setAttribute("disabled", "true");
|
2000-04-14 07:19:31 +04:00
|
|
|
allowSelectWord = false;
|
|
|
|
} else {
|
|
|
|
allowSelectWord = true;
|
2001-02-16 06:34:29 +03:00
|
|
|
// Initialize with first suggested list by selecting it
|
|
|
|
dialog.SuggestedList.selectedIndex = 0;
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
1999-08-28 06:40:18 +04:00
|
|
|
}
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function SetReplaceEnable()
|
|
|
|
{
|
|
|
|
// Enable "Change..." buttons only if new word is different than misspelled
|
|
|
|
var newWord = dialog.ReplaceWordInput.value;
|
|
|
|
var enable = newWord.length > 0 && newWord != MisspelledWord;
|
|
|
|
SetElementEnabledById("Replace", enable);
|
|
|
|
SetElementEnabledById("ReplaceAll", enable);
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
if (enable)
|
|
|
|
{
|
|
|
|
dialog.ReplaceButton.setAttribute("default","true");
|
|
|
|
dialog.IgnoreButton.removeAttribute("default");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dialog.IgnoreButton.setAttribute("default","true");
|
|
|
|
dialog.ReplaceButton.removeAttribute("default");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function doDefault()
|
|
|
|
{
|
|
|
|
if (dialog.ReplaceButton.getAttribute("default") == "true")
|
|
|
|
Replace();
|
|
|
|
else if (dialog.IgnoreButton.getAttribute("default") == "true")
|
|
|
|
Ignore();
|
|
|
|
else if (dialog.CloseButton.getAttribute("default") == "true")
|
|
|
|
onClose();
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
}
|
|
|
|
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
function onClose()
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
{
|
|
|
|
// Shutdown the spell check and close the dialog
|
|
|
|
spellChecker.UninitSpellChecker();
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
SaveWindowLocation();
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
window.close();
|
2000-10-11 01:40:39 +04:00
|
|
|
return true;
|
1999-05-14 00:59:08 +04:00
|
|
|
}
|
|
|
|
|