Index: gc_lang/fr/tb/content/about.js
==================================================================
--- gc_lang/fr/tb/content/about.js
+++ gc_lang/fr/tb/content/about.js
@@ -1,15 +1,10 @@
// JavaScript
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
-//const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
-
-function echo (...args) {
- Services.console.logStringMessage(args.join(" -- ") + "\n");
-}
function openInBrowserURL (sURL) {
// method found in S3.Google.Translator
try {
Index: gc_lang/fr/tb/content/conjugueur.js
==================================================================
--- gc_lang/fr/tb/content/conjugueur.js
+++ gc_lang/fr/tb/content/conjugueur.js
@@ -1,44 +1,39 @@
// JavaScript
const Cu = Components.utils;
-const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
-const conj = require("resource://grammalecte/fr/conj.js");
-
-
-function echo (...args) {
- Services.console.logStringMessage(args.join(" -- ") + "\n");
-}
+//const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
+//const conj = require("resource://grammalecte/fr/conj.js");
let oConj = {
init: function () {
- let that = this;
+ console.log("Init conjugueur");
try {
// button
- document.getElementById('conjugate').addEventListener("click", function (event) {
- that.getVerbAndConjugate();
+ document.getElementById('conjugate').addEventListener("click", (xEvent) => {
+ this.getVerbAndConjugate();
});
// text field
- document.getElementById('verb').addEventListener("change", function (event) {
- that.getVerbAndConjugate();
+ document.getElementById('verb').addEventListener("change", (xEvent) => {
+ this.getVerbAndConjugate();
});
// options
- document.getElementById('oneg').addEventListener("click", function (event) {
- that._displayResults();
- });
- document.getElementById('opro').addEventListener("click", function (event) {
- that._displayResults();
- });
- document.getElementById('oint').addEventListener("click", function (event) {
- that._displayResults();
- });
- document.getElementById('ofem').addEventListener("click", function (event) {
- that._displayResults();
- });
- document.getElementById('otco').addEventListener("click", function (event) {
- that._displayResults();
+ document.getElementById('oneg').addEventListener("click", (xEvent) => {
+ this._displayResults();
+ });
+ document.getElementById('opro').addEventListener("click", (xEvent) => {
+ this._displayResults();
+ });
+ document.getElementById('oint').addEventListener("click", (xEvent) => {
+ this._displayResults();
+ });
+ document.getElementById('ofem').addEventListener("click", (xEvent) => {
+ this._displayResults();
+ });
+ document.getElementById('otco').addEventListener("click", (xEvent) => {
+ this._displayResults();
});
}
catch (e) {
Cu.reportError(e);
}
Index: gc_lang/fr/tb/content/conjugueur.xul
==================================================================
--- gc_lang/fr/tb/content/conjugueur.xul
+++ gc_lang/fr/tb/content/conjugueur.xul
@@ -152,7 +152,8 @@
+
Index: gc_lang/fr/tb/content/editor.js
==================================================================
--- gc_lang/fr/tb/content/editor.js
+++ gc_lang/fr/tb/content/editor.js
@@ -19,15 +19,13 @@
* _getParsableNodes (xRootNode=this.xEditor.rootElement) {
// recursive function
try {
for (let xNode of xRootNode.childNodes) {
- //echo("tag: " + xNode.tagName);
if (xNode.className !== "moz-cite-prefix" && xNode.tagName !== "BLOCKQUOTE"
&& (xNode.nodeType == Node.TEXT_NODE || (xNode.nodeType == Node.ELEMENT_NODE && !xNode.textContent.startsWith(">")))
&& xNode.textContent !== "") {
- //echo("<"+xNode.tagName+">["+xNode.textContent+"]");
if (xNode.tagName === undefined) {
if (!prefs.getBoolPref("bCheckSignature") && xNode.textContent.startsWith("-- ")) {
break;
}
yield xNode;
Index: gc_lang/fr/tb/content/gc_options.js
==================================================================
--- gc_lang/fr/tb/content/gc_options.js
+++ gc_lang/fr/tb/content/gc_options.js
@@ -2,28 +2,22 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker.");
-//const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
-function echo (...args) {
- Services.console.logStringMessage(args.join(" -- ") + "\n");
-}
var oOptControl = {
oOptions: null,
load: function () {
this._setDialogOptions(false);
},
_setDialogOptions: function (bDefaultOptions=false) {
try {
sOptions = bDefaultOptions ? prefs.getCharPref("sGCDefaultOptions") : prefs.getCharPref("sGCOptions");
- //echo(">> " + sOptions);
this.oOptions = JSON.parse(sOptions);
for (let sParam in this.oOptions) {
- //echo(sParam + ":" + oOptions[sParam]);
if (document.getElementById("option_"+sParam) !== null) {
document.getElementById("option_"+sParam).checked = this.oOptions[sParam];
}
}
}
@@ -35,11 +29,10 @@
try {
for (let xNode of document.getElementsByClassName("option")) {
this.oOptions[xNode.id.slice(7)] = xNode.checked;
}
prefs.setCharPref("sGCOptions", JSON.stringify(this.oOptions));
- //echo("<< " + JSON.stringify(this.oOptions));
}
catch (e) {
Cu.reportError(e);
}
},
Index: gc_lang/fr/tb/content/overlay.js
==================================================================
--- gc_lang/fr/tb/content/overlay.js
+++ gc_lang/fr/tb/content/overlay.js
@@ -4,27 +4,18 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
-const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
+//const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
const { BasePromiseWorker } = Cu.import('resource://gre/modules/PromiseWorker.jsm', {});
const Task = Cu.import("resource://gre/modules/Task.jsm").Task;
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker.");
-//Cu.import("resource://gre/modules/Console.jsm"); // doesn’t work
-//const xConsole = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
-//xConsole.logStringMessage("Grammalecte: " + args.join(" · ")); // useless now. Use: Services.console.logStringMessage("***");
-
-const text = require("resource://grammalecte/text.js");
-const tf = require("resource://grammalecte/fr/textformatter.js");
-
-
-function echo (...args) {
- dump(args.join(" -- ") + "\n"); // obsolete since TB 52?
- Services.console.logStringMessage("Grammalecte: " + args.join(" · "));
-}
+
+//const text = require("resource://grammalecte/text.js");
+//const tf = require("resource://grammalecte/fr/textformatter.js");
const oConverterToExponent = {
dNumbers: new Map ([
["1", "¹"], ["2", "²"], ["3", "³"], ["4", "⁴"], ["5", "⁵"],
@@ -45,79 +36,79 @@
xGCEWorker: null,
bDictActive: null,
loadGC: function () {
if (this.xGCEWorker === null) {
// Grammar checker
- echo('Loading Grammalecte');
+ console.log('Loading Grammalecte');
this.xGCEWorker = new BasePromiseWorker('chrome://promiseworker/content/gce_worker.js');
let xPromise = this.xGCEWorker.post('loadGrammarChecker', [prefs.getCharPref("sGCOptions"), "Thunderbird"]);
xPromise.then(
function (aVal) {
- echo(aVal);
+ console.log(aVal);
prefs.setCharPref("sGCOptions", aVal);
},
- function (aReason) { echo('Promise rejected - ', aReason); }
+ function (aReason) { console.log('Promise rejected - ', aReason); }
).catch(
- function (aCaught) { echo('Promise Error - ', aCaught); }
+ function (aCaught) { console.log('Promise Error - ', aCaught); }
);
}
},
fullTests: function () {
- echo('Performing tests... Wait...');
+ console.log('Performing tests... Wait...');
let xPromise = this.xGCEWorker.post('fullTests', ['{"nbsp":true, "esp":true, "unit":true, "num":true}']);
xPromise.then(
function (aVal) {
- echo('Done.');
- echo(aVal);
+ console.log('Done.');
+ console.log(aVal);
},
- function (aReason) { echo('Promise rejected', aReason); }
+ function (aReason) { console.log('Promise rejected', aReason); }
).catch(
- function (aCaught) { echo('Promise Error', aCaught); }
+ function (aCaught) { console.log('Promise Error', aCaught); }
);
},
test: function (sText) {
- echo("Test...");
+ console.log("Test...");
let xPromise = this.xGCEWorker.post('parse', [sText, "FR", true]);
xPromise.then(
function (aVal) {
let lErr = JSON.parse(aVal);
if (lErr.length > 0) {
for (let dErr of lErr) {
- echo(text.getReadableError(dErr));
+ console.log(text.getReadableError(dErr));
}
} else {
- echo("no error found");
+ console.log("no error found");
}
},
- function (aReason) { echo('Promise rejected', aReason); }
+ function (aReason) { console.log('Promise rejected', aReason); }
).catch(
- function (aCaught) { echo('Promise Error', aCaught); }
+ function (aCaught) { console.log('Promise Error', aCaught); }
);
},
setOptions: function () {
- echo('Set options');
+ console.log('Set options');
let xPromise = this.xGCEWorker.post('setOptions', [prefs.getCharPref("sGCOptions")]);
xPromise.then(
function (aVal) {
- echo(aVal);
+ console.log(aVal);
prefs.setCharPref("sGCOptions", aVal);
},
- function (aReason) { echo('Promise rejected', aReason); }
+ function (aReason) { console.log('Promise rejected', aReason); }
).catch(
- function (aCaught) { echo('Promise Error', aCaught); }
+ function (aCaught) { console.log('Promise Error', aCaught); }
);
},
resetOptions: function () {
let xPromise = this.xGCEWorker.post('resetOptions');
xPromise.then(
function (aVal) {
- echo(aVal);
+ console.log(aVal);
prefs.setCharPref("sGCOptions", aVal);
},
- function (aReason) { echo('Promise rejected', aReason); }
+ function (aReason) { console.log('Promise rejected', aReason); }
).catch(
- function (aCaught) { echo('Promise Error', aCaught); }
+ function (aCaught) { console.log('Promise Error', aCaught); }
);
},
_getGCResultPromise: function (sParagraph, sLang, bDebug, bContext) {
// For some reason, you can’t use result of PromiseWorker within a Task,
// you have to wrap it in a common Promise. Task and yield can be replaced with async / await when it is available.
@@ -186,11 +177,11 @@
let xResultNode = document.getElementById("resnode"+iParagraph);
xResultNode.textContent = "…………… réanalyse en cours ……………";
let sParagraph = xEditor.getParagraph(iParagraph);
let xPromise = this._getGCResultPromise(sParagraph, "FR", false, false);
xPromise.then(function (res) {
- //echo("res: " + res);
+ //console.log("res: " + res);
xResultNode.textContent = "";
let oRes = JSON.parse(res);
if (oRes.aGrammErr.length > 0 || oRes.aSpellErr.length > 0) {
that.fillResultNode(xResultNode, xEditor, sParagraph, iParagraph, oRes.aGrammErr, oRes.aSpellErr);
}
@@ -369,11 +360,11 @@
xNodeSuggLine.appendChild(xNodeSuggButton);
xNodeDiv.appendChild(xNodeSuggLine);
return xNodeDiv;
},
loadUI: function() {
- echo("loadUI");
+ console.log("loadUI");
this._strings = document.getElementById("grammarchecker-strings");
let that = this;
let nsGrammarCommand = {
isCommandEnabled: function (aCommand, dummy) {
return (IsDocumentEditable() && !IsInHTMLSourceMode());
@@ -472,24 +463,24 @@
onOpenGCOptions: function (e) {
let that = this;
let xPromise = this.xGCEWorker.post('getDefaultOptions');
xPromise.then(
function (aVal) {
- echo(aVal);
+ console.log(aVal);
prefs.setCharPref("sGCDefaultOptions", aVal);
},
- function (aReason) { echo('Promise rejected', aReason); }
+ function (aReason) { console.log('Promise rejected', aReason); }
).catch(
- function (aCaught) { echo('Promise Error', aCaught); }
+ function (aCaught) { console.log('Promise Error', aCaught); }
).then(
function () {
that.openDialog("chrome://grammarchecker/content/gc_options.xul", "", "chrome, dialog, modal, resizable=no");
that.setOptions();
},
- function (aReason) { echo('Error options dialog', aReason); }
+ function (aReason) { console.log('Error options dialog', aReason); }
).catch(
- function (aCaught) { echo('Error', aCaught); }
+ function (aCaught) { console.log('Error', aCaught); }
);
},
onOpenSpellOptions: function (e) {
this.openDialog("chrome://grammarchecker/content/spell_options.xul", "", "chrome, dialog, modal, resizable=no");
},
@@ -566,11 +557,11 @@
saveOptions: function () {
let oOptions = {};
for (let xNode of document.getElementsByClassName("option")) {
oOptions[xNode.id] = xNode.checked;
}
- //echo("save options: " + JSON.stringify(oOptions));
+ //console.log("save options: " + JSON.stringify(oOptions));
prefs.setCharPref("sTFOptions", JSON.stringify(oOptions));
},
setOptionsInPanel: function (oOptions) {
for (let sOptName in oOptions) {
//console.log(sOptName + ":" + oOptions[sOptName]);
@@ -880,15 +871,15 @@
return sText;
},
formatText: function (sText, sOptName) {
let nCount = 0;
try {
- if (!tf.oReplTable.hasOwnProperty(sOptName)) {
- echo("# Error. TF: there is no option “" + sOptName+ "”.");
+ if (!oReplTable.hasOwnProperty(sOptName)) {
+ console.log("# Error. TF: there is no option “" + sOptName+ "”.");
return [sText, nCount];
}
- for (let [zRgx, sRep] of tf.oReplTable[sOptName]) {
+ for (let [zRgx, sRep] of oReplTable[sOptName]) {
nCount += (sText.match(zRgx) || []).length;
sText = sText.replace(zRgx, sRep);
}
}
catch (e) {
Index: gc_lang/fr/tb/content/overlay.xul
==================================================================
--- gc_lang/fr/tb/content/overlay.xul
+++ gc_lang/fr/tb/content/overlay.xul
@@ -5,10 +5,12 @@
+
+
Index: gc_lang/fr/tb/content/spell_options.js
==================================================================
--- gc_lang/fr/tb/content/spell_options.js
+++ gc_lang/fr/tb/content/spell_options.js
@@ -5,16 +5,10 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker.");
-const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
-
-
-function echo (...args) {
- Services.console.logStringMessage(args.join(" -- ") + "\n");
-}
var oDialogControl = {
load: function () {
try {
Index: gc_lang/fr/tb/content/spellchecker.js
==================================================================
--- gc_lang/fr/tb/content/spellchecker.js
+++ gc_lang/fr/tb/content/spellchecker.js
@@ -30,11 +30,11 @@
/*
const parser = Cc["@mozilla.org/parserutils;1"].getService(Ci.nsIParserUtils);
const persodict = Cc["@mozilla.org/spellchecker/personaldictionary;1"].getService(Ci.mozIPersonalDictionary);
*/
-const system = require("sdk/system");
+//const system = require("sdk/system");
var oSpellControl = {
xSCEngine: null,
init: function () {
@@ -131,16 +131,17 @@
try {
let that = this;
let sPath = "/content/dictionaries/" + sDictName;
AddonManager.getAddonByID("French-GC-TB@grammalecte.net", function (addon) {
let xURI = addon.getResourceURI(sPath);
- //console.log("> " + xURI.path);
+ console.log("> " + xURI.path);
let sFolder = xURI.path;
- if (system.platform === "winnt") {
+ //if (system.platform === "winnt") {
+ if (sFolder) {
sFolder = sFolder.slice(1).replace(/\//g, "\\\\");
}
- //console.log("> " + sFolder);
+ console.log("> " + sFolder);
if (bActivate) {
that.addDirectory(sFolder);
} else {
that.removeDirectory(sFolder);
}