Code viewer for World: Button Count (websocket test)

// Cloned by Stephen Walsh on 17 Feb 2023 from World "One Cube World (Three.js)" by Starter user 
// Please leave this clone trail here.
 

// default body is margin 0 and padding 0 

  $('body').css( "margin", "20px" );
  $('body').css( "padding", "20px" );

document.write(`
  <h1>Test</h1>
  <p>Button has been clicked <span id="count">0</span> times</p>
  <button onclick="addOne();" class="ab-largenormbutton" style="
    position: absolute; z-index: 999;">Press</button>
`);

AB.socketStart();

let count = 0;

function addOne(event) {
  count++;
  // console.log(`Button has been clicked ${count} times`);
  document.getElementById("count").textContent = count;
  send(count);
}

// const button = document.querySelector('.ab-largenormbutton');
// button.addEventListener('click', addOne);

function send(num) {
  var data = {
    counter: num
  };

  data.count = count
  console.log(count)
  
  AB.socketOut (data);
}

AB.socketIn = function(data)
{
    data.count += count
    document.getElementById("count").textContent = data.count;
};


// AB.socketIn = (data) => {
//   if (!isNaN(data.count)) {
//     data.count += count
//     document.getElementById("count").textContent = data.count;
//   }
// };