Overview
| Comment: | [tb] fix modules importation, remove old logging system… |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | tb | tbnext |
| Files: | files | file ages | folders |
| SHA3-256: |
a90720e17ca5e477d4a305904e248b36 |
| User & Date: | olr on 2018-03-10 14:58:14 |
| Other Links: | branch diff | manifest | tags |
Context
|
2018-03-10
| ||
| 15:18 | [tb] fix conjugueur initialization… (again, and again, and again, and again, thanks to the endless JS pile of shit) check-in: 8253dcac97 user: olr tags: tb, tbnext | |
| 14:58 | [tb] fix modules importation, remove old logging system… check-in: a90720e17c user: olr tags: tb, tbnext | |
|
2018-03-09
| ||
| 09:32 | [tb] build for Thunderbird Beta check-in: 09c165319c user: olr tags: tb, tbnext | |
Changes
Modified gc_lang/fr/tb/content/about.js from [2bc9ad5ee7] to [c5c1006b2d].
1 2 3 4 5 | // JavaScript const Cc = Components.classes; const Ci = Components.interfaces; const Cu = Components.utils; | < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 |
// JavaScript
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
function openInBrowserURL (sURL) {
// method found in S3.Google.Translator
try {
openURL(sURL);
// Works in overlay.js, but not here… Seems there is no documentation available about this feature on Mozilla.org
|
| ︙ | ︙ |
Modified gc_lang/fr/tb/content/conjugueur.js from [52fcb1616a] to [91bf4af012].
1 2 3 | // JavaScript const Cu = Components.utils; | | | < < < < < | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
// JavaScript
const Cu = Components.utils;
//const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
//const conj = require("resource://grammalecte/fr/conj.js");
let oConj = {
init: function () {
console.log("Init conjugueur");
try {
// button
document.getElementById('conjugate').addEventListener("click", (xEvent) => {
this.getVerbAndConjugate();
});
// text field
document.getElementById('verb').addEventListener("change", (xEvent) => {
this.getVerbAndConjugate();
});
// options
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);
}
this.conjugate("être");
},
|
| ︙ | ︙ |
Modified gc_lang/fr/tb/content/conjugueur.xul from [429a95586f] to [cd97a646e7].
| ︙ | ︙ | |||
150 151 152 153 154 155 156 157 158 |
<label id="condb4" class="cj">.</label>
<label id="condb5" class="cj">.</label>
<label id="condb6" class="cj">.</label>
</groupbox>
</column>
</columns>
<script type="application/javascript" src="conjugueur.js"/>
</dialog>
| > | 150 151 152 153 154 155 156 157 158 159 |
<label id="condb4" class="cj">.</label>
<label id="condb5" class="cj">.</label>
<label id="condb6" class="cj">.</label>
</groupbox>
</column>
</columns>
<script type="application/javascript" src="resource://grammalecte/fr/conj.js"/>
<script type="application/javascript" src="conjugueur.js"/>
</dialog>
|
Modified gc_lang/fr/tb/content/editor.js from [71421bf6bc] to [8eea7833f2].
| ︙ | ︙ | |||
17 18 19 20 21 22 23 |
}
};
* _getParsableNodes (xRootNode=this.xEditor.rootElement) {
// recursive function
try {
for (let xNode of xRootNode.childNodes) {
| < < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
}
};
* _getParsableNodes (xRootNode=this.xEditor.rootElement) {
// recursive function
try {
for (let xNode of xRootNode.childNodes) {
if (xNode.className !== "moz-cite-prefix" && xNode.tagName !== "BLOCKQUOTE"
&& (xNode.nodeType == Node.TEXT_NODE || (xNode.nodeType == Node.ELEMENT_NODE && !xNode.textContent.startsWith(">")))
&& xNode.textContent !== "") {
if (xNode.tagName === undefined) {
if (!prefs.getBoolPref("bCheckSignature") && xNode.textContent.startsWith("-- ")) {
break;
}
yield xNode;
} else if (this.lParsableNodes.includes(xNode.tagName)) {
yield xNode;
|
| ︙ | ︙ |
Modified gc_lang/fr/tb/content/gc_options.js from [f85fde1089] to [aee78a8d90].
1 2 3 4 5 6 |
// JavaScript
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.");
| < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
// JavaScript
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.");
var oOptControl = {
oOptions: null,
load: function () {
this._setDialogOptions(false);
},
_setDialogOptions: function (bDefaultOptions=false) {
try {
sOptions = bDefaultOptions ? prefs.getCharPref("sGCDefaultOptions") : prefs.getCharPref("sGCOptions");
this.oOptions = JSON.parse(sOptions);
for (let sParam in this.oOptions) {
if (document.getElementById("option_"+sParam) !== null) {
document.getElementById("option_"+sParam).checked = this.oOptions[sParam];
}
}
}
catch (e) {
Cu.reportError(e);
}
},
save: function () {
try {
for (let xNode of document.getElementsByClassName("option")) {
this.oOptions[xNode.id.slice(7)] = xNode.checked;
}
prefs.setCharPref("sGCOptions", JSON.stringify(this.oOptions));
}
catch (e) {
Cu.reportError(e);
}
},
reset: function () {
this._setDialogOptions(true);
}
}
oOptControl.load();
|
Modified gc_lang/fr/tb/content/overlay.js from [0f3db968a0] to [fcc7e4e2d6].
1 2 3 4 5 6 7 8 | // JavaScript "use strict"; const Cc = Components.classes; const Ci = Components.interfaces; const Cu = Components.utils; | | < < < | | < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
// JavaScript
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
//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.");
//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", "⁵"],
["6", "⁶"], ["7", "⁷"], ["8", "⁸"], ["9", "⁹"], ["0", "⁰"]
]),
|
| ︙ | ︙ | |||
43 44 45 46 47 48 49 |
var oGrammarChecker = {
// you must use var to be able to call this object from elsewhere
xGCEWorker: null,
bDictActive: null,
loadGC: function () {
if (this.xGCEWorker === null) {
// Grammar checker
| | | | | | | | | | | | | | | | | | | | | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
var oGrammarChecker = {
// you must use var to be able to call this object from elsewhere
xGCEWorker: null,
bDictActive: null,
loadGC: function () {
if (this.xGCEWorker === null) {
// Grammar checker
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) {
console.log(aVal);
prefs.setCharPref("sGCOptions", aVal);
},
function (aReason) { console.log('Promise rejected - ', aReason); }
).catch(
function (aCaught) { console.log('Promise Error - ', aCaught); }
);
}
},
fullTests: function () {
console.log('Performing tests... Wait...');
let xPromise = this.xGCEWorker.post('fullTests', ['{"nbsp":true, "esp":true, "unit":true, "num":true}']);
xPromise.then(
function (aVal) {
console.log('Done.');
console.log(aVal);
},
function (aReason) { console.log('Promise rejected', aReason); }
).catch(
function (aCaught) { console.log('Promise Error', aCaught); }
);
},
test: function (sText) {
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) {
console.log(text.getReadableError(dErr));
}
} else {
console.log("no error found");
}
},
function (aReason) { console.log('Promise rejected', aReason); }
).catch(
function (aCaught) { console.log('Promise Error', aCaught); }
);
},
setOptions: function () {
console.log('Set options');
let xPromise = this.xGCEWorker.post('setOptions', [prefs.getCharPref("sGCOptions")]);
xPromise.then(
function (aVal) {
console.log(aVal);
prefs.setCharPref("sGCOptions", aVal);
},
function (aReason) { console.log('Promise rejected', aReason); }
).catch(
function (aCaught) { console.log('Promise Error', aCaught); }
);
},
resetOptions: function () {
let xPromise = this.xGCEWorker.post('resetOptions');
xPromise.then(
function (aVal) {
console.log(aVal);
prefs.setCharPref("sGCOptions", aVal);
},
function (aReason) { console.log('Promise rejected', aReason); }
).catch(
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.
let that = this;
return new Promise(function (resolve, reject) {
|
| ︙ | ︙ | |||
184 185 186 187 188 189 190 |
try {
let that = this;
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) {
| | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
try {
let that = this;
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) {
//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);
}
}, function (res) {
xResultNode.textContent = "Erreur: " + res;
|
| ︙ | ︙ | |||
367 368 369 370 371 372 373 |
}
});
xNodeSuggLine.appendChild(xNodeSuggButton);
xNodeDiv.appendChild(xNodeSuggLine);
return xNodeDiv;
},
loadUI: function() {
| | | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
}
});
xNodeSuggLine.appendChild(xNodeSuggButton);
xNodeDiv.appendChild(xNodeSuggLine);
return xNodeDiv;
},
loadUI: function() {
console.log("loadUI");
this._strings = document.getElementById("grammarchecker-strings");
let that = this;
let nsGrammarCommand = {
isCommandEnabled: function (aCommand, dummy) {
return (IsDocumentEditable() && !IsInHTMLSourceMode());
},
getCommandStateParams: function (aCommand, aParams, aRefCon) {},
|
| ︙ | ︙ | |||
470 471 472 473 474 475 476 |
this.closePanel();
},
onOpenGCOptions: function (e) {
let that = this;
let xPromise = this.xGCEWorker.post('getDefaultOptions');
xPromise.then(
function (aVal) {
| | | | | | | 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
this.closePanel();
},
onOpenGCOptions: function (e) {
let that = this;
let xPromise = this.xGCEWorker.post('getDefaultOptions');
xPromise.then(
function (aVal) {
console.log(aVal);
prefs.setCharPref("sGCDefaultOptions", aVal);
},
function (aReason) { console.log('Promise rejected', aReason); }
).catch(
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) { console.log('Error options dialog', aReason); }
).catch(
function (aCaught) { console.log('Error', aCaught); }
);
},
onOpenSpellOptions: function (e) {
this.openDialog("chrome://grammarchecker/content/spell_options.xul", "", "chrome, dialog, modal, resizable=no");
},
onOpenOptions: function (e) {
this.openDialog("chrome://grammarchecker/content/options.xul", "", "chrome, dialog, modal, resizable=no");
|
| ︙ | ︙ | |||
564 565 566 567 568 569 570 |
}
},
saveOptions: function () {
let oOptions = {};
for (let xNode of document.getElementsByClassName("option")) {
oOptions[xNode.id] = xNode.checked;
}
| | | 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
}
},
saveOptions: function () {
let oOptions = {};
for (let xNode of document.getElementsByClassName("option")) {
oOptions[xNode.id] = xNode.checked;
}
//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]);
if (document.getElementById(sOptName) !== null) {
document.getElementById(sOptName).checked = oOptions[sOptName];
|
| ︙ | ︙ | |||
878 879 880 881 882 883 884 |
Cu.reportError(e);
}
return sText;
},
formatText: function (sText, sOptName) {
let nCount = 0;
try {
| | | | | 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 |
Cu.reportError(e);
}
return sText;
},
formatText: function (sText, sOptName) {
let nCount = 0;
try {
if (!oReplTable.hasOwnProperty(sOptName)) {
console.log("# Error. TF: there is no option “" + sOptName+ "”.");
return [sText, nCount];
}
for (let [zRgx, sRep] of oReplTable[sOptName]) {
nCount += (sText.match(zRgx) || []).length;
sText = sText.replace(zRgx, sRep);
}
}
catch (e) {
Cu.reportError(e);
}
|
| ︙ | ︙ |
Modified gc_lang/fr/tb/content/overlay.xul from [a19f1698d8] to [32fb17e890].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://grammarchecker/content/overlay.css" type="text/css"?>
<!DOCTYPE overlay SYSTEM "chrome://grammarchecker/locale/overlay.dtd">
<overlay id="grammarchecker-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="overlay.js"/>
<script type="application/javascript" src="spellchecker.js"/>
<script type="application/javascript" src="editor.js"/>
<stringbundleset id="stringbundleset">
<stringbundle id="grammarchecker-strings" src="chrome://grammarchecker/locale/grammarchecker.properties"/>
</stringbundleset>
| > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://grammarchecker/content/overlay.css" type="text/css"?>
<!DOCTYPE overlay SYSTEM "chrome://grammarchecker/locale/overlay.dtd">
<overlay id="grammarchecker-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="resource://grammalecte/text.js"/>
<script type="application/javascript" src="resource://grammalecte/fr/textformatter.js"/>
<script type="application/javascript" src="overlay.js"/>
<script type="application/javascript" src="spellchecker.js"/>
<script type="application/javascript" src="editor.js"/>
<stringbundleset id="stringbundleset">
<stringbundle id="grammarchecker-strings" src="chrome://grammarchecker/locale/grammarchecker.properties"/>
</stringbundleset>
|
| ︙ | ︙ |
Modified gc_lang/fr/tb/content/spell_options.js from [9ebffece09] to [4444b40148].
1 2 3 4 5 6 7 8 9 |
// JavaScript
"use strict";
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.");
| < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// JavaScript
"use strict";
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.");
var oDialogControl = {
load: function () {
try {
document.getElementById('fr-FR-modern').checked = prefs.getBoolPref('bDictModern');
document.getElementById('fr-FR-classic').checked = prefs.getBoolPref('bDictClassic');
|
| ︙ | ︙ |
Modified gc_lang/fr/tb/content/spellchecker.js from [3be1484aff] to [225bd1d02e].
| ︙ | ︙ | |||
28 29 30 31 32 33 34 |
const AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm").AddonManager;
/*
const parser = Cc["@mozilla.org/parserutils;1"].getService(Ci.nsIParserUtils);
const persodict = Cc["@mozilla.org/spellchecker/personaldictionary;1"].getService(Ci.mozIPersonalDictionary);
*/
| | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
const AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm").AddonManager;
/*
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");
var oSpellControl = {
xSCEngine: null,
init: function () {
if (this.xSCEngine === null) {
try {
|
| ︙ | ︙ | |||
129 130 131 132 133 134 135 |
},
setExtensionDictFolder: function (sDictName, bActivate) {
try {
let that = this;
let sPath = "/content/dictionaries/" + sDictName;
AddonManager.getAddonByID("French-GC-TB@grammalecte.net", function (addon) {
let xURI = addon.getResourceURI(sPath);
| | | > | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
},
setExtensionDictFolder: function (sDictName, bActivate) {
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);
let sFolder = xURI.path;
//if (system.platform === "winnt") {
if (sFolder) {
sFolder = sFolder.slice(1).replace(/\//g, "\\\\");
}
console.log("> " + sFolder);
if (bActivate) {
that.addDirectory(sFolder);
} else {
that.removeDirectory(sFolder);
}
});
}
catch (e) {
echo("Unable to add extension folder");
Cu.reportError(e);
}
}
};
|