<commit_before>'use strict'


var startOrJoinVideo = function(seat, $scope){

  var table = $scope.hangouts[seat.tableNumber];


  if (table.users === 0){

    table.users++;

    bootbox.alert("Creating a video group chat!");
    $(".modal-backdrop").css("z-index", "0");

    $scope.$apply(function(){
      console.log('SEAT', seat, table);
      $scope.currentURL = table.url;
      $scope.currentSeat = seat.tableNumber + ' - ' + seat.seatNumber;
    });

    //call function to start video and store link to it here

    fbHangouts.set($scope.hangouts);

  }else{

    bootbox.alert('Joining a video chat!');
    $(".modal-backdrop").css("z-index", "0");

    $scope.$apply(function(){
      console.log('SEAT', seat, table);
      $scope.currentURL = table.url;
      $scope.currentSeat = seat.tableNumber + ' - ' + seat.seatNumber;
    });

    //call function to join video here

    fbHangouts.set($scope.hangouts);

  }

};

var handleClick = function(seat, $event, $scope) {

  $event.preventDefault();

  console.log('SEAT', seat);

  if (!$scope.satDown){

    if (!seat.taken){

      $scope.currentSeat = seat.seatNumber;

      seat.name = userName;
      seat.taken = true;
      $scope.satDown = true;

      fbSeating.set($scope.seats);

      startOrJoinVideo(seat, $scope)

    }else{

      bootbox.alert("Seat already occupied");
      $(".modal-backdrop").css("z-index", "0");

    }

  }else{

    if (seat.name === userName){

      seat.name = 'empty';
      seat.taken = false;
      $scope.satDown = false;

      $scope.currentSeat = "standing";
      $scope.currentURL = "No current hangout url";

      fbSeating.set($scope.seats);

      var table = $scope.hangouts[seat.tableNumber];

      table.users--;

      $scope.currentSeat = 'Standing'

    }

  }

};

var clearRoom = function(){
  console.log('clearing')

  var hangouts = {
    "table1" : {
      "users": 0,
      "message": 0,
      "url": 0
    },
    "table2" : {
      "users": 0,
      "message": 0,
      "url": 0
    },
    "table3" : {
      "users": 0,
      "message": 0,
      "url": 0
    },
    "table4" : {
      "users": 0,
      "message": 0,
      "url": 0
    }<commit_msg>This fixes minor bug that sometimes displayed the current seat incorrectly<commit_after>'use strict'


var startOrJoinVideo = function(seat, $scope){

  var table = $scope.hangouts[seat.tableNumber];


  if (table.users === 0){

    table.users++;

    bootbox.alert("Creating a video group chat!");
    $(".modal-backdrop").css("z-index", "0");

    $scope.$apply(function(){
      console.log('SEAT', seat, table);
      $scope.currentURL = table.url;
      $scope.currentSeat = seat.tableNumber + ' - ' + seat.seatNumber;
    });

    //call function to start video and store link to it here

    fbHangouts.set($scope.hangouts);

  }else{

    bootbox.alert('Joining a video chat!');
    $(".modal-backdrop").css("z-index", "0");

    $scope.$apply(function(){
      console.log('SEAT', seat, table);
      $scope.currentURL = table.url;
      $scope.currentSeat = seat.tableNumber + ' - ' + seat.seatNumber;
    });

    //call function to join video here

    fbHangouts.set($scope.hangouts);

  }

};

var handleClick = function(seat, $event, $scope) {

  $event.preventDefault();

  console.log('SEAT', seat);

  if (!$scope.satDown){

    if (!seat.taken){

      $scope.currentSeat = seat.seatNumber;

      seat.name = userName;
      seat.taken = true;
      $scope.satDown = true;

      fbSeating.set($scope.seats);

      startOrJoinVideo(seat, $scope)

    }else{

      bootbox.alert("Seat already occupied");
      $(".modal-backdrop").css("z-index", "0");

    }

  }else{

    if (seat.name === userName){

      seat.name = 'empty';
      seat.taken = false;
      $scope.satDown = false;

      $scope.currentSeat = "standing";
      $scope.currentURL = "No current hangout url";

      fbSeating.set($scope.seats);

      var table = $scope.hangouts[seat.tableNumber];

      table.users--;

      $scope.currentSeat = 'Standing'

    }else{

      bootbox.alert("You're already sat down");
      $(".modal-backdrop").css("z-index", "0");

    }

  }

};

var clearRoom = function(){
  console.log('clearing')

  var hangouts = {
    "table1" : {
      "users": 0,
      "message": 0,
      "url": 0
    },
    "table2" : {
      "users": 0,
      "message": 0,
      "url": 0
    },
    "table3" : {
      "users": 0,
      "message": 0,
      "url": 0
    },
    "table4" : {
      "users": 0,
      "message": 0,
      "url": 0
    }
{'fraction_non_alphanumeric': 0.17502198768689534, 'fraction_numerical': 0.00901495162708883, 'mean_word_length': 2.387192851824274, 'pattern_counts': {'":': 24, '<': 3, '<?xml version=': 0, '>': 3, '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': '6979574', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1513, 'n_words': 319}