- addMessage("Connected.");
- };
-
- ws.onmessage = function (evt) {
- var received_msg = JSON.parse(evt.data);
-
- if (typeof received_msg.text != 'undefined') {
- console.log(received_msg);
-
- message_text = received_msg.text.trim();
- // use argos translate text result if received
- if (typeof received_msg.txt_translation != 'undefined' && received_msg.txt_translation.trim() !== '') {
- message_text = received_msg.txt_translation.trim();
- }
-
- addMessage("<sup>["+received_msg.language+"]</sup> " + message_text);
- document.querySelector('#live-data').textContent = "";
- }
-
- // update live translation text
- if (typeof received_msg.type != 'undefined' && received_msg.type === "processing_data") {