Index: doc/API_web.md ================================================================== --- doc/API_web.md +++ doc/API_web.md @@ -114,24 +114,24 @@ For the last event, `oResult` will be `null`. ### Get spelling suggestions - oGrammalecteAPI.getSpellingSuggestions(word, destination, error_identifier) + oGrammalecteAPI.getSpellingSuggestions(word, destination, request_identifier) Parameters: - word (string) - destination: node_id (string) -- error_identifier: a custom identifier (string) +- request_identifier: a custom identifier (string) [default = ""] Suggestions will be sent within an event at the node identified by `destination`. node.addEventListener("GrammalecteResult", function (event) { if (event.detail.sType && event.detail.sType == "spellsugg") { let oResult = event.detail.oResult; - let oInfo = event.detail.oInfo; // object containing the destination and the error_identifier + let oInfo = event.detail.oInfo; // object containing the destination and the request_identifier ... } } Index: gc_lang/fr/webext/content_scripts/api.js ================================================================== --- gc_lang/fr/webext/content_scripts/api.js +++ gc_lang/fr/webext/content_scripts/api.js @@ -71,19 +71,19 @@ else { console.log("[Grammalecte API] Error: parameter is not a HTML node or doesn’t have an identifier."); } }, - getSpellSuggestions: function (sWord, sDestination, sErrorId) { + getSpellSuggestions: function (sWord, sDestination, sRequestId="") { /* parameters: - sWord (string) - sDestination: HTML identifier (string) -> the result will be sent as an event “GrammalecteResult” to destination node - - sErrorId: identifier for the error (string) + - sRequestId: custom identifier for the request (string) [default = ""] */ - if (typeof(sWord) === "string" && typeof(sDestination) === "string" && typeof(sErrorId) === "string") { - let xEvent = new CustomEvent("GrammalecteCall", { detail: {sCommand: "getSpellSuggestions", sWord: sWord, sDestination: sDestination, sErrorId: sErrorId} }); + if (typeof(sWord) === "string" && typeof(sDestination) === "string" && typeof(sRequestId) === "string") { + let xEvent = new CustomEvent("GrammalecteCall", { detail: {sCommand: "getSpellSuggestions", sWord: sWord, sDestination: sDestination, sRequestId: sRequestId} }); document.dispatchEvent(xEvent); } else { console.log("[Grammalecte API] Error: one or several parameters aren’t string."); } } }