Index: gc_core/js/helpers.js ================================================================== --- gc_core/js/helpers.js +++ gc_core/js/helpers.js @@ -5,24 +5,24 @@ // 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. let funcOutput = null; -function setLogOutput (func) { +export function setLogOutput (func) { funcOutput = func; } -function echo (obj) { +export function echo (obj) { if (funcOutput !== null) { funcOutput(obj); } else { console.log(obj); } return true; } -function logerror (e, bStack=false) { +export function logerror (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) { @@ -34,11 +34,11 @@ // 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 -function loadFile (spf) { +export function loadFile (spf) { try { let xRequest; if (typeof XMLHttpRequest !== "undefined") { xRequest = new XMLHttpRequest(); } @@ -56,33 +56,23 @@ logerror(e); return null } } - - - // conversions -function objectToMap (obj) { +export function objectToMap (obj) { let m = new Map(); for (let param in obj) { //console.log(param + " " + obj[param]); m.set(param, obj[param]); } return m; } -function mapToObject (m) { +export function mapToObject (m) { let obj = {}; for (let [k, v] of m) { obj[k] = v; } return obj; } - -exports.echo = echo; -exports.logerror = logerror; -exports.objectToMap = objectToMap; -exports.mapToObject = mapToObject; -exports.setLogOutput = setLogOutput; -exports.loadFile = loadFile; ADDED gc_lang/fr/oxt/_img/Algoo_logo.png Index: gc_lang/fr/oxt/_img/Algoo_logo.png ================================================================== --- /dev/null +++ gc_lang/fr/oxt/_img/Algoo_logo.png cannot compute difference between binary files ADDED gc_lang/fr/oxt/_img/logo120_text.png Index: gc_lang/fr/oxt/_img/logo120_text.png ================================================================== --- /dev/null +++ gc_lang/fr/oxt/_img/logo120_text.png cannot compute difference between binary files ADDED gc_lang/fr/tb/skin/Algoo_logo.png Index: gc_lang/fr/tb/skin/Algoo_logo.png ================================================================== --- /dev/null +++ gc_lang/fr/tb/skin/Algoo_logo.png cannot compute difference between binary files Index: gc_lang/fr/webext/content_scripts/modify_page.js ================================================================== --- gc_lang/fr/webext/content_scripts/modify_page.js +++ gc_lang/fr/webext/content_scripts/modify_page.js @@ -1,11 +1,14 @@ +import { echo } from "../mymodule"; + +echo("CONTENT SCRIPRT!!!"); -function do_something (request, sender, sendResponse) { - //removeEverything(); +function handleMessage2 (oRequest, xSender, sendResponse) { + console.log(`[Content script] received: ${oRequest.content}`); change(request.myparam); - console.log("DONE!!"); - browser.runtime.onMessage.removeListener(do_something); + //browser.runtime.onMessage.removeListener(handleMessage); + sendResponse({response: "response from content script"}); } function removeEverything () { while (document.body.firstChild) { document.body.firstChild.remove(); @@ -20,6 +23,6 @@ /* Assign do_something() as a listener for messages from the extension. */ -browser.runtime.onMessage.addListener(do_something); +browser.runtime.onMessage.addListener(handleMessage2); Index: gc_lang/fr/webext/gce_worker.js ================================================================== --- gc_lang/fr/webext/gce_worker.js +++ gc_lang/fr/webext/gce_worker.js @@ -1,8 +1,16 @@ -// Background script -// for calling the grammar checker engine +/* +import { echo } from "mymodule"; +try { + echo("It works! At last!"); +} +catch (e) { + console.error(e); +} +*/ +"use strict"; let gce = null; // module: grammar checker engine let text = null; let tkz = null; // module: tokenizer let lxg = null; // module: lexicographer @@ -111,10 +119,17 @@ return JSON.stringify([]); } function handleMessage (oRequest, xSender, sendResponse) { - console.log(`content script sent a message: ${oRequest.content}`); + console.log(`[background] received: ${oRequest.content}`); sendResponse({response: "response from background script"}); } browser.runtime.onMessage.addListener(handleMessage); + +try { + loadGrammarChecker(); +} +catch (e) { + console.error(e); +} Index: gc_lang/fr/webext/panel/main.js ================================================================== --- gc_lang/fr/webext/panel/main.js +++ gc_lang/fr/webext/panel/main.js @@ -55,15 +55,15 @@ showError(e); } } function handleResponse(message) { - console.log(`background script sent a response: ${message.response}`); + console.log(`[Panel] received: ${message.response}`); } function handleError(error) { - console.log(`Error: ${error}`); + console.log(`[Panel] Error: ${error}`); } function sendMessage (sMessage) { let sending = browser.runtime.sendMessage({content: sMessage}); sending.then(handleResponse, handleError); ADDED gc_lang/fr/xpi/data/img/Algoo_logo.png Index: gc_lang/fr/xpi/data/img/Algoo_logo.png ================================================================== --- /dev/null +++ gc_lang/fr/xpi/data/img/Algoo_logo.png cannot compute difference between binary files