<html>
<head>
  <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
  <script src="engine.io.js"></script>
</head>
<body>
<button id="single" onclick="single()">Single Image</button>
<button id="start" onclick="start()">Start Streaming</button>
<button id="stop" onclick="stop()">Stop Streaming</button>
<img id="myImg">

<script type="text/javascript">
  var interval;
  var socket = eio('ws://webcam-spybox:9000/');
  var img = $('#myImg');
  socket.on('open', function(){
    socket.on('message', function(data){
      img.src = 'data:image/png;base64,' + hexToBase64(data);
    });
    socket.on('close', function(){
      console.log('socket closed');
    });
  });

  function single(){
    socket.send('Image please!');
  }

  function start(){
    interval = setInterval(function(){
      socket.send('Image please!');
    },3000);
  };

  function stop(){
    clearInterval(interval);
  };

  function hexToBase64(str) {
    return btoa(String.fromCharCode.apply(null, str.replace( /\r|\n/g , "").replace( /([\da-fA-F]{2}) ?/g, "0x$1 ").replace(/ +$/, "").split(" ")));
  }

</script>

</body>
</html>
<html>
<head>
  <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
  <script src="engine.io.js"></script>
</head>
<body>
<button id="single" onclick="single()">Single Image</button>
<button id="start" onclick="start()">Start Streaming</button>
<button id="stop" onclick="stop()">Stop Streaming</button>
<img id="myImg">

<script type="text/javascript">
  var interval;
  var socket = eio('ws://webcam-spybox:9000/');
  var img = $('#myImg');
  socket.on('open', function(){
    socket.on('message', function(data){
      console.log(data)
      img.src = 'data:image/png;base64,' + hexToBase64(data);
    });
    socket.on('close', function(){
      console.log('socket closed');
    });
  });

  function single(){
    socket.send('Image please!');
  }

  function start(){
    interval = setInterval(function(){
      socket.send('Image please!');
    },3000);
  };

  function stop(){
    clearInterval(interval);
  };

  function hexToBase64(str) {
    return btoa(String.fromCharCode.apply(null, str.replace( /\r|\n/g , "").replace( /([\da-fA-F]{2}) ?/g, "0x$1 ").replace(/ +$/, "").split(" ")));
  }

</script>

</body>
</html>
Revert "just testing, remember to revert"
Revert "just testing, remember to revert"
