<commit_before>$(document).ready(function() {
// static stuff
var ref = new Firebase("***firebase-url***");
var socket = io();
var canPost = true;
var authData;

var msgbox = $("#message");

$('.helpButton').click(function() {
  $('.about-box').fadeIn(function() {
    $('.close-button').click(function() {
      $('.about-box').fadeOut()
    });
  })
});

function showMessage(msg, user, tags, imageLink) {
  msg = emojione.toImage(msg);

  var messageElement;
  if (user == 'RubyBot') {
    messageElement = $('<li class="bot-msg">').html('<a href="http://yrs.io" target="_blank">' + user + '</a>' + ': ' + msg);

  } else if (user == 'Server') {
    messageElement = $('<li class="server-msg">').html('<a href="http://yrs.io" target="_blank">' + user + '</a>' + ': ' + msg);

  } else {

    if (!imageLink || imageLink == ''){
      messageElement = $('<li>').html(
        '<a href="https://twitter.com/'+ user +'" target="_blank"></a>' +
        '<div class="message">' +
        '<a class="twitter-link" href="https://twitter.com/'+ user +'" target="_blank">@' + user + '</a><span class="label label-' + tags + '">' + tags + '</span>' +
        '<p class="msg">' + msg + '</p></div>'
      );
    } else {
      messageElement = $('<li>').html(
        '<a href="https://twitter.com/'+ user +'" target="_blank"><img class="profileImage" src="' + imageLink + '"/></a>' +
        '<div class="message">' +
        '<a class="twitter-link" href="https://twitter.com/'+ user +'" target="_blank">@' + user + '</a><span class="label label-' + tags + '">' + tags + '</span>' +
        '<p class="msg">' + msg + '</p></div>'
      );
    }
  }
  messageElement.linkify({
    target: "_blank"
  });
  $('#messages').append(messageElement).animate({scrollTop: 1000000}, "slow");

  if (document.hasFocus() == false){
    var audio = new Audio('/assets/sound/pop.ogg');
    audio.play();
  }
}


// firebase stuff
ref.onAuth(function(data) {
  authData = data;
  if (!data){
    $('.twitter').css("display", "block")
  } else {
    socket.emit("user join", data.token, data.twitter.username, data.twitter.profileImageURL);
  }
});

$('#twitter-button').click(function() {
  ref.authWithOAuthPopup("twitter", function(error, data) {
    if (error) {<commit_msg>Title updates if there is an unread message<commit_after>$(document).ready(function() {
// static stuff
var ref = new Firebase("***firebase-url***");
var socket = io();
var canPost = true;
var authData;
var unreadMessages =  false;

var msgbox = $("#message");

$('.helpButton').click(function() {
  $('.about-box').fadeIn(function() {
    $('.close-button').click(function() {
      $('.about-box').fadeOut()
    });
  })
});

function updateTitle() {
  var title = $(document).prop('title'); 
  if (unreadMessages){
    title.prepend("*");
  }else{
    title =  title.substring(1);
  }
}

function showMessage(msg, user, tags, imageLink) {
  msg = emojione.toImage(msg);

  var messageElement;
  if (user == 'RubyBot') {
    messageElement = $('<li class="bot-msg">').html('<a href="http://yrs.io" target="_blank">' + user + '</a>' + ': ' + msg);

  } else if (user == 'Server') {
    messageElement = $('<li class="server-msg">').html('<a href="http://yrs.io" target="_blank">' + user + '</a>' + ': ' + msg);

  } else {

    if (!imageLink || imageLink == ''){
      messageElement = $('<li>').html(
        '<a href="https://twitter.com/'+ user +'" target="_blank"></a>' +
        '<div class="message">' +
        '<a class="twitter-link" href="https://twitter.com/'+ user +'" target="_blank">@' + user + '</a><span class="label label-' + tags + '">' + tags + '</span>' +
        '<p class="msg">' + msg + '</p></div>'
      );
    } else {
      messageElement = $('<li>').html(
        '<a href="https://twitter.com/'+ user +'" target="_blank"><img class="profileImage" src="' + imageLink + '"/></a>' +
        '<div class="message">' +
        '<a class="twitter-link" href="https://twitter.com/'+ user +'" target="_blank">@' + user + '</a><span class="label label-' + tags + '">' + tags + '</span>' +
        '<p class="msg">' + msg + '</p></div>'
      );
    }
  }
  messageElement.linkify({
    target: "_blank"
  });
  $('#messages').append(messageElement).animate({scrollTop: 1000000}, "slow");

  if (document.hasFocus() == false){
    unreadMessages = true;
    updateTitle();
    var audio = new Audio('/assets/sound/pop.ogg');
    audio.play();
  }
}


// firebase stuff
ref.onAuth(function(data) {
  authData = data;
  if (!data){
    $('.twitter').css("display", "block")
  } else {
    socket.emit("user join", data.token, data.twitter.username, data.twitter.profileImageURL);
  }
});

$('#twitter-button').click(function() {
  ref.authWithOAuthPopup("twitter", function(error, data) {
    if (error) {
{'fraction_non_alphanumeric': 0.248744769874477, 'fraction_numerical': 0.0031380753138075313, 'mean_word_length': 3.3902662993572084, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 61, 'https://': 8, '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': '6370680', 'n_tokens_mistral': 1617, 'n_tokens_neox': 1585, 'n_words': 316}