| Comment: | [fx][cli][build] thesaurus for webextension and CLI |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | trunk | fr | cli | build | fx |
| Files: | files | file ages | folders |
| SHA3-256: |
091890c8f550fcf59ef5c7d32787d53e |
| User & Date: | olr on 2025-11-20 15:33:50 |
| Other Links: | manifest | tags |
|
2025-11-20
| ||
| 15:33 | [fx][cli][build] thesaurus for webextension and CLI Leaf check-in: 091890c8f5 user: olr tags: trunk, fr, cli, build, fx | |
|
2025-10-01
| ||
| 09:39 | [fx] remove search engine in lost database check-in: d1a9f923b8 user: olr tags: trunk, fx | |
Modified gc_lang/fr/build_data.py from [a2cd8b7cce] to [538b8f5fd2].
| ︙ | ︙ | |||
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
def makeDictionaries (sp, sVersion):
with cd(sp+"/dictionnaire"):
if platform.system() == "Windows":
os.system("python genfrdic.py -s -gl -v "+sVersion)
else:
os.system("python3 ./genfrdic.py -s -gl -v "+sVersion)
def makeConj (sp, bJS=False):
print("> Conjugaisons ", end="")
print("(Python et JavaScript)" if bJS else "(Python seulement)")
dVerb = {}
lVinfo = []; dVinfo = {}; nVinfo = 0
lTags = []; dTags = {}; nTags = 0
| > > > > > > > > > > > > > | 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 |
def makeDictionaries (sp, sVersion):
with cd(sp+"/dictionnaire"):
if platform.system() == "Windows":
os.system("python genfrdic.py -s -gl -v "+sVersion)
else:
os.system("python3 ./genfrdic.py -s -gl -v "+sVersion)
def makeThesaurusFiles (sp):
dThesaurus = {}
sContent = open(sp+'/data/thes_fr.json', "r", encoding="utf-8").read()
dThesaurus = json.loads(sContent)
## write file for Python
sCode = "# generated data (do not edit)\n\n" + \
"dThesaurus = " + str(dThesaurus) + "\n"
open(sp+"/modules/thesaurus_data.py", "w", encoding="utf-8", newline="\n").write(sCode)
if bJS:
## write file for JavaScript
file_util.copy_file(sp+'/data/thes_fr.json', sp+"/modules-js/thesaurus_data.json")
def makeConj (sp, bJS=False):
print("> Conjugaisons ", end="")
print("(Python et JavaScript)" if bJS else "(Python seulement)")
dVerb = {}
lVinfo = []; dVinfo = {}; nVinfo = 0
lTags = []; dTags = {}; nTags = 0
|
| ︙ | ︙ |
Modified gc_lang/fr/dictionnaire/genfrdic.py from [2c15ac24c5] to [23c6a753b0].
| ︙ | ︙ | |||
566 567 568 569 570 571 572 |
file_util.copy_file('césures/hyph_fr.dic', spExt+'/dictionaries')
file_util.copy_file('césures/hyph_fr.iso8859-1.dic', spExt+'/dictionaries')
file_util.copy_file('césures/frhyph.tex', spExt+'/dictionaries')
file_util.copy_file('césures/hyph-fr.tex', spExt+'/dictionaries')
file_util.copy_file('césures/README_hyph_fr-3.0.txt', spExt+'/dictionaries')
file_util.copy_file('césures/README_hyph_fr-2.9.txt', spExt+'/dictionaries')
# thesaurus
| | > > | 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
file_util.copy_file('césures/hyph_fr.dic', spExt+'/dictionaries')
file_util.copy_file('césures/hyph_fr.iso8859-1.dic', spExt+'/dictionaries')
file_util.copy_file('césures/frhyph.tex', spExt+'/dictionaries')
file_util.copy_file('césures/hyph-fr.tex', spExt+'/dictionaries')
file_util.copy_file('césures/README_hyph_fr-3.0.txt', spExt+'/dictionaries')
file_util.copy_file('césures/README_hyph_fr-2.9.txt', spExt+'/dictionaries')
# thesaurus
file_util.copy_file(spBuild+"/thesaurus-v"+sThesVer+'/thes_fr.dat', spExt+"/dictionaries")
file_util.copy_file(spBuild+"/thesaurus-v"+sThesVer+'/thes_fr.idx', spExt+"/dictionaries")
file_util.copy_file(spBuild+"/thesaurus-v"+sThesVer+'/README_thes_fr.txt', spExt+"/dictionaries")
# zip
createZipFiles(spExt, spBuild, sExtensionName + '.oxt')
# copy to Grammalecte Project
if spDestGL:
echo(" Dictionnaires Hunspell copiés dans Grammalecte pour LibreOffice...")
dir_util.copy_tree(spExt+'/dictionaries', spDestGL)
|
| ︙ | ︙ | |||
1404 1405 1406 1407 1408 1409 1410 |
with open(sPathFile, 'w', encoding='utf-8', newline="\n") as hDst:
for t in self.lLex:
hDst.write(str(t)+"\n")
for e in self.dFlexions.items():
hDst.write("{} - {}\n".format(e[0], e[1]))
| | > > > | 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 |
with open(sPathFile, 'w', encoding='utf-8', newline="\n") as hDst:
for t in self.lLex:
hDst.write(str(t)+"\n")
for e in self.dFlexions.items():
hDst.write("{} - {}\n".format(e[0], e[1]))
def createThesaurusPackage (spBuild, sVersion, spCopy="", spDataDestGL=""):
print(" * Création du thésaurus")
spThesaurus = spBuild+"/thesaurus-v"+sVersion
dir_util.mkpath(spThesaurus)
thes_build.build("thesaurus/thes_fr.dat", "thesaurus/synsets_fr.dat", spThesaurus)
file_util.copy_file('thesaurus/README_thes_fr.txt', spThesaurus)
if spCopy:
# copy in libreoffice extension package
print(" Copie du thésaurus dans:", spCopy)
file_util.copy_file(spThesaurus+'/thes_fr.dat', spCopy)
file_util.copy_file(spThesaurus+'/thes_fr.idx', spCopy)
file_util.copy_file(spThesaurus+'/README_thes_fr.txt', spCopy)
if spModulesDestGL:
# copy in data source folder of Grammalecte
file_util.copy_file(spThesaurus+'/thes_fr.json', spDataDestGL)
def main ():
xParser = argparse.ArgumentParser()
xParser.add_argument("-v", "--verdic", help="set dictionary version, i.e. 5.4", type=str, default="X.Y.z")
xParser.add_argument("-m", "--mode", help="0: no tags, 1: Hunspell tags (default), 2: All tags", type=int, choices=[0, 1, 2], default=1)
xParser.add_argument("-u", "--uncompress", help="do not use Hunspell compression", action="store_true")
|
| ︙ | ︙ | |||
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 |
oStatsLex.addLexFromFile('lexique/corpus_data/stats_litterature.txt', 'L', 'Littérature')
oStatsLex.write(spBuild+'/test_lex.txt')
oFrenchDict.calculateStats(oStatsLex, spfStats)
### Écriture des paquets
echo("Création des paquets...")
spLexiconDestGL = "../../../lexicons" if xArgs.grammalecte else ""
spLibreOfficeExtDestGL = "../oxt/Dictionnaires/dictionaries" if xArgs.grammalecte else ""
spMozillaExtDestGL = "" if xArgs.grammalecte else "" # no more Hunspell dictionaries in Mozilla extensions for now
spDataDestGL = "../data" if xArgs.grammalecte else ""
### dictionnaires
if not xArgs.uncompress:
oFrenchDict.defineAbreviatedTags(xArgs.mode, spfStats)
oFrenchDict.createFiles(spBuild, [dTOUTESVAR, dCLASSIQUE, dREFORME1990], xArgs.mode, xArgs.simplify)
oFrenchDict.createLexiconPackages(spBuild, xArgs.verdic, oStatsLex, spLexiconDestGL)
oFrenchDict.createFileIfqForDB(spBuild)
| > | | | 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 |
oStatsLex.addLexFromFile('lexique/corpus_data/stats_litterature.txt', 'L', 'Littérature')
oStatsLex.write(spBuild+'/test_lex.txt')
oFrenchDict.calculateStats(oStatsLex, spfStats)
### Écriture des paquets
echo("Création des paquets...")
nThesaurusVersion = 2.4
spLexiconDestGL = "../../../lexicons" if xArgs.grammalecte else ""
spLibreOfficeExtDestGL = "../oxt/Dictionnaires/dictionaries" if xArgs.grammalecte else ""
spMozillaExtDestGL = "" if xArgs.grammalecte else "" # no more Hunspell dictionaries in Mozilla extensions for now
spDataDestGL = "../data" if xArgs.grammalecte else ""
### dictionnaires
if not xArgs.uncompress:
oFrenchDict.defineAbreviatedTags(xArgs.mode, spfStats)
oFrenchDict.createFiles(spBuild, [dTOUTESVAR, dCLASSIQUE, dREFORME1990], xArgs.mode, xArgs.simplify)
oFrenchDict.createLexiconPackages(spBuild, xArgs.verdic, oStatsLex, spLexiconDestGL)
oFrenchDict.createFileIfqForDB(spBuild)
createThesaurusPackage(spBuild, nThesaurusVersion, spLibreOfficeExtDestGL, spDataDestGL)
oFrenchDict.createLibreOfficeExtension(spBuild, dMOZEXT, [dTOUTESVAR, dCLASSIQUE, dREFORME1990], nThesaurusVersion, spLibreOfficeExtDestGL)
oFrenchDict.createMozillaExtensions(spBuild, dMOZEXT, [dTOUTESVAR, dCLASSIQUE, dREFORME1990], spMozillaExtDestGL)
oFrenchDict.createDictConj(spBuild, spDataDestGL)
oFrenchDict.createDictDecl(spBuild, spDataDestGL)
if __name__ == '__main__':
main()
|
Modified gc_lang/fr/dictionnaire/thes_build.py from [7fe275114e] to [b66a405bcd].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# Thesaurus builder
import os
import re
def readFile (spf):
if os.path.isfile(spf):
with open(spf, "r", encoding="utf-8") as hSrc:
for sLine in hSrc:
yield sLine.strip()
else:
print("# Error. File not found or not loadable: " + spf)
class ThesaurusBuilder ():
def __init__ (self):
# synsets
self.dSynEntry = {} # {sWord: iSynset}
self.dSynset = {} # {iSynset: lSynset}
# thesaurus
| > | | 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 |
# Thesaurus builder
import os
import re
import json
def readFile (spf):
if os.path.isfile(spf):
with open(spf, "r", encoding="utf-8") as hSrc:
for sLine in hSrc:
yield sLine.strip()
else:
print("# Error. File not found or not loadable: " + spf)
class ThesaurusBuilder ():
def __init__ (self):
# synsets
self.dSynEntry = {} # {sWord: iSynset}
self.dSynset = {} # {iSynset: lSynset}
# thesaurus
self.dThesaurus = {} # {sWord: lWord}
def readSynsets (self, spf):
if not spf:
return
for i, sLine in enumerate(readFile(spf), 1):
sPOS, *lSynset = sLine.split("|")
lSynset = self._removeDuplicatesFrom(lSynset)
|
| ︙ | ︙ | |||
57 58 59 60 61 62 63 |
sLine = sLine.strip()
if re.search(r"^[^|]+\|[1-9][0-9]*$", sLine):
# new entry
if nClass != nClassFound:
print("Ligne:", iEntryLine, ", nombre de liste incorrect")
iEntryLine = i
sEntry, sNum = sLine.split("|")
| | | | | | | | | > > > > > > | 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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
sLine = sLine.strip()
if re.search(r"^[^|]+\|[1-9][0-9]*$", sLine):
# new entry
if nClass != nClassFound:
print("Ligne:", iEntryLine, ", nombre de liste incorrect")
iEntryLine = i
sEntry, sNum = sLine.split("|")
self.dThesaurus[sEntry] = []
nClass = int(sNum)
nClassFound = 0
else:
# new list of synonyms
nClassFound += 1
sPOS, *lClass = sLine.split("|")
lClass = self._removeDuplicatesFrom(lClass)
self.dThesaurus[sEntry].append( (sPOS, lClass) )
def showThesaurusEntries (self):
for sWord, lClass in self.dThesaurus.items():
for sPOS, lWord in lClass:
print(sWord, sPOS, "|".join(lWord))
def _removeDuplicatesFrom (self, lWord):
return [ sWord.strip() for sWord in dict.fromkeys(lWord) ] # remove duplicates: use <dict.fromkeys()> instead of <set()> to keep order
def merge (self):
for sWord, lSynset in self.dSynEntry.items():
for sPOS, iSynset in lSynset:
if sWord in self.dThesaurus:
self.dThesaurus[sWord].append( (sPOS, self.dSynset[iSynset]) )
else:
self.dThesaurus[sWord] = [ (sPOS, self.dSynset[iSynset]) ]
def write (self, spDest):
nOffset = 0 # the offset for finding data is the number of bytes (-> encoding("utf-8"))
dOffset = {}
with open(spDest + "/thes_fr.dat", "w", encoding="utf-8", newline="\n") as hThes:
sHeader = "UTF-8\n"
hThes.write(sHeader)
nOffset = len(sHeader.encode("utf-8"))
for sWord, lClass in self.dThesaurus.items():
dOffset[sWord] = nOffset
sWordLine = sWord+"|"+str(len(lClass))+"\n"
hThes.write(sWordLine)
nOffset += len(sWordLine.encode("utf-8"))
for sPOS, lWord in lClass:
sClassLine = sPOS+"|"+"|".join(lWord)+"\n"
hThes.write(sClassLine)
nOffset += len(sClassLine.encode("utf-8"))
with open(spDest + "/thes_fr.idx", "w", encoding="utf-8", newline="\n") as hIndex:
hIndex.write("UTF-8\n")
hIndex.write(str(len(self.dThesaurus))+"\n")
for sWord, nOffset in sorted(dOffset.items()):
hIndex.write(sWord+"|"+str(nOffset)+"\n")
def writeAsJSON (self, spDest):
with open(spDest + "/thes_fr.json", "w", encoding="utf-8", newline="\n") as hJsonThes:
sJSON = json.dumps(self.dThesaurus, ensure_ascii=False)
hJsonThes.write(sJSON)
def build (spfThesaurus="", spfSynsets="", spDest="_build"):
oThes = ThesaurusBuilder()
oThes.readSynsets(spfSynsets)
#oThes.showSynsetEntries()
oThes.readThesaurus(spfThesaurus)
#oThes.showThesaurusEntries()
oThes.merge()
oThes.write(spDest)
oThes.writeAsJSON(spDest)
if __name__ == '__main__':
build("thesaurus/thes_fr.dat", "thesaurus/synsets_fr.dat")
|
Added gc_lang/fr/modules-js/thesaurus.js version [009b56b2e7].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 - Thésaurus
/* jshint esversion:6 */
/* jslint esversion:6 */
/* global __dirname */
"use strict";
${string}
if (typeof(process) !== 'undefined') {
var helpers = require("../graphspell/helpers.js");
}
var thesaurus = {
_dWord: new Map(),
bInit: false,
init: function (sJSONData) {
try {
let _oData = JSON.parse(sJSONData);
this._dWord = helpers.objectToMap(_oData);
this.bInit = true;
//console.log(this._dWord);
}
catch (e) {
console.error(e);
}
},
getSyns: function (sWord) {
// return list of synonyms of <sWord>
if (!sWord) {
return [];
}
if (this._dWord.has(sWord)) {
return this._dWord.get(sWord);
}
if (sWord.slice(0,1).gl_isUpperCase()) {
sWord = sWord.toLowerCase();
if (this._dWord.has(sWord)) {
return this._dWord.get(sWord);
}
}
return [];
}
};
// Initialization
if (!thesaurus.bInit && typeof(process) !== 'undefined') {
// NodeJS
thesaurus.init(helpers.loadFile(__dirname+"/thesaurus_data.json"));
} else if (!thesaurus.bInit && typeof(browser) !== 'undefined') {
// WebExtension Standard (but not in Worker)
thesaurus.init(helpers.loadFile(browser.runtime.getURL("grammalecte/fr/thesaurus_data.json")));
} else if (!thesaurus.bInit && typeof(chrome) !== 'undefined') {
// WebExtension Chrome (but not in Worker)
thesaurus.init(helpers.loadFile(chrome.runtime.getURL("grammalecte/fr/thesaurus_data.json")));
} else if (thesaurus.bInit){
console.log("Module thesaurus déjà initialisé");
} else {
//console.log("Module thesaurus non initialisé");
}
if (typeof(exports) !== 'undefined') {
exports._dWord = thesaurus._dWord;
exports.init = thesaurus.init;
exports.getSyns = thesaurus.getSyns;
}
|
Added gc_lang/fr/modules-js/thesaurus_data.json version [f1d1750969].
more than 10,000 changes
Added gc_lang/fr/modules/thesaurus.py version [0fc425d93f].
> > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
"""
Grammalecte - Thesaurus
"""
# License: GPL 3
from .thesaurus_data import dThesaurus as _dThesaurus
def getSyns (sWord):
"return list of synonyms of <sWord>"
if not sWord:
return []
if sWord in _dThesaurus:
return _dThesaurus[sWord]
if sWord[0:1].isupper():
sWord = sWord.lower()
if sWord in _dThesaurus:
return _dThesaurus[sWord]
return []
|
Added gc_lang/fr/modules/thesaurus_data.py version [4ac0f3ea5b].
more than 10,000 changes
Modified gc_lang/fr/webext/background.js from [502b8838ad] to [2ee8e2d39e].
| ︙ | ︙ | |||
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
case "parse":
case "parseAndSpellcheck":
case "parseAndSpellcheck1":
case "parseFull":
case "getListOfTokens":
case "getSpellSuggestions":
case "getVerb":
// send result to content script
if (typeof(oInfo.iReturnPort) === "number") {
let xPort = dConnx.get(oInfo.iReturnPort);
xPort.postMessage(e.data);
} else {
console.log("[background] don’t know where to send results");
console.log(e.data);
| > | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
case "parse":
case "parseAndSpellcheck":
case "parseAndSpellcheck1":
case "parseFull":
case "getListOfTokens":
case "getSpellSuggestions":
case "getVerb":
case "getSyns":
// send result to content script
if (typeof(oInfo.iReturnPort) === "number") {
let xPort = dConnx.get(oInfo.iReturnPort);
xPort.postMessage(e.data);
} else {
console.log("[background] don’t know where to send results");
console.log(e.data);
|
| ︙ | ︙ | |||
288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
oWorkerHandler.restart(oParam["nDelayLimit"]);
break;
case "openURL":
browser.tabs.create({url: oParam.sURL});
break;
case "openConjugueurTab":
openConjugueurTab();
break;
case "openLexiconEditor":
openLexiconEditor(oParam["dictionary"]);
break;
case "openDictionaries":
openDictionaries();
break;
| > > > | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
oWorkerHandler.restart(oParam["nDelayLimit"]);
break;
case "openURL":
browser.tabs.create({url: oParam.sURL});
break;
case "openConjugueurTab":
openConjugueurTab();
break;
case "openThesaurusTab":
openThesaurusTab();
break;
case "openLexiconEditor":
openLexiconEditor(oParam["dictionary"]);
break;
case "openDictionaries":
openDictionaries();
break;
|
| ︙ | ︙ | |||
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
case "parse":
case "parseAndSpellcheck":
case "parseAndSpellcheck1":
case "parseFull":
case "getListOfTokens":
case "getSpellSuggestions":
case "getVerb":
oRequest.oInfo.iReturnPort = iPortId; // we pass the id of the return port to receive answer
oWorkerHandler.xGCEWorker.postMessage(oRequest);
break;
case "restartWorker":
oWorkerHandler.restart(oParam["nDelayLimit"]);
break;
case "openURL":
browser.tabs.create({url: oParam.sURL});
break;
case "openConjugueurTab":
openConjugueurTab();
break;
case "openConjugueurWindow":
openConjugueurWindow();
break;
case "openLexiconEditor":
openLexiconEditor("__personal__", oParam["sWord"]);
break;
default:
console.log("[background] Unknown command: " + sCommand);
console.log(oRequest);
}
| > > > > > > > | 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
case "parse":
case "parseAndSpellcheck":
case "parseAndSpellcheck1":
case "parseFull":
case "getListOfTokens":
case "getSpellSuggestions":
case "getVerb":
case "getSyns":
oRequest.oInfo.iReturnPort = iPortId; // we pass the id of the return port to receive answer
oWorkerHandler.xGCEWorker.postMessage(oRequest);
break;
case "restartWorker":
oWorkerHandler.restart(oParam["nDelayLimit"]);
break;
case "openURL":
browser.tabs.create({url: oParam.sURL});
break;
case "openConjugueurTab":
openConjugueurTab();
break;
case "openConjugueurWindow":
openConjugueurWindow();
break;
case "openThesaurusTab":
openThesaurusTab();
break;
case "openThesaurusWindow":
openThesaurusWindow();
break;
case "openLexiconEditor":
openLexiconEditor("__personal__", oParam["sWord"]);
break;
default:
console.log("[background] Unknown command: " + sCommand);
console.log(oRequest);
}
|
| ︙ | ︙ | |||
387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
browser.contextMenus.create({ id: "grammar_checker_page", title: "Analyser la page", contexts: ["all"] });
browser.contextMenus.create({ id: "separator_tools", type: "separator", contexts: ["all"] });
// Tools
browser.contextMenus.create({ id: "conjugueur_tab", title: "Conjugueur [onglet]", contexts: ["all"] });
browser.contextMenus.create({ id: "conjugueur_window", title: "Conjugueur [fenêtre]", contexts: ["all"] });
//browser.contextMenus.create({ id: "dictionaries", title: "Dictionnaires", contexts: ["all"] });
browser.contextMenus.create({ id: "lexicon_editor", title: "Éditeur lexical", contexts: ["all"] });
browser.contextMenus.onClicked.addListener(function (xInfo, xTab) {
// xInfo = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/contextMenus/OnClickData
// xTab = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/Tab
// confusing: no way to get the node where we click?!
switch (xInfo.menuItemId) {
// analyze
| > > | 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
browser.contextMenus.create({ id: "grammar_checker_page", title: "Analyser la page", contexts: ["all"] });
browser.contextMenus.create({ id: "separator_tools", type: "separator", contexts: ["all"] });
// Tools
browser.contextMenus.create({ id: "conjugueur_tab", title: "Conjugueur [onglet]", contexts: ["all"] });
browser.contextMenus.create({ id: "conjugueur_window", title: "Conjugueur [fenêtre]", contexts: ["all"] });
//browser.contextMenus.create({ id: "dictionaries", title: "Dictionnaires", contexts: ["all"] });
browser.contextMenus.create({ id: "lexicon_editor", title: "Éditeur lexical", contexts: ["all"] });
browser.contextMenus.create({ id: "thesaurus_tab", title: "Thésaurus [onglet]", contexts: ["all"] });
browser.contextMenus.create({ id: "thesaurus_window", title: "Thésaurus [fenêtre]", contexts: ["all"] });
browser.contextMenus.onClicked.addListener(function (xInfo, xTab) {
// xInfo = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/contextMenus/OnClickData
// xTab = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/Tab
// confusing: no way to get the node where we click?!
switch (xInfo.menuItemId) {
// analyze
|
| ︙ | ︙ | |||
410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
break;
// tools
case "conjugueur_window":
openConjugueurWindow();
break;
case "conjugueur_tab":
openConjugueurTab();
break;
case "lexicon_editor":
openLexiconEditor();
break;
case "dictionaries":
openDictionaries();
break;
| > > > > > > | 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
break;
// tools
case "conjugueur_window":
openConjugueurWindow();
break;
case "conjugueur_tab":
openConjugueurTab();
break;
case "thesaurus_window":
openConjugueurWindow();
break;
case "thesaurus_tab":
openConjugueurTab();
break;
case "lexicon_editor":
openLexiconEditor();
break;
case "dictionaries":
openDictionaries();
break;
|
| ︙ | ︙ | |||
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
switch (sCommand) {
case "grammar_checker":
sendCommandToCurrentTab("shortcutGrammarChecker");
break;
case "conjugueur_tab":
openConjugueurTab();
break;
case "lexicon_editor":
openLexiconEditor();
break;
case "dictionaries":
openDictionaries();
break;
}
});
/*
Tabs
*/
let nTabLexiconEditor = null;
let nTabDictionaries = null;
let nTabConjugueur = null;
browser.tabs.onRemoved.addListener(function (nTabId, xRemoveInfo) {
switch (nTabId) {
case nTabLexiconEditor: nTabLexiconEditor = null; break;
case nTabDictionaries: nTabDictionaries = null; break;
case nTabConjugueur: nTabConjugueur = null; break;
}
});
/*
Actions
*/
| > > > > > | 457 458 459 460 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 489 490 491 492 493 494 495 496 497 |
switch (sCommand) {
case "grammar_checker":
sendCommandToCurrentTab("shortcutGrammarChecker");
break;
case "conjugueur_tab":
openConjugueurTab();
break;
case "thesaurus_tab":
openThesaurusTab();
break;
case "lexicon_editor":
openLexiconEditor();
break;
case "dictionaries":
openDictionaries();
break;
}
});
/*
Tabs
*/
let nTabLexiconEditor = null;
let nTabDictionaries = null;
let nTabConjugueur = null;
let nTabThesaurus = null;
browser.tabs.onRemoved.addListener(function (nTabId, xRemoveInfo) {
switch (nTabId) {
case nTabLexiconEditor: nTabLexiconEditor = null; break;
case nTabDictionaries: nTabDictionaries = null; break;
case nTabConjugueur: nTabConjugueur = null; break;
case nTabThesaurus: nTabThesaurus = null; break;
}
});
/*
Actions
*/
|
| ︙ | ︙ | |||
601 602 603 604 605 606 607 608 609 610 611 612 |
url: browser.runtime.getURL("panel/conjugueur.html"),
type: "popup",
width: 710,
height: 980
});
}
function showError (e) {
console.error(e);
//console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
url: browser.runtime.getURL("panel/conjugueur.html"),
type: "popup",
width: 710,
height: 980
});
}
function openThesaurusTab () {
if (nTabThesaurus === null) {
if (bChrome) {
browser.tabs.create({
url: browser.runtime.getURL("panel/thesaurus.html")
}, onThesaurusOpened);
return;
}
let xThesTab = browser.tabs.create({
url: browser.runtime.getURL("panel/thesaurus.html")
});
xThesTab.then(onThesaurusOpened, showError);
}
else {
browser.tabs.update(nTabThesaurus, {active: true});
}
}
function onThesaurusOpened (xTab) {
nTabThesaurus = xTab.id;
}
function openThesaurusWindow () {
if (bChrome) {
browser.windows.create({
url: browser.runtime.getURL("panel/thesaurus.html"),
type: "popup",
width: 710,
height: 980
});
return;
}
let xConjWindow = browser.windows.create({
url: browser.runtime.getURL("panel/thesaurus.html"),
type: "popup",
width: 710,
height: 980
});
}
function showError (e) {
console.error(e);
//console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}
|
Modified gc_lang/fr/webext/content_scripts/html_src.js from [32b2f1f9e8] to [9a834c7c56].
| ︙ | ︙ | |||
8 9 10 11 12 13 14 |
@Reviewers:
This file only defines HTML nodes in const values
*/
const sGrammalecteConjugueurHTML = `
| | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
@Reviewers:
This file only defines HTML nodes in const values
*/
const sGrammalecteConjugueurHTML = `
<div class="grammalecte_centered_bar">
<div contenteditable="true" id="grammalecte_conj_verb" autofocus >entrez un verbe</div>
<div id="grammalecte_conj_erase_button">×</div>
</div>
<div class="grammalecte_clearer"></div>
<h1 class="grammalecte_conj_title" id="grammalecte_conj_verb_title" class="center"> </h1>
<div id="grammalecte_conj_verb_info" class="center"> </div>
|
| ︙ | ︙ | |||
154 155 156 157 158 159 160 161 |
</div>
</div>
</div>
<div class="grammalecte_clearer"></div>
`;
| > > > > > > > > > > > > > > > > > > | 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
</div>
</div>
</div>
<div class="grammalecte_clearer"></div>
`;
const sGrammalecteThesaurusHTML = `
<div class="grammalecte_centered_bar">
<div contenteditable="true" id="grammalecte_thes_word" autofocus ></div>
<div id="grammalecte_thes_erase_button">×</div>
</div>
<div class="grammalecte_clearer"></div>
<h1 class="grammalecte_thes_title" id="grammalecte_thes_title" class="center"> </h1>
<div id="grammalecte_separator">❦</div>
<div id="grammalecte_thes_word_info" class="center" style="display: none;">Aucun synonyme trouvé</div>
<div id="grammalecte_synonyms_list">
</div>
<div class="grammalecte_clearer"></div>
`;
|
Modified gc_lang/fr/webext/content_scripts/init.js from [083d402f25] to [ceb96caba3].
| ︙ | ︙ | |||
351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
getListOfTokens: function (sText, sDestination) {
this.send("getListOfTokens", { sText: sText }, { sDestination: sDestination });
},
getVerb: function (sVerb, bStart=true, bPro=false, bNeg=false, bTpsCo=false, bInt=false, bFem=false) {
this.send("getVerb", { sVerb: sVerb, bPro: bPro, bNeg: bNeg, bTpsCo: bTpsCo, bInt: bInt, bFem: bFem }, { bStart: bStart });
},
getSpellSuggestions: function (sWord, sDestination, sErrorId) {
this.send("getSpellSuggestions", { sWord: sWord }, { sDestination: sDestination, sErrorId: sErrorId });
},
openURL: function (sURL) {
this.send("openURL", { "sURL": sURL });
| > > > > | 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
getListOfTokens: function (sText, sDestination) {
this.send("getListOfTokens", { sText: sText }, { sDestination: sDestination });
},
getVerb: function (sVerb, bStart=true, bPro=false, bNeg=false, bTpsCo=false, bInt=false, bFem=false) {
this.send("getVerb", { sVerb: sVerb, bPro: bPro, bNeg: bNeg, bTpsCo: bTpsCo, bInt: bInt, bFem: bFem }, { bStart: bStart });
},
getSyns: function (sWord) {
this.send("getSyns", { sWord: sWord });
},
getSpellSuggestions: function (sWord, sDestination, sErrorId) {
this.send("getSpellSuggestions", { sWord: sWord }, { sDestination: sDestination, sErrorId: sErrorId });
},
openURL: function (sURL) {
this.send("openURL", { "sURL": sURL });
|
| ︙ | ︙ | |||
448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
case "getVerb":
if (oInfo.bStart) {
oGrammalecte.oGCPanel.conjugateWith(result.oVerb, result.oConjTable);
} else {
oGrammalecte.oGCPanel.displayConj(result.oConjTable);
}
break;
case "workerRestarted":
oGrammalecte.oGCPanel.stopWaitIcon();
oGrammalecte.oGCPanel.showMessage("Le serveur grammatical a été arrêté et relancé.");
oGrammalecte.oGCPanel.endTimer();
break;
/*
Commands received from the context menu
| > > > | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
case "getVerb":
if (oInfo.bStart) {
oGrammalecte.oGCPanel.conjugateWith(result.oVerb, result.oConjTable);
} else {
oGrammalecte.oGCPanel.displayConj(result.oConjTable);
}
break;
case "getSyns":
oGrammalecte.oGCPanel.displaySyns(result.sWord, result.lSyns);
break;
case "workerRestarted":
oGrammalecte.oGCPanel.stopWaitIcon();
oGrammalecte.oGCPanel.showMessage("Le serveur grammatical a été arrêté et relancé.");
oGrammalecte.oGCPanel.endTimer();
break;
/*
Commands received from the context menu
|
| ︙ | ︙ |
Modified gc_lang/fr/webext/content_scripts/panel.css from [0ba5c9a9a4] to [d72cc9e578].
| ︙ | ︙ | |||
130 131 132 133 134 135 136 137 138 139 |
color: hsla(210, 0%, 100%, 1);
}
div.grammalecte_panel_menu {
display: flex;
flex-direction: row;
justify-content: space-around;
}
div.grammalecte_menu_button {
color: hsl(210, 50%, 96%);
| > | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
color: hsla(210, 0%, 100%, 1);
}
div.grammalecte_panel_menu {
display: flex;
flex-direction: row;
justify-content: space-around;
flex-wrap: nowrap;
}
div.grammalecte_menu_button {
color: hsl(210, 50%, 96%);
padding: 5px 5px;
font-size: 12px;
font-variant: small-caps;
cursor: pointer;
border-radius: 3px;
}
div.grammalecte_menu_button:hover {
background-color: hsl(210, 80%, 40%);
|
| ︙ | ︙ |
Modified gc_lang/fr/webext/content_scripts/panel.js from [01269ca544] to [8512db0e86].
| ︙ | ︙ | |||
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
insertIntoPage () {
if (this.bShadow) {
oGrammalecte.createStyle("content_scripts/panel.css", null, this.xShadowRoot);
oGrammalecte.createStyle("content_scripts/panel_gc.css", null, this.xShadowRoot);
oGrammalecte.createStyle("content_scripts/panel_lxg.css", null, this.xShadowRoot);
oGrammalecte.createStyle("content_scripts/panel_conj.css", null, this.xShadowRoot);
oGrammalecte.createStyle("content_scripts/panel_tf.css", null, this.xShadowRoot);
this.xShadowRoot.appendChild(this.xPanel);
document.body.appendChild(this.xShadowHost);
} else {
if (!document.getElementById("grammalecte_csspanel")) {
oGrammalecte.createStyle("content_scripts/panel.css", "grammalecte_csspanel", document.head);
oGrammalecte.createStyle("content_scripts/panel_gc.css", null, document.head);
oGrammalecte.createStyle("content_scripts/panel_lxg.css", null, document.head);
oGrammalecte.createStyle("content_scripts/panel_conj.css", null, document.head);
oGrammalecte.createStyle("content_scripts/panel_tf.css", null, document.head);
}
document.body.appendChild(this.xPanel);
}
}
show () {
| > > | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
insertIntoPage () {
if (this.bShadow) {
oGrammalecte.createStyle("content_scripts/panel.css", null, this.xShadowRoot);
oGrammalecte.createStyle("content_scripts/panel_gc.css", null, this.xShadowRoot);
oGrammalecte.createStyle("content_scripts/panel_lxg.css", null, this.xShadowRoot);
oGrammalecte.createStyle("content_scripts/panel_conj.css", null, this.xShadowRoot);
oGrammalecte.createStyle("content_scripts/panel_thes.css", null, this.xShadowRoot);
oGrammalecte.createStyle("content_scripts/panel_tf.css", null, this.xShadowRoot);
this.xShadowRoot.appendChild(this.xPanel);
document.body.appendChild(this.xShadowHost);
} else {
if (!document.getElementById("grammalecte_csspanel")) {
oGrammalecte.createStyle("content_scripts/panel.css", "grammalecte_csspanel", document.head);
oGrammalecte.createStyle("content_scripts/panel_gc.css", null, document.head);
oGrammalecte.createStyle("content_scripts/panel_lxg.css", null, document.head);
oGrammalecte.createStyle("content_scripts/panel_conj.css", null, document.head);
oGrammalecte.createStyle("content_scripts/panel_thes.css", null, document.head);
oGrammalecte.createStyle("content_scripts/panel_tf.css", null, document.head);
}
document.body.appendChild(this.xPanel);
}
}
show () {
|
| ︙ | ︙ |
Modified gc_lang/fr/webext/content_scripts/panel_conj.css from [ec0b4594f9] to [9c7dfe2b81].
1 2 3 4 5 6 7 8 9 |
/*
CSS Document
*/
div#grammalecte_conj_panel_content {
padding: 20px 0;
width: 100%;
}
| | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/*
CSS Document
*/
div#grammalecte_conj_panel_content {
padding: 20px 0;
width: 100%;
}
div.grammalecte_centered_bar {
display: flex;
justify-content: center;
align-items: stretch;
width: 500px;
margin: 0 auto;
}
|
| ︙ | ︙ | |||
72 73 74 75 76 77 78 |
font: normal 18px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif;
color: hsl(0, 0%, 30%);
}
div#grammalecte_conj_verb {
color: hsl(0, 0%, 70%);
}
| > | > | | > | < | < < < < | | | < | 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 |
font: normal 18px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif;
color: hsl(0, 0%, 30%);
}
div#grammalecte_conj_verb {
color: hsl(0, 0%, 70%);
}
div#grammalecte_conj_erase_button {
display: inline-block;
margin: 3px;
padding: 5px 10px;
font-weight: bold;
color: hsl(0, 0%, 100%);
background-color: hsl(0, 0%, 80%);
border-radius: 4px;
}
div#grammalecte_conj_erase_button:hover {
background-color: hsl(0, 50%, 50%);
cursor: pointer;
}
div#grammalecte_conj_options {
margin: 10px 0 0 5px;
font-size: 16px;
text-align: center;
}
|
| ︙ | ︙ |
Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [21f2cf4731] to [e2f46957ed].
| ︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
oGrammalecteBackgroundPort.openURL(xElem.dataset.url);
} else {
oGrammalecte.oGCPanel.oTooltip.hide();
}
} else {
oGrammalecte.oGCPanel.oTooltip.hide();
}
}
catch (e) {
showError(e);
}
}
| > > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
oGrammalecteBackgroundPort.openURL(xElem.dataset.url);
} else {
oGrammalecte.oGCPanel.oTooltip.hide();
}
} else {
oGrammalecte.oGCPanel.oTooltip.hide();
}
if (xElem.className == "grammalecte_synonym") {
oGrammalecte.oGCPanel.getSyns(xElem.textContent.trim());
}
}
catch (e) {
showError(e);
}
}
|
| ︙ | ︙ | |||
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
this.xPanelContent.appendChild(this.xLxgPanelContent);
// Conjugueur
this.xConjPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_conj_panel_content"});
this.xConjPanelContent.innerHTML = sGrammalecteConjugueurHTML; // @Reviewers: sGrammalecteConjugueurHTML is a const value defined in <content_scripts/html_src.js>
this.xPanelContent.appendChild(this.xConjPanelContent);
this.sVerb = "";
this.bListenConj = false;
}
createMenu () {
this.xMenu = oGrammalecte.createNode("div", {className: "grammalecte_panel_menu"});
// tabs
this.xTFButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Formateur de texte"});
this.xEditorButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Éditeur"});
this.xLxgButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Lexicographe"});
this.xConjButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Conjugueur"});
// buttons
| > > > > > > | | 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 117 |
this.xPanelContent.appendChild(this.xLxgPanelContent);
// Conjugueur
this.xConjPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_conj_panel_content"});
this.xConjPanelContent.innerHTML = sGrammalecteConjugueurHTML; // @Reviewers: sGrammalecteConjugueurHTML is a const value defined in <content_scripts/html_src.js>
this.xPanelContent.appendChild(this.xConjPanelContent);
this.sVerb = "";
this.bListenConj = false;
// Thésaurus
this.xThesPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_thes_panel_content"});
this.xThesPanelContent.innerHTML = sGrammalecteThesaurusHTML; // @Reviewers: sGrammalecteThesaurusHTML is a const value defined in <content_scripts/html_src.js>
this.xPanelContent.appendChild(this.xThesPanelContent);
this.sWord = "";
}
createMenu () {
this.xMenu = oGrammalecte.createNode("div", {className: "grammalecte_panel_menu"});
// tabs
this.xTFButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Formateur de texte"});
this.xEditorButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Éditeur"});
this.xLxgButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Lexicographe"});
this.xConjButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Conjugueur"});
this.xThesButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Thésaurus"});
// buttons
this.xLexEditButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_subbutton", textContent: "Édit.", title: "Ouvrir l’éditeur lexical", style: "background-color: hsl(210, 50%, 40%)"});
this.xLxgButton.appendChild(this.xLexEditButton);
this.xAutoRefresh = oGrammalecte.createNode("div", {className: "grammalecte_menu_subbutton", textContent: "AutoRafr", title: "Auto-rafraîchissement de la correction grammaticale (3 s après la dernière frappe)"});
this.xEditorButton.appendChild(this.xAutoRefresh);
this.bAutoRefresh = oGrammalecte.bAutoRefresh;
this.setAutoRefreshButton();
this.xTFButton.onclick = () => {
if (!this.bWorking) {
|
| ︙ | ︙ | |||
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
this.showLexicographer();
}
};
this.xConjButton.onclick = () => {
if (!this.bWorking) {
this.showConjugueur();
}
};
this.xLexEditButton.onclick = () => {
oGrammalecteBackgroundPort.openLexiconEditor();
};
// Add tabs to menu
this.xMenu.appendChild(this.xTFButton);
this.xMenu.appendChild(this.xEditorButton);
this.xMenu.appendChild(this.xLxgButton);
this.xMenu.appendChild(this.xConjButton);
this.xPanelBar.appendChild(this.xMenu);
}
start (what, xResultNode=null) {
this.oTooltip.hide();
this.bWorking = false;
this.clear();
| > > > > > > | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
this.showLexicographer();
}
};
this.xConjButton.onclick = () => {
if (!this.bWorking) {
this.showConjugueur();
}
};
this.xThesButton.onclick = () => {
if (!this.bWorking) {
this.showThesaurus();
}
};
this.xLexEditButton.onclick = () => {
oGrammalecteBackgroundPort.openLexiconEditor();
};
// Add tabs to menu
this.xMenu.appendChild(this.xTFButton);
this.xMenu.appendChild(this.xEditorButton);
this.xMenu.appendChild(this.xLxgButton);
this.xMenu.appendChild(this.xConjButton);
this.xMenu.appendChild(this.xThesButton);
this.xPanelBar.appendChild(this.xMenu);
}
start (what, xResultNode=null) {
this.oTooltip.hide();
this.bWorking = false;
this.clear();
|
| ︙ | ︙ | |||
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
oGrammalecteBackgroundPort.parseAndSpellcheck(this.oTextControl.getText(), "__GrammalectePanel__");
}
showEditor () {
this.switchContentOn(this.xGCPanelContent, this.xEditorButton);
this.switchContentOff(this.xLxgPanelContent, this.xLxgButton);
this.switchContentOff(this.xConjPanelContent, this.xConjButton);
this.xPanel.style.background = "";
}
showLexicographer () {
this.switchContentOff(this.xGCPanelContent, this.xEditorButton);
this.switchContentOn(this.xLxgPanelContent, this.xLxgButton);
this.switchContentOff(this.xConjPanelContent, this.xConjButton);
this.xPanel.style.background = "";
}
showConjugueur () {
this.switchContentOff(this.xGCPanelContent, this.xEditorButton);
this.switchContentOff(this.xLxgPanelContent, this.xLxgButton);
this.switchContentOn(this.xConjPanelContent, this.xConjButton);
this.xPanel.style.background = "linear-gradient(to bottom, hsla(0,0%,100%,1) 0%, hsla(0,0%,95%,1) 55%, hsla(0,0%,90%,1) 100%)";
this.listenConj();
if (!this.sVerb) {
this.conjugateVerb("être");
}
}
switchContentOn (xContent, xNodeButton) {
xContent.style.display = "block";
xNodeButton.style.backgroundColor = "hsl(210, 60%, 40%)";
xNodeButton.style.textShadow = "2px 0 0 hsla(210, 40%, 35%, .5), -2px 0 0 hsla(210, 40%, 35%, .5), 0 2px 0 hsla(210, 40%, 35%, .5), 0 -2px 0 hsla(210, 40%, 35%, .5), 1px 1px hsla(210, 40%, 35%, .5), -1px -1px 0 hsla(210, 40%, 35%, .5), 1px -1px 0 hsla(210, 40%, 35%, .5), -1px 1px 0 hsla(210, 30%, 35%, .5)";
}
| > > > > > > > > > > > > | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
oGrammalecteBackgroundPort.parseAndSpellcheck(this.oTextControl.getText(), "__GrammalectePanel__");
}
showEditor () {
this.switchContentOn(this.xGCPanelContent, this.xEditorButton);
this.switchContentOff(this.xLxgPanelContent, this.xLxgButton);
this.switchContentOff(this.xConjPanelContent, this.xConjButton);
this.switchContentOff(this.xThesPanelContent, this.xThesButton);
this.xPanel.style.background = "";
}
showLexicographer () {
this.switchContentOff(this.xGCPanelContent, this.xEditorButton);
this.switchContentOn(this.xLxgPanelContent, this.xLxgButton);
this.switchContentOff(this.xConjPanelContent, this.xConjButton);
this.switchContentOff(this.xThesPanelContent, this.xThesButton);
this.xPanel.style.background = "";
}
showConjugueur () {
this.switchContentOff(this.xGCPanelContent, this.xEditorButton);
this.switchContentOff(this.xLxgPanelContent, this.xLxgButton);
this.switchContentOn(this.xConjPanelContent, this.xConjButton);
this.switchContentOff(this.xThesPanelContent, this.xThesButton);
this.xPanel.style.background = "linear-gradient(to bottom, hsla(0,0%,100%,1) 0%, hsla(0,0%,95%,1) 55%, hsla(0,0%,90%,1) 100%)";
this.listenConj();
if (!this.sVerb) {
this.conjugateVerb("être");
}
}
showThesaurus () {
this.switchContentOff(this.xGCPanelContent, this.xEditorButton);
this.switchContentOff(this.xLxgPanelContent, this.xLxgButton);
this.switchContentOff(this.xConjPanelContent, this.xConjButton);
this.switchContentOn(this.xThesPanelContent, this.xThesButton);
this.xPanel.style.background = "";
this.listenThes();
}
switchContentOn (xContent, xNodeButton) {
xContent.style.display = "block";
xNodeButton.style.backgroundColor = "hsl(210, 60%, 40%)";
xNodeButton.style.textShadow = "2px 0 0 hsla(210, 40%, 35%, .5), -2px 0 0 hsla(210, 40%, 35%, .5), 0 2px 0 hsla(210, 40%, 35%, .5), 0 -2px 0 hsla(210, 40%, 35%, .5), 1px 1px hsla(210, 40%, 35%, .5), -1px -1px 0 hsla(210, 40%, 35%, .5), 1px -1px 0 hsla(210, 40%, 35%, .5), -1px 1px 0 hsla(210, 30%, 35%, .5)";
}
|
| ︙ | ︙ | |||
682 683 684 685 686 687 688 |
}
// Conjugueur
listenConj () {
if (!this.bListenConj) {
| < < | > > | < < | < < < < | | 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
}
// Conjugueur
listenConj () {
if (!this.bListenConj) {
// text field
this.xParent.getElementById('grammalecte_conj_verb').addEventListener("input", (e) => { this.conjugateVerb(); });
// erase button
this.xParent.getElementById('grammalecte_conj_erase_button').addEventListener("click", (e) => { this.clearConjInput(); });
// options
this.xParent.getElementById('grammalecte_conj_oneg').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_oneg'); this.updateConj(); });
this.xParent.getElementById('grammalecte_conj_opro').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_opro'); this.updateConj(); });
this.xParent.getElementById('grammalecte_conj_oint').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_oint'); this.updateConj(); });
this.xParent.getElementById('grammalecte_conj_ofem').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_ofem'); this.updateConj(); });
this.xParent.getElementById('grammalecte_conj_otco').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_otco'); this.updateConj(); });
this.bListenConj = true;
}
}
clearConjInput () {
this.xParent.getElementById('grammalecte_conj_verb').innerText = "";
this.xParent.getElementById('grammalecte_conj_verb').style = "";
}
switchOption (sOption) {
if (this.xParent.getElementById(sOption).dataset.disabled == "off") {
this.xParent.getElementById(sOption).dataset.selected = (this.xParent.getElementById(sOption).dataset.selected == "off") ? "on" : "off";
this.xParent.getElementById(sOption).className = (this.xParent.getElementById(sOption).dataset.selected == "on") ? "grammalecte_conj_option_on" : "grammalecte_conj_option_off";
}
|
| ︙ | ︙ | |||
743 744 745 746 747 748 749 |
disableOption (sOption) {
this.xParent.getElementById(sOption).dataset.disabled = "on";
this.xParent.getElementById(sOption).style.color = "#CCC";
}
conjugateVerb (sVerb="") {
try {
| < < < < > > > > > > > > > > | | < < > | 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 |
disableOption (sOption) {
this.xParent.getElementById(sOption).dataset.disabled = "on";
this.xParent.getElementById(sOption).style.color = "#CCC";
}
conjugateVerb (sVerb="") {
try {
this.resetOption('grammalecte_conj_oneg');
this.resetOption('grammalecte_conj_opro');
this.resetOption('grammalecte_conj_oint');
this.resetOption('grammalecte_conj_otco');
this.resetOption('grammalecte_conj_ofem');
// request analyzing
if (!sVerb) {
sVerb = this.xParent.getElementById('grammalecte_conj_verb').innerText;
if (sVerb.indexOf("\n") != -1) {
sVerb = this.purgeInputText(sVerb);
this.xParent.getElementById('grammalecte_conj_verb').textContent = sVerb;
} else {
sVerb = this.purgeInputText(sVerb);
}
}
sVerb = sVerb.trim().toLowerCase().replace(/’/g, "'").replace(/ +/g, " ");
if (sVerb) {
if (sVerb.startsWith("ne pas ")) {
this.selectOption('grammalecte_conj_oneg');
sVerb = sVerb.slice(7).trim();
}
if (sVerb.startsWith("se ")) {
this.selectOption('grammalecte_conj_opro');
sVerb = sVerb.slice(3).trim();
}
else if (sVerb.startsWith("s'")) {
this.selectOption('grammalecte_conj_opro');
sVerb = sVerb.slice(2).trim();
}
if (sVerb.endsWith("?")) {
this.selectOption('grammalecte_conj_oint');
sVerb = sVerb.slice(0,-1).trim();
}
if (sVerb) {
if (sVerb.search("(?:[ei]r|re)$")) {
this.sVerb = sVerb;
this.updateConj(true);
}
}
}
}
catch (e) {
showError(e);
}
}
|
| ︙ | ︙ | |||
917 918 919 920 921 922 923 924 925 926 927 928 929 930 |
this.xParent.getElementById('grammalecte_conj_simp5').textContent = oConjTable["simp5"] || " ";
this.xParent.getElementById('grammalecte_conj_simp6').textContent = oConjTable["simp6"] || " ";
}
catch (e) {
showError(e);
}
}
}
class GrammalecteTooltip {
constructor (xParent, xGCPanelContent) {
this.xParent = xParent;
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 |
this.xParent.getElementById('grammalecte_conj_simp5').textContent = oConjTable["simp5"] || " ";
this.xParent.getElementById('grammalecte_conj_simp6').textContent = oConjTable["simp6"] || " ";
}
catch (e) {
showError(e);
}
}
// Thesaurus
listenThes () {
if (!this.bListenThes) {
// text field
this.xParent.getElementById('grammalecte_thes_word').addEventListener("input", (e) => {
let sWord = this.xParent.getElementById('grammalecte_thes_word').innerText;
this.getSyns(sWord);
});
// erase button
this.xParent.getElementById('grammalecte_thes_erase_button').addEventListener("click", (e) => {
this.clearWordInput();
});
this.bListenThes = true;
}
}
clearWordInput () {
this.xParent.getElementById('grammalecte_thes_word').innerText = "";
this.xParent.getElementById('grammalecte_thes_word').style = "";
}
getSyns (sWord) {
sWord = sWord.trim();
oGrammalecteBackgroundPort.getSyns(sWord);
}
displaySyns (sWord, lSyns) {
try {
if (sWord) {
this.xParent.getElementById('grammalecte_thes_title').textContent = sWord;
this.emptySynList();
if (lSyns.length == 0) {
this.xParent.getElementById('grammalecte_thes_word').style = "color: #BB4411;";
this.xParent.getElementById('grammalecte_thes_word_info').style = "display: block";
} else {
this.xParent.getElementById('grammalecte_thes_word').style = "";
this.xParent.getElementById('grammalecte_thes_word_info').style = "display: none";
this.populateSynList(lSyns);
}
}
}
catch (e) {
console.error(e);
}
}
emptySynList () {
let xSynonymsList = this.xParent.getElementById('grammalecte_synonyms_list');
while (xSynonymsList.firstChild) {
xSynonymsList.removeChild(xSynonymsList.firstChild);
}
}
populateSynList (lSyns) {
let xSynonymsList = this.xParent.getElementById('grammalecte_synonyms_list');
for (let [sCat, lSyn] of lSyns) {
let xSynBlok = oGrammalecte.createNode("div", { className: "grammalecte_syn_block" });
xSynonymsList.appendChild(xSynBlok);
xSynBlok.appendChild(oGrammalecte.createNode("div", { className: "grammalecte_cat_name", textContent: sCat }));
let xSynonyms = oGrammalecte.createNode("div", { className: "grammalecte_synonyms" });
xSynBlok.appendChild(xSynonyms);
for (let sSyn of lSyn) {
xSynonyms.appendChild(oGrammalecte.createNode("div", { className: "grammalecte_synonym", textContent: sSyn }));
}
}
}
purgeInputText (sText) {
// Thunderbird doesn’t accept input fields
// So we use editable node and we purge it
let nIndexCut = sText.indexOf("\n");
if (nIndexCut != -1) {
sText = sText.slice(0, nIndexCut);
};
return sText.trim();
}
}
class GrammalecteTooltip {
constructor (xParent, xGCPanelContent) {
this.xParent = xParent;
|
| ︙ | ︙ |
Added gc_lang/fr/webext/content_scripts/panel_thes.css version [2197bd2acf].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 |
/*
CSS Document
*/
div#grammalecte_thes_panel_content {
padding: 20px 0;
width: 100%;
}
h1.grammalecte_thes_title {
margin: 5px 0 2px 0;
color: hsl(210, 50%, 50%);
font: bold 30px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif;
text-align: center;
}
div#grammalecte_thes_word_info {
text-align: center;
color: hsl(210, 00%, 40%);
}
div#grammalecte_thes_word {
display: inline-block;
width: 230px;
margin-left: 5px;
padding: 5px 10px;
border: 2px solid hsl(0, 0%, 80%);
border-radius: 3px;
height: 20px;
background: transparent;
font: normal 18px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif;
color: hsl(0, 0%, 50%);
}
div#grammalecte_thes_erase_button {
display: inline-block;
margin: 3px;
padding: 5px 10px;
font-weight: bold;
color: hsl(0, 0%, 100%);
background-color: hsl(0, 0%, 80%);
border-radius: 4px;
}
div#grammalecte_thes_erase_button:hover {
background-color: hsl(0, 50%, 50%);
cursor: pointer;
}
div#grammalecte_separator {
margin: 10px 20px;
font-size: 11px;
color: hsl(0, 0%, 60%);
text-align: center;
}
div.grammalecte_syn_block {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: flex-start;
}
div.grammalecte_cat_name {
flex: 0 0 15%;
padding: 9px;
}
div.grammalecte_synonyms {
padding: 5px;
}
div.grammalecte_synonym {
display: inline-block;
padding: 2px 5px;
background: hsl(210, 100%, 95%);
border-radius: 3px;
margin: 2px 3px;
cursor: pointer;
}
div.grammalecte_synonym:hover {
background: hsl(0, 100%, 95%);
}
|
Modified gc_lang/fr/webext/gce_worker.js from [2672ecfd48] to [946a071330].
| ︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
importScripts("grammalecte/graphspell/ibdawg.js");
importScripts("grammalecte/graphspell/spellchecker.js");
importScripts("grammalecte/text.js");
importScripts("grammalecte/graphspell/tokenizer.js");
importScripts("grammalecte/fr/conj.js");
importScripts("grammalecte/fr/mfsp.js");
importScripts("grammalecte/fr/phonet.js");
importScripts("grammalecte/fr/cregex.js");
importScripts("grammalecte/fr/gc_options.js");
importScripts("grammalecte/fr/gc_functions.js");
importScripts("grammalecte/fr/gc_rules.js");
importScripts("grammalecte/fr/gc_rules_graph.js");
importScripts("grammalecte/fr/gc_engine.js");
importScripts("grammalecte/tests.js");
| > | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
importScripts("grammalecte/graphspell/ibdawg.js");
importScripts("grammalecte/graphspell/spellchecker.js");
importScripts("grammalecte/text.js");
importScripts("grammalecte/graphspell/tokenizer.js");
importScripts("grammalecte/fr/conj.js");
importScripts("grammalecte/fr/mfsp.js");
importScripts("grammalecte/fr/phonet.js");
importScripts("grammalecte/fr/thesaurus.js");
importScripts("grammalecte/fr/cregex.js");
importScripts("grammalecte/fr/gc_options.js");
importScripts("grammalecte/fr/gc_functions.js");
importScripts("grammalecte/fr/gc_rules.js");
importScripts("grammalecte/fr/gc_rules_graph.js");
importScripts("grammalecte/fr/gc_engine.js");
importScripts("grammalecte/tests.js");
|
| ︙ | ︙ | |||
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
break;
case "getSpellSuggestions":
getSpellSuggestions(oParam.sWord, oInfo);
break;
case "getVerb":
getVerb(oParam.sVerb, oParam.bPro, oParam.bNeg, oParam.bTpsCo, oParam.bInt, oParam.bFem, oInfo);
break;
default:
console.log("[Worker] Unknown command: " + sCommand);
showData(e.data);
}
}
let bInitDone = false;
let oSpellChecker = null;
let oTokenizer = null;
let oTest = null;
let oLocution = null;
/*
Technical note:
| > > > | > | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
break;
case "getSpellSuggestions":
getSpellSuggestions(oParam.sWord, oInfo);
break;
case "getVerb":
getVerb(oParam.sVerb, oParam.bPro, oParam.bNeg, oParam.bTpsCo, oParam.bInt, oParam.bFem, oInfo);
break;
case "getSyns":
getSyns(oParam.sWord, oInfo);
break;
default:
console.log("[Worker] Unknown command: " + sCommand);
showData(e.data);
}
}
let bInitDone = false;
let oSpellChecker = null;
let oTokenizer = null;
let oTest = null;
let oLocution = null;
/*
Technical note:
This worker doesn’t work as a PromiseWorker (which returns a promise), so when we send request
to this worker, we can’t wait the return of the answer just after the request made.
The answer is received by the background in another function (onmessage).
That’s why the full text to analyze is send in one block, but analyse is returned paragraph
by paragraph.
*/
function init (sExtensionPath, dOptions=null, sContext="JavaScript", oInfo={}) {
try {
if (!bInitDone) {
//console.log("[Worker] Loading… Extension path: " + sExtensionPath);
conj.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/conj_data.json"));
phonet.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/phonet_data.json"));
mfsp.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/mfsp_data.json"));
thesaurus.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/thesaurus_data.json"));
//console.log("[Worker] Modules have been initialized…");
gc_engine.load(sContext, "aHSL", sExtensionPath+"grammalecte/graphspell/_dictionaries");
oSpellChecker = gc_engine.getSpellChecker();
oTest = new TestGrammarChecking(gc_engine, sExtensionPath+"/grammalecte/fr/tests_data.json");
oTokenizer = new Tokenizer("fr");
if (dOptions !== null) {
if (!(dOptions instanceof Map)) {
|
| ︙ | ︙ | |||
427 428 429 430 431 432 433 |
postMessage(createResponse("getVerb", { oVerb: oVerb, oConjTable: oConjTable }, oInfo, true));
}
catch (e) {
console.error(e);
postMessage(createResponse("getVerb", createErrorResult(e, "no verb"), oInfo, true, true));
}
}
| > > > > > > > > > > > > > > | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
postMessage(createResponse("getVerb", { oVerb: oVerb, oConjTable: oConjTable }, oInfo, true));
}
catch (e) {
console.error(e);
postMessage(createResponse("getVerb", createErrorResult(e, "no verb"), oInfo, true, true));
}
}
// Thesaurus
function getSyns (sWord, oInfo) {
try {
let lSyns = thesaurus.getSyns(sWord)
postMessage(createResponse("getSyns", { sWord: sWord, lSyns: lSyns }, oInfo, true));
}
catch (e) {
console.error(e);
postMessage(createResponse("getSyns", createErrorResult(e, "no synonyms"), oInfo, true, true));
}
}
|
Modified gc_lang/fr/webext/manifest.json from [4758eeb6d5] to [85be41d8bb].
| ︙ | ︙ | |||
87 88 89 90 91 92 93 94 |
"suggested_key": { "default": "Ctrl+Shift+F" },
"description": "Ouvre le correcteur grammatical"
},
"conjugueur_tab": {
"suggested_key": { "default": "Ctrl+Shift+6" },
"description": "Ouvre le conjugueur"
},
"lexicon_editor": {
| > > > > | > | 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 117 118 119 120 121 122 123 124 125 126 |
"suggested_key": { "default": "Ctrl+Shift+F" },
"description": "Ouvre le correcteur grammatical"
},
"conjugueur_tab": {
"suggested_key": { "default": "Ctrl+Shift+6" },
"description": "Ouvre le conjugueur"
},
"thesaurus_tab": {
"suggested_key": { "default": "Ctrl+Shift+7" },
"description": "Ouvre le thésaurus"
},
"lexicon_editor": {
"suggested_key": { "default": "Ctrl+Shift+8" },
"description": "Ouvre l’éditeur lexical"
}
},
"web_accessible_resources": [
"content_scripts/api.js",
"content_scripts/panel.css",
"content_scripts/panel_tf.css",
"content_scripts/panel_gc.css",
"content_scripts/panel_lxg.css",
"content_scripts/panel_conj.css",
"content_scripts/message_box.css",
"content_scripts/menu.css",
"grammalecte/graphspell/_dictionaries/fr-allvars.json",
"grammalecte/graphspell/_dictionaries/fr-classic.json",
"grammalecte/graphspell/_dictionaries/fr-reform.json",
"grammalecte/fr/conj_data.json",
"grammalecte/fr/mfsp_data.json",
"grammalecte/fr/phonet_data.json",
"grammalecte/fr/thesaurus_data.json",
"grammalecte/fr/tests_data.json",
"img/logo-16.png"
],
"permissions": [
"*://localhost/*",
"*://dic.grammalecte.net/*",
|
| ︙ | ︙ |
Modified gc_lang/fr/webext/panel/main.html from [f6a872dca8] to [84afbdf9be].
| ︙ | ︙ | |||
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
</div>
<h2>Raccourcis clavier</h2>
<p class="shortcut">CTRL+MAJ+F</p>
<p class="shortcut_label">Correcteur grammatical</p>
<p class="shortcut">CTRL+MAJ+6</p>
<p class="shortcut_label">Conjugueur</p>
<p class="shortcut">CTRL+MAJ+7</p>
<p class="shortcut_label">Éditeur lexical</p>
<!--<p class="shortcut">CTRL+MAJ+8</p>
<p class="shortcut_label">Dictionnaires communautaires</p>-->
</section> <!-- #ui_options_page -->
<section id="gc_options_page" class="page">
<h1>OPTIONS GRAMMATICALES</h1>
| > > | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
</div>
<h2>Raccourcis clavier</h2>
<p class="shortcut">CTRL+MAJ+F</p>
<p class="shortcut_label">Correcteur grammatical</p>
<p class="shortcut">CTRL+MAJ+6</p>
<p class="shortcut_label">Conjugueur</p>
<p class="shortcut">CTRL+MAJ+7</p>
<p class="shortcut_label">Dictionnaire des synonymes</p>
<p class="shortcut">CTRL+MAJ+8</p>
<p class="shortcut_label">Éditeur lexical</p>
<!--<p class="shortcut">CTRL+MAJ+8</p>
<p class="shortcut_label">Dictionnaires communautaires</p>-->
</section> <!-- #ui_options_page -->
<section id="gc_options_page" class="page">
<h1>OPTIONS GRAMMATICALES</h1>
|
| ︙ | ︙ |
Added gc_lang/fr/webext/panel/thesaurus.css version [dbe9525ab8].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 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 |
/*
CSS Document
White
Design par Olivier R.
*/
* { margin: 0; padding: 0; }
img { border: none; }
/* Generic classes */
.fleft {
float: left;
}
.fright {
float: right;
}
.center {
text-align: center;
}
.right {
text-align: right;
}
.left {
text-align: left;
}
.justify {
text-align: justify;
}
.hidden {
display: none;
}
.clearer {
clear: both;
font-size: 0;
height: 0;
}
body {
background: #FFFFFF url(../img/lines.png);
font: normal 16px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif;
color: #505050;
}
.mainflow {
width: 800px;
margin: 0 auto 0 auto;
}
.logo {
position: absolute;
background-color: #FFFFFF;
border: 3px solid #F0F0F0;
border-radius: 96px;
padding: 4px 4px 0 4px;
}
/* MAIN ====================================================================== */
#main .inbox {
width: 800px;
margin: 20px auto 10px auto;
padding: 10px 30px 30px 30px;
background: #FFFFFF;
border: 2px solid #F0F0F0;
border-radius: 20px;
}
#main h1 {
margin: 5px 0 2px 0;
color: hsl(210, 50%, 50%);
font: bold 30px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif;
}
#main .syn_block {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: flex-start;
}
.cat_name {
flex: 0 0 15%;
padding: 9px;
}
.synonyms {
padding: 5px;
}
.synonym {
display: inline-block;
padding: 2px 5px;
background: hsl(210, 100%, 95%);
border-radius: 3px;
margin: 2px 3px;
cursor: pointer;
}
.synonym:hover {
background: hsl(0, 100%, 95%);
}
/*.box {
border-left: 2px solid #8BC5EF;
border-bottom: 2px solid #8BC5EF;
border-radius: 5px;
padding: 0 0 2px 10px;
}*/
input#word {
display: inline-block;
width: 230px;
margin-left: 5px;
padding: 5px 10px;
border: 2px solid hsl(0, 0%, 80%);
border-radius: 3px;
height: 24px;
background: transparent;
font: normal 20px Tahoma, "Ubuntu Condensed";
color: hsl(0, 0%, 30%);
}
input[placeholder]#word {
color: hsl(0, 0%, 70%);
}
#fetch {
display: inline-block;
padding: 7px 10px;
font-size: 18px;
background-color: hsl(210, 30%, 50%);
color: hsl(210, 30%, 80%);
border-radius: 3px;
text-transform: uppercase;
text-align: center;
text-decoration: none;
cursor: pointer;
}
#fetch:hover {
background-color: hsl(210, 60%, 40%);
color: hsl(210, 60%, 90%);
box-shadow: 0 0 2px hsl(210, 60%, 50%);
}
#separator {
margin: 10px 0 10px 0;
font-size: 11px;
color: hsl(0, 0%, 60%);
text-align: center;
}
|
Added gc_lang/fr/webext/panel/thesaurus.html version [06fb33d6c8].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 |
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="thesaurus.css" />
<title>Grammalecte · Thesaurus</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<header>
<div class="mainflow">
<div class="logo" style="margin: -10px 0 0 0;">
<img src="../img/logo-96.png" alt="" />
</div>
</div>
</header>
<div id="main">
<div class="inbox">
<div class="right" style="margin: 10px 180px 0 0">
<input type="text" id="word" name="word" maxlength="40" value="" placeholder="entrez un mot" autofocus />
<div id="fetch">Synonymes</div>
</div>
<h1 id="word_title" class="center"> </h1>
<p id="info" class="center"> </p>
<p id="separator">❦</p>
<div id="synonyms_list">
</div>
</div>
</div>
<script src="../grammalecte/graphspell/helpers.js"></script>
<script src="../grammalecte/fr/thesaurus.js"></script>
<script src="thesaurus.js"></script>
</body>
</html>
|
Added gc_lang/fr/webext/panel/thesaurus.js version [51eb91646b].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 |
// JavaScript
"use strict";
// button
document.getElementById('fetch').addEventListener("click", function (event) {
showSynonymsOf(document.getElementById('word').value);
});
// text field
document.getElementById('word').addEventListener("change", function (event) {
showSynonymsOf(document.getElementById('word').value);
});
// click on synonyms
document.getElementById('synonyms_list').addEventListener("click", function (xEvent) {
let xElem = xEvent.target;
if (xElem.className == "synonym") {
showSynonymsOf(xElem.textContent);
}
});
function createNode (sType, oAttr, oDataset=null) {
try {
let xNode = document.createElement(sType);
Object.assign(xNode, oAttr);
if (oDataset) {
Object.assign(xNode.dataset, oDataset);
}
return xNode;
}
catch (e) {
showError(e);
}
}
function showSynonymsOf (sWord) {
try {
sWord = sWord.trim().toLowerCase().replace(/’/g, "'").replace(/ +/g, " ");
if (sWord) {
document.getElementById('word_title').textContent = sWord;
let lSyns = thesaurus.getSyns(sWord);
if (lSyns.length == 0) {
document.getElementById('word').style = "color: #BB4411;";
emptyList();
document.getElementById('synonyms_list').textContent = "Aucun synonyme trouvé.";
} else {
document.getElementById('word').style = "";
document.getElementById('word').value = "";
emptyList();
populateList(lSyns);
}
}
}
catch (e) {
console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}
}
function populateList (lSyns) {
let xSynonymsList = document.getElementById('synonyms_list');
for (let [sCat, lSyn] of lSyns) {
let xSynBlok = createNode("div", {className: "syn_block"});
xSynonymsList.appendChild(xSynBlok);
xSynBlok.appendChild(createNode("div", { className: "cat_name", textContent: sCat}));
let xSynonyms = createNode("div", { className: "synonyms" });
xSynBlok.appendChild(xSynonyms);
for (let sSyn of lSyn) {
xSynonyms.appendChild(createNode("div", { className: "synonym", textContent: sSyn }));
}
}
}
function emptyList () {
let xSynonymsList = document.getElementById('synonyms_list');
while (xSynonymsList.firstChild) {
xSynonymsList.removeChild(xSynonymsList.firstChild);
}
}
showSynonymsOf("être");
document.getElementById("word").focus();
|
Modified grammalecte-cli.py from [807abadcc4] to [4a72c6e607].
| ︙ | ︙ | |||
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 |
import re
import traceback
import grammalecte
import grammalecte.text as txt
import grammalecte.graphspell.str_transform as strt
from grammalecte.graphspell.echo import echo
_EXAMPLE = "Quoi ? Racontes ! Racontes-moi ! Bon sangg, parles ! Oui. Il y a des menteur partout. " \
"Je suit sidéré par la brutales arrogance de cette homme-là. Quelle salopard ! Un escrocs de la pire espece. " \
"Quant sera t’il châtiés pour ses mensonge ? Merde ! J’en aie marre."
_HELP = """
Analysis commands:
any_text grammar checking
?word1 [word2] ... words analysis
!word spelling suggestion
>word draw path of word in the word graph
=[filter1][=[filter2]] show entries which fit to filters (filter1 for word, filter2 for morphology)
≠word1 word2 [word3] ... show distance between words
$some_text show sentences and tokens of text
Other commands:
/help /h show this text
/lopt /lo list options
/lrules [pattern] /lr list rules
/o+ option1 [option2] ... activate grammar checking options
/o- option1 [option2] ... deactivate grammar checking options
| > > | 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 |
import re
import traceback
import grammalecte
import grammalecte.text as txt
import grammalecte.graphspell.str_transform as strt
from grammalecte.graphspell.echo import echo
import grammalecte.fr.thesaurus as thes
_EXAMPLE = "Quoi ? Racontes ! Racontes-moi ! Bon sangg, parles ! Oui. Il y a des menteur partout. " \
"Je suit sidéré par la brutales arrogance de cette homme-là. Quelle salopard ! Un escrocs de la pire espece. " \
"Quant sera t’il châtiés pour ses mensonge ? Merde ! J’en aie marre."
_HELP = """
Analysis commands:
any_text grammar checking
?word1 [word2] ... words analysis
!word spelling suggestion
>word draw path of word in the word graph
=[filter1][=[filter2]] show entries which fit to filters (filter1 for word, filter2 for morphology)
≠word1 word2 [word3] ... show distance between words
$some_text show sentences and tokens of text
#word1 [word2] ... get synonyms of words
Other commands:
/help /h show this text
/lopt /lo list options
/lrules [pattern] /lr list rules
/o+ option1 [option2] ... activate grammar checking options
/o- option1 [option2] ... deactivate grammar checking options
|
| ︙ | ︙ | |||
313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# distances calculation
lWords = sText[1:].split()
for s1, s2 in itertools.combinations(lWords, 2):
strt.showDistance(s1, s2)
if xArgs.debug:
strt.showDistance(strt.simplifyWord(s1), strt.simplifyWord(s2))
echo("")
elif sText.startswith("/o+ "):
oGrammarChecker.gce.setOptions({ opt:True for opt in sText[3:].strip().split() if opt in oGrammarChecker.gce.getOptions() })
echo("done")
elif sText.startswith("/o- "):
oGrammarChecker.gce.setOptions({ opt:False for opt in sText[3:].strip().split() if opt in oGrammarChecker.gce.getOptions() })
echo("done")
elif sText.startswith("/r- "):
| > > > > > > > > > > > | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# distances calculation
lWords = sText[1:].split()
for s1, s2 in itertools.combinations(lWords, 2):
strt.showDistance(s1, s2)
if xArgs.debug:
strt.showDistance(strt.simplifyWord(s1), strt.simplifyWord(s2))
echo("")
elif sText.startswith("#"):
# synonyms
lWords = sText[1:].split()
for sWord in lWords:
lSyns = thes.getSyns(sWord)
if lSyns:
echo(f"\n{sWord}")
for sCat, lSyn in lSyns:
echo(f"> {sCat} : " + " | ".join(lSyn))
else:
echo(f"\n{sWord}: pas de synonymes trouvés")
elif sText.startswith("/o+ "):
oGrammarChecker.gce.setOptions({ opt:True for opt in sText[3:].strip().split() if opt in oGrammarChecker.gce.getOptions() })
echo("done")
elif sText.startswith("/o- "):
oGrammarChecker.gce.setOptions({ opt:False for opt in sText[3:].strip().split() if opt in oGrammarChecker.gce.getOptions() })
echo("done")
elif sText.startswith("/r- "):
|
| ︙ | ︙ |
Modified graphspell-js/helpers.js from [3e56cf75fd] to [b2198e5e90].
| ︙ | ︙ | |||
19 20 21 22 23 24 25 |
},
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 {
| | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
},
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 {
if (typeof(process) !== 'undefined') {
//console.log('loadFile(disque): ' + spf);
let fs = require("fs");
return fs.readFileSync(spf, "utf8");
} else {
console.log("loadFile: " + spf);
let xRequest;
xRequest = new XMLHttpRequest();
|
| ︙ | ︙ |