Events
At some moments you might need some data related to the tool's use, like number of openings, translation, whether the tool is loades, among others. For that, you must listen to the events triggered by HT, just like the quoted example.
The events triggered by HT are:
| Event | Description | Return |
|---|---|---|
| coreReady | Avatar loaded | true |
| activated | Text Translator was activated | undefined |
| deactivated | Text Translator was deactivated | undefined |
| signalized | Triggers when the text is full signalized | undefined |
| errorOnAuth | Authentication error | string: mensagem referente ao erro ocorrido |
| errorOnTranslate | Error while translating the text in the Hand Talk's server | undefined |
| notCompatible | Browser or hardware not compatible | string: 'withoutCanvas' ou 'withoutWebGL' |
Example of the Event Listener
Javascript
// Listens to the signalized event
ht.on('signalized', function () {
console.log('New translated phrase!');
});
HTML
<body>
<!-- Takes the latest version of the Hand Talk Plugin. -->
<script src="https://plugin.handtalk.me/web/latest/handtalk.min.js"></script>
<script>
var ht = new HT({
// Change it to your access token
token: 'TOKEN'
});
// Listens to the signalized event
ht.on('signalized', function () {
console.log('New translated phrase!');
});
</script>
</body>