Changes In Branch webext2 Through [455f677793] Excluding Merge-Ins
This is equivalent to a diff from 6af1e457f4 to 455f677793
|
2017-08-01
| ||
| 09:50 | [core][py] variable renaming check-in: 1b98af1338 user: olr tags: trunk, core | |
|
2017-07-31
| ||
| 16:35 | [core][js] mfsp as object check-in: 47815bc2dc user: olr tags: core, webext2 | |
| 15:56 | [core][js] phonet as object check-in: 455f677793 user: olr tags: core, webext2 | |
| 15:42 | [core][js] str_transform as object check-in: 917994adcd user: olr tags: core, webext2 | |
| 15:31 | [core][js] helpers as object check-in: 1140b979f8 user: olr tags: core, webext2 | |
| 07:52 | [core][js] text: remove useless functions check-in: 6af1e457f4 user: olr tags: trunk, core | |
| 07:44 | [core][js][fr] JavaScript sucks: avoid weird and unpredictable behavior, infinite loop and similar crazyness -> stable number of groups in regex check-in: 20ec5b88a4 user: olr tags: trunk, core, warning | |
Modified gc_core/js/helpers.js from [da0905c944] to [c3386dc3e8].
1 2 3 4 5 6 7 | // HELPERS "use strict"; // In Firefox, there is no console.log in PromiseWorker, but there is worker.log. // In Thunderbird, you can’t access to console directly. So it’s required to pass a log function. | | > | > | | > > > | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | > > | | | | | | | | 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 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 |
// HELPERS
"use strict";
// In Firefox, there is no console.log in PromiseWorker, but there is worker.log.
// In Thunderbird, you can’t access to console directly. So it’s required to pass a log function.
var funcOutput = null;
var helpers = {
setLogOutput: function (func) {
try {
funcOutput = func;
}
catch (e) {
func(e);
console.error(e);
}
},
echo: function (obj) {
if (funcOutput !== null) {
funcOutput(obj);
} else {
console.log(obj);
}
return true;
},
logerror: function (e, bStack=false) {
let sMsg = "\n" + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message;
if (bStack) {
sMsg += "\n--- Stack ---\n" + e.stack;
}
if (funcOutput !== null) {
funcOutput(sMsg);
} else {
console.error(sMsg);
}
},
inspect: function (o) {
let sMsg = "__inspect__: " + typeof o;
for (let sParam in o) {
sMsg += "\n" + sParam + ": " + o.sParam;
}
sMsg += "\n" + JSON.stringify(o) + "\n__end__";
this.echo(sMsg);
},
loadFile: function (spf) {
// load ressources in workers (suggested by Mozilla extensions reviewers)
// for more options have a look here: https://gist.github.com/Noitidart/ec1e6b9a593ec7e3efed
// if not in workers, use sdk/data.load() instead
try {
let xRequest;
if (typeof XMLHttpRequest !== "undefined") {
xRequest = new XMLHttpRequest();
}
else {
// JS bullshit again… necessary for Thunderbird
let { Cc, Ci } = require("chrome");
xRequest = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
xRequest.QueryInterface(Ci.nsIXMLHttpRequest);
}
xRequest.open('GET', spf, false); // 3rd arg is false for synchronous, sync is acceptable in workers
xRequest.send();
return xRequest.responseText;
}
catch (e) {
this.logerror(e);
return null
}
},
// conversions
objectToMap: function (obj) {
let m = new Map();
for (let param in obj) {
//console.log(param + " " + obj[param]);
m.set(param, obj[param]);
}
return m;
},
mapToObject: function (m) {
let obj = {};
for (let [k, v] of m) {
obj[k] = v;
}
return obj;
}
}
if (typeof(exports) !== 'undefined') {
exports.setLogOutput = helpers.setLogOutput;
exports.echo = helpers.echo;
exports.logerror = helpers.logerror;
exports.inspect = helpers.inspect;
exports.loadFile = helpers.loadFile;
exports.objectToMap = helpers.objectToMap;
exports.mapToObject = helpers.mapToObject;
}
|
Modified gc_core/js/str_transform.js from [0fafeda9a5] to [9b41fc7a14].
1 2 | //// STRING TRANSFORMATION | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > | < | | | | | | > | < | | | | | | | | | > | | | 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 |
//// STRING TRANSFORMATION
// Note: 48 is the ASCII code for "0"
var str_transform = {
getStemFromSuffixCode: function (sFlex, sSfxCode) {
// Suffix only
if (sSfxCode == "0") {
return sFlex;
}
return sSfxCode[0] == '0' ? sFlex + sSfxCode.slice(1) : sFlex.slice(0, -(sSfxCode.charCodeAt(0)-48)) + sSfxCode.slice(1);
},
getStemFromAffixCode: function (sFlex, sAffCode) {
// Prefix and suffix
if (sAffCode == "0") {
return sFlex;
}
if (!sAffCode.includes("/")) {
return "# error #";
}
let [sPfxCode, sSfxCode] = sAffCode.split('/');
sFlex = sPfxCode.slice(1) + sFlex.slice(sPfxCode.charCodeAt(0)-48);
return sSfxCode[0] == '0' ? sFlex + sSfxCode.slice(1) : sFlex.slice(0, -(sSfxCode.charCodeAt(0)-48)) + sSfxCode.slice(1);
}
}
if (typeof(exports) !== 'undefined') {
exports.getStemFromSuffixCode = str_transform.getStemFromSuffixCode;
exports.getStemFromAffixCode = str_transform.getStemFromAffixCode;
}
|
Modified gc_core/js/text.js from [beffb97d58] to [b502e53f4f].
1 2 3 4 5 6 |
// JavaScript
"use strict";
const helpers = require("resource://grammalecte/helpers.js");
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
// JavaScript
"use strict";
const helpers = require("resource://grammalecte/helpers.js");
var text = {
getParagraph: function* (sText) {
// generator: returns paragraphs of text
let iStart = 0;
let iEnd = 0;
sText = sText.replace("\r", "");
while ((iEnd = sText.indexOf("\n", iStart)) !== -1) {
yield sText.slice(iStart, iEnd);
iStart = iEnd + 1;
}
yield sText.slice(iStart);
},
wrap: function* (sText, nWidth=80) {
// generator: returns text line by line
while (sText) {
if (sText.length >= nWidth) {
let nEnd = sText.lastIndexOf(" ", nWidth) + 1;
if (nEnd > 0) {
yield sText.slice(0, nEnd);
sText = sText.slice(nEnd);
} else {
yield sText.slice(0, nWidth);
sText = sText.slice(nWidth);
}
} else {
break;
}
}
yield sText;
},
getReadableError: function (oErr) {
// Returns an error oErr as a readable error
try {
let sResult = "\n* " + oErr['nStart'] + ":" + oErr['nEnd']
+ " # " + oErr['sLineId'] + " # " + oErr['sRuleId'] + ":\n";
sResult += " " + oErr["sMessage"];
if (oErr["aSuggestions"].length > 0) {
sResult += "\n > Suggestions : " + oErr["aSuggestions"].join(" | ");
}
if (oErr["URL"] !== "") {
sResult += "\n > URL: " + oErr["URL"];
}
return sResult;
}
catch (e) {
helpers.logerror(e);
return "\n# Error. Data: " + oErr.toString();
}
}
}
if (typeof(exports) !== 'undefined') {
exports.getParagraph = text.getParagraph;
exports.wrap = text.wrap;
exports.getReadableError = text.getReadableError;
}
|
Modified gc_lang/fr/modules-js/phonet.js from [1d899a6d9f] to [17494340df].
1 2 3 |
// Grammalecte - Suggestion phonétique
const helpers = require("resource://grammalecte/helpers.js");
| < | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | 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 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 |
// Grammalecte - Suggestion phonétique
const helpers = require("resource://grammalecte/helpers.js");
const _oData = JSON.parse(helpers.loadFile("resource://grammalecte/fr/phonet_data.json"));
const _dWord = helpers.objectToMap(_oData.dWord);
const _lSet = _oData.lSet;
const _dMorph = helpers.objectToMap(_oData.dMorph);
var phonet = {
hasSimil: function (sWord, sPattern=null) {
// return True if there is list of words phonetically similar to sWord
if (!sWord) {
return false;
}
if (_dWord.has(sWord)) {
if (sPattern) {
return this.getSimil(sWord).some(sSimil => _dMorph.gl_get(sSimil, []).some(sMorph => sMorph.search(sPattern) >= 0));
}
return true;
}
if (sWord.slice(0,1).gl_isUpperCase()) {
sWord = sWord.toLowerCase();
if (_dWord.has(sWord)) {
if (sPattern) {
return this.getSimil(sWord).some(sSimil => _dMorph.gl_get(sSimil, []).some(sMorph => sMorph.search(sPattern) >= 0));
}
return true;
}
}
return false;
},
getSimil: function (sWord) {
// return list of words phonetically similar to sWord
if (!sWord) {
return [];
}
if (_dWord.has(sWord)) {
return _lSet[_dWord.get(sWord)];
}
if (sWord.slice(0,1).gl_isUpperCase()) {
sWord = sWord.toLowerCase();
if (_dWord.has(sWord)) {
return _lSet[_dWord.get(sWord)];
}
}
return [];
},
selectSimil: function (sWord, sPattern) {
// return list of words phonetically similar to sWord and whom POS is matching sPattern
if (!sPattern) {
return new Set(this.getSimil(sWord));
}
let aSelect = new Set();
for (let sSimil of this.getSimil(sWord)) {
for (let sMorph of _dMorph.gl_get(sSimil, [])) {
if (sMorph.search(sPattern) >= 0) {
aSelect.add(sSimil);
}
}
}
return aSelect;
}
}
if (typeof(exports) !== 'undefined') {
exports.hasSimil = phonet.hasSimil;
exports.getSimil = phonet.getSimil;
exports.selectSimil = phonet.selectSimil;
}
|
Modified gc_lang/fr/tb/content/overlay.js from [31d038a91d] to [a6d0f601cc].
| ︙ | ︙ | |||
908 909 910 911 912 913 914 915 916 917 918 919 920 921 |
oTextFormatter.resetProgressBar();
}
}, false);
window.addEventListener("load", function (xEvent) {
oDictIgniter.init();
oGrammarChecker.loadGC();
}, false);
window.addEventListener("compose-window-init", function (xEvent) {
oGrammarChecker.loadUI();
oGrammarChecker.closePanel();
oGrammarChecker.clearPreview();
oTextFormatter.init();
| > | 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 |
oTextFormatter.resetProgressBar();
}
}, false);
window.addEventListener("load", function (xEvent) {
oDictIgniter.init();
oGrammarChecker.loadGC();
//oGrammarChecker.fullTests();
}, false);
window.addEventListener("compose-window-init", function (xEvent) {
oGrammarChecker.loadUI();
oGrammarChecker.closePanel();
oGrammarChecker.clearPreview();
oTextFormatter.init();
|
| ︙ | ︙ |