<commit_before>// namespace for this "module"
var Buttons = {};

Buttons.bodyDivId = 'buttons_page';

////////////////////////////////////////////////////////////////////////
//
// Action flow through this page:
// * Buttons.showLoggedInPage() is the landing function.  Always call
//   this first. It inspects the query string. Depending on what it finds there,
//   it calls the API and sets either Api.button or Api.buttonSet. It then calls
//   either Buttons.showButton(), Buttons.showSet() or Buttons.showSetList().
// * Buttons.showButton() uses the data returned by the API to build a page
//   describing a single button, then calls Login.arrangePage().
// * Buttons.showSet() uses the data returned by the API to build a page
//   describing a single button set with a list of all of its buttons, then
//   calls Login.arrangePage().
// * Buttons.showSetList() uses the data returned by the API to build a page
//   describing a list of all button sets, then calls Login.arrangePage().
////////////////////////////////////////////////////////////////////////

Buttons.showLoggedInPage = function() {
  // Figure out what we're here to display, get all needed information,
  // then display the page
  Buttons.buttonName = Env.getParameterByName('button');
  Buttons.setName = Env.getParameterByName('set');

  if (Buttons.buttonName) {
    Api.getButtonData(Buttons.buttonName, Buttons.showButton);
  } else if (Buttons.setName) {
    Api.getButtonSetData(Buttons.setName, Buttons.showSet);
  } else {
    Api.getButtonSetData(null, Buttons.showSetList);
  }
};

Buttons.showButton = function() {
  Buttons.page = $('<div>');


  if (Api.button.load_status != 'ok') {
    if (Env.message === undefined || Env.message === null) {
      Env.message = {
        'type': 'error',
        'text': 'An internal error occurred while loading the button.',
      };
    }

    Login.arrangePage(Buttons.page);
    return;
  }


  // Assume that the version of the button name from the API is canonical
  for (var buttonName in Api.button.list) {
    Buttons.buttonName = buttonName;
    break;
  }

  $('title').html(buttonName + '&mdash; Button Men Online');

  if (Api.button.list[Buttons.buttonName] === undefined) {
    Env.message = {
      'type': 'none',
      'text': 'Button not found.',
    };

    Login.arrangePage(Buttons.page);
    return;
  }

  var button = Api.button.list[Buttons.buttonName];

  var mainDiv = $('<div>', { 'class': 'singleButton' });

  var buttonDetailsArea = $('<div>', { 'class': 'buttonDetails' });
  mainDiv.append(buttonDetailsArea);
  buttonDetailsArea.append(Buttons.buildButtonBox(button));
  var secondBox = $('<div>', { 'class': 'secondaryDetails' });
  buttonDetailsArea.append(secondBox);
  secondBox.append($('<p>', {
    'class': 'flavorText',
    'text': (button.flavorText ? button.flavorText : 'No flavor text.'),<commit_msg>Remove extra lines added by mistake<commit_after>// namespace for this "module"
var Buttons = {};

Buttons.bodyDivId = 'buttons_page';

////////////////////////////////////////////////////////////////////////
//
// Action flow through this page:
// * Buttons.showLoggedInPage() is the landing function.  Always call
//   this first. It inspects the query string. Depending on what it finds there,
//   it calls the API and sets either Api.button or Api.buttonSet. It then calls
//   either Buttons.showButton(), Buttons.showSet() or Buttons.showSetList().
// * Buttons.showButton() uses the data returned by the API to build a page
//   describing a single button, then calls Login.arrangePage().
// * Buttons.showSet() uses the data returned by the API to build a page
//   describing a single button set with a list of all of its buttons, then
//   calls Login.arrangePage().
// * Buttons.showSetList() uses the data returned by the API to build a page
//   describing a list of all button sets, then calls Login.arrangePage().
////////////////////////////////////////////////////////////////////////

Buttons.showLoggedInPage = function() {
  // Figure out what we're here to display, get all needed information,
  // then display the page
  Buttons.buttonName = Env.getParameterByName('button');
  Buttons.setName = Env.getParameterByName('set');

  if (Buttons.buttonName) {
    Api.getButtonData(Buttons.buttonName, Buttons.showButton);
  } else if (Buttons.setName) {
    Api.getButtonSetData(Buttons.setName, Buttons.showSet);
  } else {
    Api.getButtonSetData(null, Buttons.showSetList);
  }
};

Buttons.showButton = function() {
  Buttons.page = $('<div>');

  if (Api.button.load_status != 'ok') {
    if (Env.message === undefined || Env.message === null) {
      Env.message = {
        'type': 'error',
        'text': 'An internal error occurred while loading the button.',
      };
    }

    Login.arrangePage(Buttons.page);
    return;
  }

  // Assume that the version of the button name from the API is canonical
  for (var buttonName in Api.button.list) {
    Buttons.buttonName = buttonName;
    break;
  }

  $('title').html(buttonName + '&mdash; Button Men Online');

  if (Api.button.list[Buttons.buttonName] === undefined) {
    Env.message = {
      'type': 'none',
      'text': 'Button not found.',
    };

    Login.arrangePage(Buttons.page);
    return;
  }

  var button = Api.button.list[Buttons.buttonName];

  var mainDiv = $('<div>', { 'class': 'singleButton' });

  var buttonDetailsArea = $('<div>', { 'class': 'buttonDetails' });
  mainDiv.append(buttonDetailsArea);
  buttonDetailsArea.append(Buttons.buildButtonBox(button));
  var secondBox = $('<div>', { 'class': 'secondaryDetails' });
  buttonDetailsArea.append(secondBox);
  secondBox.append($('<p>', {
    'class': 'flavorText',
    'text': (button.flavorText ? button.flavorText : 'No flavor text.'),
{'fraction_non_alphanumeric': 0.181723779854621, 'fraction_numerical': 0.0, 'mean_word_length': 2.85781041388518, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4970954', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1695, 'n_words': 500}