gradio/examples/js/textbox-output.js
2019-02-19 22:21:00 -08:00

37 lines
710 B
JavaScript

function notifyError(error) {
$.notify({
// options
message: 'Not able to communicate with model (is python code still running?)'
},{
// settings
type: 'danger',
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
placement: {
from: "bottom",
align: "right"
},
delay: 5000
});
}
try {
ws.onerror = function(evt) {
notifyError(evt)
};
ws.onmessage = function (event) {
console.log(event.data);
sleep(300).then(() => {
$("#textbox-output").val(event.data);
})
}
} catch (e) {
notifyError(e)
}