Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var aaa = "0"; // Eu recebo essa variável como string (não dá para mudar o tipo)
- console.log(typeof(aaa)); // String
- console.log(Number(aaa)); // NaN ===> Não deveria ser número 0?
- console.log(parseInt(aaa)); // NaN ===> Não deveria ser número 0?
- // Isso sempre dá FALSE
- aaa = "1";
- if (aaa)
- console.log('true');
- else
- console.log('false');
- // Isso sempre dá FALSE também
- aaa = "1";
- if (Number(aaa))
- console.log('true');
- else
- console.log('false');
- <head>
- <title>TESTE</title>
- <link rel="stylesheet" href="/stylesheets/style.css">
- <link rel="stylesheet" href="/stylesheets/bootstrap.min.css">
- <script src="/socket.io/socket.io.js"> </script>
- <script>
- var socket = io.connect();
- function changeState(state) {
- if (state == 1) {
- socket.emit('changeState', '{"state":1}');
- document.getElementById("outputStatus").innerHTML = "Status: ON";
- } else {
- socket.emit('changeState', '{"state":0}');
- document.getElementById("outputStatus").innerHTML = "Status: OFF";
- }
- }
- socket.on('sensorsUpdate', function (data) {
- var reading = JSON.parse(data);
- document.getElementById("IO_opened").innerHTML = reading.IO_opened;
- document.getElementById("IO_closed").innerHTML = reading.IO_closed;
- if (reading.IO_opened {
- console.log('ABRIR');
- document.getElementById("IO_opened").className = "exibe";
- document.getElementById("IO_closed").className = "n_exibe";
- } else if (reading.IO_closed) {
- console.log('FECHAR');
- document.getElementById("IO_opened").className = "n_exibe";
- document.getElementById("IO_closed").className = "exibe";
- } else {
- console.log('Open = ' + reading.IO_opened + ' Close = ' + reading.IO_closed);
- document.getElementById("IO_opened").className = "n_exibe";
- document.getElementById("IO_closed").className = "n_exibe";
- }
- });
- </script>
- </head>
- head
- title= title
- link(rel='stylesheet', href='/stylesheets/style.css')
- link(rel='stylesheet', href='/stylesheets/bootstrap.min.css')
- script(src='/socket.io/socket.io.js')
- include ../public/javascripts/sensorStatus.js //<<<<<====== Include do javascript
- body
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement