Grammalecte  Check-in [99c62fdd3b]

Overview
Comment:[fx][doc] Web API update
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | doc | fx
Files: files | file ages | folders
SHA3-256: 99c62fdd3bfbd3310a28b6a21429ea23815c832e633ebab90fe03d1c95a09860
User & Date: olr on 2020-03-19 08:42:53
Other Links: manifest | tags
Context
2020-03-19
13:59
[fr] ajustements check-in: ded2a889d7 user: olr tags: trunk, fr
08:42
[fx][doc] Web API update check-in: 99c62fdd3b user: olr tags: trunk, doc, fx
08:31
[doc] Web API update check-in: 2d88924e57 user: olr tags: trunk, doc
Changes

Modified doc/API_web.md from [6481a45de5] to [b8843fe5b2].

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
    }

For the last event, `oResult` will be `null`.


### Get spelling suggestions

    oGrammalecteAPI.getSpellingSuggestions(word, destination, error_identifier)

Parameters:

- word (string)

- destination: node_id (string)

- error_identifier: a custom identifier (string)

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
            ...
        }
    }







|







|






|



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
    }

For the last event, `oResult` will be `null`.


### Get spelling suggestions

    oGrammalecteAPI.getSpellingSuggestions(word, destination, request_identifier)

Parameters:

- word (string)

- destination: node_id (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 request_identifier
            ...
        }
    }

Modified gc_lang/fr/webext/content_scripts/api.js from [938cca0bac] to [8cd25765a3].

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
            document.dispatchEvent(xEvent);
        }
        else {
            console.log("[Grammalecte API] Error: parameter is not a HTML node or doesn’t have an identifier.");
        }
    },

    getSpellSuggestions: function (sWord, sDestination, sErrorId) {
        /* 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)
        */
        if (typeof(sWord) === "string"  &&  typeof(sDestination) === "string"  &&  typeof(sErrorId) === "string") {
            let xEvent = new CustomEvent("GrammalecteCall", { detail: {sCommand: "getSpellSuggestions", sWord: sWord, sDestination: sDestination, sErrorId: sErrorId} });
            document.dispatchEvent(xEvent);
        } else {
            console.log("[Grammalecte API] Error: one or several parameters aren’t string.");
        }
    }
}







|



|

|
|






69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
            document.dispatchEvent(xEvent);
        }
        else {
            console.log("[Grammalecte API] Error: parameter is not a HTML node or doesn’t have an identifier.");
        }
    },

    getSpellSuggestions: function (sWord, sDestination, sRequestId="") {
        /* parameters:
            - sWord (string)
            - sDestination: HTML identifier (string) -> the result will be sent as an event “GrammalecteResult” to destination node
            - sRequestId: custom identifier for the request (string) [default = ""]
        */
        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.");
        }
    }
}