<commit_before>
/**
 * twitter.com.js
 *
 * README.md
 * > Listens for your following of users, automatically adds those users
 * > to your Dodo[1] list.
 *
 * deps:
 *  jQuery 1.9
 */

/**
 * Static variables.
 */

var host = 'https://dodo-twitter.herokuapp.com/api/';
var userId;

/**
 * Send request to server to add a new dodo.
 *
 * @param {String} userId
 * @param {String} dodoId
 * @param {Function} fn (optional)
 */

function addDodo(userId, dodoId, fn) {
  if (!userId) return;
  $.post(host + 'dodo', { userId: userId, dodoId: dodoId }, fn);
}

/**
 * Return twitter user id from follow button.
 *
 * @param {Element} button
 */

function getDodoId(button) {
  return $(button)
    .closest('div.account')
    .attr('data-user-id');
}

/**
 * On click for follow buttons, bind appropriate event listener.
 */

function bindFollowButtons() {
  $('.follow-button').click(function() {
    addDodo(userId, getDodoId(this), showMessage);
  });
}

/**
 * Show visual confirmation that dodo has been added.
 */

function showMessage(err, data) {
  // Show something on the web page.
  if (err) console.log(err);
  console.log(data);
}

/**
 * Set userId.
 */

function setUserId() {
  userId = $('#user-dropdown').find('img.avatar').attr('data-user-id');
  if (!userId)
    showMessage('Please login to use Dodo.', null);
}

/**
 * Start script!<commit_msg>added visual confirmation with showMessage<commit_after>
/**
 * twitter.com.js
 *
 * README.md
 * > Listens for your following of users, automatically adds those users
 * > to your Dodo[1] list.
 *
 * deps:
 *  jQuery 1.9
 */

/**
 * Static variables.
 */

var host = 'https://dodo-twitter.herokuapp.com/api/';
var userId;

/**
 * Send request to server to add a new dodo.
 *
 * @param {String} userId
 * @param {String} dodoId
 * @param {Function} fn (optional)
 */

function addDodo(userId, dodoId, fn) {
  if (!userId) return;
  $.post(host + 'dodo', { userId: userId, dodoId: dodoId }, fn);
}

/**
 * Return twitter user id from follow button.
 *
 * @param {Element} button
 */

function getDodoId(button) {
  return $(button)
    .closest('div.account')
    .attr('data-user-id');
}

/**
 * On click for follow buttons, bind appropriate event listener.
 */

function bindFollowButtons() {
  $('.follow-button').click(function() {
    addDodo(userId, getDodoId(this), showMessage);
  });
}

/**
 * Show visual confirmation that dodo has been added.
 *
 * @param {Object or String} err
 * @param {Object or String} data
 */

function showMessage(err, data) {
  var notification = document.createElement('div');
  var message = err || data;
  var styles = {
    'position': 'fixed',
    'bottom': '0',
    'right': '0',
    'left': '0',
    'padding': '1em',
    'font-size': '1em',
    'text-align': 'center',
    'opacity': '0.9',
    'z-index': '100',
    'color': '#333',
    'background-color': '#dff0d8',
  };
  if (err) styles['background-color'] = '#f2dede';
  $(notification)
    .css(styles)
    .text(message)
    .attr('id', 'dodo-twitter-notification');
  $('body').append(notification);
  setTimeout(function() { $('#dodo-twitter-notification').remove() }, 3000);
}

/**
 * Set userId.
 */

function setUserId() {
  userId = $('#user-dropdown').find('img.avatar').attr('data-user-id');
  if (!userId)
    showMessage('Please login to use Dodo.', null);
}

/**
 * Start script!
{'fraction_non_alphanumeric': 0.18246869409660108, 'fraction_numerical': 0.007751937984496124, 'mean_word_length': 3.357142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '4773992', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1164, 'n_words': 303}