Index: gc_lang/fr/webext/background.js ================================================================== --- gc_lang/fr/webext/background.js +++ gc_lang/fr/webext/background.js @@ -39,10 +39,11 @@ storeGCOptions(result); break; case "parse": case "parseAndSpellcheck": case "parseAndSpellcheck1": + case "parseFull": case "getListOfTokens": case "getSpellSuggestions": case "getVerb": // send result to content script if (typeof(dInfo.iReturnPort) === "number") { @@ -200,10 +201,11 @@ /* Messages from the extension (not the Worker) */ function handleMessage (oRequest, xSender, sendResponse) { + // message from panels //console.log(xSender); let {sCommand, dParam, dInfo} = oRequest; switch (sCommand) { case "getOptions": case "getDefaultOptions": @@ -246,10 +248,11 @@ let {sCommand, dParam, dInfo} = oRequest; switch (sCommand) { case "parse": case "parseAndSpellcheck": case "parseAndSpellcheck1": + case "parseFull": case "getListOfTokens": case "getSpellSuggestions": case "getVerb": oRequest.dInfo.iReturnPort = iPortId; // we pass the id of the return port to receive answer xGCEWorker.postMessage(oRequest); Index: gc_lang/fr/webext/content_scripts/init.js ================================================================== --- gc_lang/fr/webext/content_scripts/init.js +++ gc_lang/fr/webext/content_scripts/init.js @@ -305,10 +305,13 @@ oGrammalecte.oGCPanel.stopWaitIcon(); } break; case "parseAndSpellcheck1": oGrammalecte.oGCPanel.refreshParagraph(dInfo.sParagraphId, result); + break; + case "parseFull": + // TODO break; case "getListOfTokens": if (!bEnd) { oGrammalecte.oGCPanel.addListOfTokens(result); } else { Index: gc_lang/fr/webext/content_scripts/panel_gc.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel_gc.js +++ gc_lang/fr/webext/content_scripts/panel_gc.js @@ -109,10 +109,15 @@ xGrammalectePort.postMessage({ sCommand: "getListOfTokens", dParam: {sText: this.oTextControl.getText()}, dInfo: ((this.xNode) ? {sTextAreaId: this.xNode.id} : {}) }); + xGrammalectePort.postMessage({ + sCommand: "parseFull", + dParam: {sText: this.oTextControl.getText(), sCountry: "FR", bDebug: false, bContext: false}, + dInfo: ((this.xNode) ? {sTextAreaId: this.xNode.id} : {}) + }); } }; this.xConjButton.onclick = () => { if (!this.bWorking) { this.showConjugueur(); Index: gc_lang/fr/webext/gce_worker.js ================================================================== --- gc_lang/fr/webext/gce_worker.js +++ gc_lang/fr/webext/gce_worker.js @@ -101,10 +101,16 @@ parseAndSpellcheck(dParam.sText, dParam.sCountry, dParam.bDebug, dParam.bContext, dInfo); break; case "parseAndSpellcheck1": parseAndSpellcheck1(dParam.sText, dParam.sCountry, dParam.bDebug, dParam.bContext, dInfo); break; + case "parseFull": + parseFull(dParam.sText, dParam.sCountry, dParam.bDebug, dParam.bContext, dInfo); + break; + case "getListOfTokens": + getListOfTokens(dParam.sText, dInfo); + break; case "getOptions": getOptions(dInfo); break; case "getDefaultOptions": getDefaultOptions(dInfo); @@ -134,13 +140,10 @@ getSpellSuggestions(dParam.sWord, dInfo); break; case "getVerb": getVerb(dParam.sVerb, dParam.bPro, dParam.bNeg, dParam.bTpsCo, dParam.bInt, dParam.bFem, dInfo); break; - case "getListOfTokens": - getListOfTokens(dParam.sText, dInfo); - break; default: console.log("[Worker] Unknown command: " + sCommand); showData(e.data); } } @@ -212,24 +215,53 @@ function parseAndSpellcheck (sText, sCountry, bDebug, bContext, dInfo={}) { let i = 0; sText = sText.replace(/­/g, "").normalize("NFC"); for (let sParagraph of text.getParagraph(sText)) { - let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, bContext); + let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, null, bContext); let aSpellErr = oSpellChecker.parseParagraph(sParagraph); postMessage(createResponse("parseAndSpellcheck", {sParagraph: sParagraph, iParaNum: i, aGrammErr: aGrammErr, aSpellErr: aSpellErr}, dInfo, false)); i += 1; } postMessage(createResponse("parseAndSpellcheck", null, dInfo, true)); } function parseAndSpellcheck1 (sParagraph, sCountry, bDebug, bContext, dInfo={}) { sParagraph = sParagraph.replace(/­/g, "").normalize("NFC"); - let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, bContext); + let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, null, bContext); let aSpellErr = oSpellChecker.parseParagraph(sParagraph); postMessage(createResponse("parseAndSpellcheck1", {sParagraph: sParagraph, aGrammErr: aGrammErr, aSpellErr: aSpellErr}, dInfo, true)); } + +function parseFull (sText, sCountry, bDebug, bContext, dInfo={}) { + let i = 0; + sText = sText.replace(/­/g, "").normalize("NFC"); + for (let sParagraph of text.getParagraph(sText)) { + let lSentence = gc_engine.parse(sParagraph, sCountry, bDebug, null, bContext, true); + console.log("*", lSentence); + postMessage(createResponse("parseFull", {sParagraph: sParagraph, iParaNum: i, lSentence: lSentence}, dInfo, false)); + i += 1; + } + postMessage(createResponse("parseFull", null, dInfo, true)); +} + +function getListOfTokens (sText, dInfo={}) { + // lexicographer + try { + sText = sText.replace(/­/g, "").normalize("NFC"); + for (let sParagraph of text.getParagraph(sText)) { + if (sParagraph.trim() !== "") { + postMessage(createResponse("getListOfTokens", oLxg.getListOfTokensReduc(sParagraph, true), dInfo, false)); + } + } + postMessage(createResponse("getListOfTokens", null, dInfo, true)); + } + catch (e) { + console.error(e); + postMessage(createResponse("getListOfTokens", createErrorResult(e, "no tokens"), dInfo, true, true)); + } +} function getOptions (dInfo={}) { let dOptions = helpers.mapToObject(gc_engine.getOptions()); postMessage(createResponse("getOptions", dOptions, dInfo, true)); } @@ -392,24 +424,5 @@ catch (e) { console.error(e); postMessage(createResponse("getVerb", createErrorResult(e, "no verb"), dInfo, true, true)); } } - - -// Lexicographer - -function getListOfTokens (sText, dInfo={}) { - try { - sText = sText.replace(/­/g, "").normalize("NFC"); - for (let sParagraph of text.getParagraph(sText)) { - if (sParagraph.trim() !== "") { - postMessage(createResponse("getListOfTokens", oLxg.getListOfTokensReduc(sParagraph, true), dInfo, false)); - } - } - postMessage(createResponse("getListOfTokens", null, dInfo, true)); - } - catch (e) { - console.error(e); - postMessage(createResponse("getListOfTokens", createErrorResult(e, "no tokens"), dInfo, true, true)); - } -}