Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>birl</title>
- </head>
- <body>
- <p id="saida"></p>
- <textarea id="textArea">
- JAULA SHOW
- CE QUER VER ISSO: "BIRL PORRA!"
- SAINDO DA JAULA
- </textarea>
- <button id="enviar">Enviar</button>
- <script type="text/javascript">
- window.addEventListener('load', function() {
- var txtArea = document.getElementById('textArea');
- var webSocket = new WebSocket('ws://127.0.0.1:8080');
- var ultimoCodigo = "";
- webSocket.addEventListener('open', function() {
- console.log('conectado');
- });
- webSocket.addEventListener('message', function(msg) {
- var json = JSON.parse(msg.data);
- document.getElementById('saida').innerHTML = json['output'];
- });
- document.getElementById('enviar').addEventListener('click', function() {
- if (textArea.value != ultimoCodigo) {
- var json = {
- codigo : txtArea.value
- };
- webSocket.send(JSON.stringify(json));
- ultimoCodigo = json.codigo;
- }
- });
- })
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement