<commit_before>// Variables
var $chat = $('.chat');
var $messages = $('.messages');
var $input = $('.input');

// SocketIO
var socket = io();
var connected = false;

// Bar Variables
var ctx1, startingAccData, accChart, latestAccLabel;
var ctx2, startingGyroData, gyroChart, latestGyroLabel;
initAccChart();
initGyroChart();

// Send message and emit 'message'
function sendMessage() {
  var msg = $input.val();
  if (msg && connected) {
    $input.val('');
    $messages.append('<li>' + msg + '</li>');
    socket.emit('message', msg);
  }
}

// Attach listener to Submit button
$('.submitMessage').click(function() {
  sendMessage();
});

// Render any messages from conversation stored on server upon connection
socket.on('connection', function(data) {
  connected = true;
  data.messages.forEach(function(message) {
    $messages.append('<li>' + message + '</li>');
  });
  socket.emit('joined');
});

// Tell clients when someone connects
socket.on('joined', function(msg) {
  $messages.append('<li>' + msg.message + '</li>');
  window.addEventListener("devicemotion", function(e) {
    console.log(e.acceleration.x);
  });
});

// Add message to chat
socket.on('message', function(msg) {
  $messages.append('<li>' + msg.message + '</li>');
});

// Phone data
if (window.DeviceMotionEvent) {
  window.addEventListener('devicemotion', function(data) {
    var acceleration = data.accelerationIncludingGravity;
    var gyro = data.rotationRate;
    var d = {
      accelerometer: acceleration,
      gyro: gyro
    }
    console.log(data.accelerationIncludingGravity.x);
    socket.emit('phone', d);
  }, false);
}

socket.on('phone', function(data) {
  // Acc data
  $('#x').text('X: ' + Math.round(data.accelerometer.x * 100)/100);
  $('#y').text('Y: ' + Math.round(data.accelerometer.y * 100)/100);
  $('#z').text('Z: ' + Math.round(data.accelerometer.z * 100)/100);
  // Gyro data
  $('#a').text('Alpha: ' + Math.round(data.gyro.alpha * 100)/100);
  $('#b').text('Beta: ' + Math.round(data.gyro.beta * 100)/100);
  $('#g').text('Gamma: ' + Math.round(data.gyro.gamma * 100)/100);
  
  // Remove old data and add new data
  accChart.data.datasets[0].data.shift();
  accChart.data.datasets[1].data.shift();
  accChart.data.datasets[2].data.shift();
  accChart.data.datasets[0].data.push(data.accelerometer.x);
  accChart.data.datasets[1].data.push(data.accelerometer.y);
  accChart.data.datasets[2].data.push(data.accelerometer.z);
  accChart.update();
  
  gyroChart.data.datasets[0].data.shift();<commit_msg>Code rebase commits.<commit_after>// Variables
var $chat = $('.chat');
var $messages = $('.messages');
var $input = $('.input');

// SocketIO
var socket = io();
var connected = false;

// Bar Variables
var ctx1, startingAccData, accChart, latestAccLabel;
var ctx2, startingGyroData, gyroChart, latestGyroLabel;
initAccChart();
initGyroChart();

// Send message and emit 'message'
function sendMessage() {
  var msg = $input.val();
  if (msg && connected) {
    $input.val('');
    $messages.append('<li>' + msg + '</li>');
    socket.emit('message', msg);
  }
}

// Attach listener to Submit button
$('.submitMessage').click(function() {
  sendMessage();
});

// Render any messages from conversation stored on server upon connection
socket.on('connection', function(data) {
  connected = true;
  data.messages.forEach(function(message) {
    $messages.append('<li>' + message + '</li>');
  });
  socket.emit('joined');
});

// Tell clients when someone connects
socket.on('joined', function(msg) {
  $messages.append('<li>' + msg.message + '</li>');
  window.addEventListener("devicemotion", function(e) {
    console.log(e.acceleration.x);
  });
});

// Add message to chat
socket.on('message', function(msg) {
  $messages.append('<li>' + msg.message + '</li>');
});

// Phone data
if (window.DeviceMotionEvent) {
  window.addEventListener('devicemotion', function(data) {
    var acceleration = data.accelerationIncludingGravity;
    var gyro = data.rotationRate;
    var d = {
      accelerometer: acceleration,
      gyro: gyro
    };
    socket.emit('phone', d);
  }, false);
}

socket.on('phone', function(data) {
  // Acc data
  $('#x').text('X: ' + Math.round(data.accelerometer.x * 100)/100);
  $('#y').text('Y: ' + Math.round(data.accelerometer.y * 100)/100);
  $('#z').text('Z: ' + Math.round(data.accelerometer.z * 100)/100);
  // Gyro data
  $('#a').text('Alpha: ' + Math.round(data.gyro.alpha * 100)/100);
  $('#b').text('Beta: ' + Math.round(data.gyro.beta * 100)/100);
  $('#g').text('Gamma: ' + Math.round(data.gyro.gamma * 100)/100);
  
  // Remove old data and add new data
  accChart.data.datasets[0].data.shift();
  accChart.data.datasets[1].data.shift();
  accChart.data.datasets[2].data.shift();
  accChart.data.datasets[0].data.push(data.accelerometer.x);
  accChart.data.datasets[1].data.push(data.accelerometer.y);
  accChart.data.datasets[2].data.push(data.accelerometer.z);
  accChart.update();
  
  gyroChart.data.datasets[0].data.shift();
{'fraction_non_alphanumeric': 0.20184590690208667, 'fraction_numerical': 0.018057784911717497, 'mean_word_length': 4.118069815195072, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '711984', 'n_tokens_mistral': 1789, 'n_tokens_neox': 1694, 'n_words': 320}