<commit_before>(function (root, factory) {
  // Universal Module Definition (UMD)
  // via https://github.com/umdjs/umd/blob/master/templates/returnExports.js
  if (typeof module === 'object' && module.exports) {
    // Node. Does not work with strict CommonJS, but
    // only CommonJS-like environments that support module.exports,
    // like Node.
    module.exports = factory();
  } else {
    // Browser globals (root is window)
    root.returnExports = factory();
  }
}(this, function () {
  'use strict'

  // Bail if there is no navbar present on this page
  if (!document.querySelector('nav.navbar')) return;

  var loginButton = document.querySelector('nav.navbar #sign-in');
  var signupButton = document.querySelector('nav.navbar #sign-up');
  var subPaths = getSubPaths();
  if (!loginButton) {
    putActiveTab();
    return;
  }

  checkUserState();

  function checkUserState () {

    // Send request to check the user is logged in or not
    var developerRequest = new XMLHttpRequest();
    developerRequest.open('GET', '/api/developer.json', true);

    developerRequest.onload = function() {
      if (developerRequest.status >= 200 && developerRequest.status < 400) {
        // Success!
        var data = JSON.parse(developerRequest.responseText);

        if (data.id) {
          loginButton.parentNode.innerHTML = getLoginElem(data.nickname, data.avatar);
          // After 'sign out element' in the dropdown was injected
          var signOutElem = document.getElementById('sign-out');
          signOutElem.addEventListener('click', makeLogoutCall);
          hideSignUpButton();
          putActiveTab();
        } else {
          // When user is not logged in
          loginButton.innerHTML = getNotLoginElem();
          signupButton.innerHTML = getSignUpElem();
          putActiveTab();
        }
      } else {
        // We re1ched our target server, but it returned an error
        loginButton.innerHTML = getNotLoginElem();
        signupButton.innerHTML = getSignUpElem();
      }
    };


    developerRequest.onerror = function() {
      //
      loginButton.innerHTML = getNotLoginElem();
      signupButton.innerHTML = getSignUpElem();
    };
    developerRequest.send();
  }

  function hideSignUpButton () {
    signupButton.style.minWidth = '63px'; // to keep width of nav
    signupButton.style.padding = '0';
    signupButton.style.minHeight = '0';
    signupButton.parentNode.style.fontSize = '0';
  }

  function makeLogoutCall (e) {

    e.preventDefault();
    e.stopPropagation();
    var logoutRequest = new XMLHttpRequest();
    logoutRequest.open('POST', '/api/developer/sign_out', true);
    logoutRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    logoutRequest.send();


    // change Button UI, cancle the event when log out is successful

    logoutRequest.onload = function () {
      if (isThisDevPortalPage() || isThisCustomExtractPage()) {
        // If user was on dashboard or custom extract page, redirect the page to sign in page
        window.location = '/developers/sign_in/'
      } else {
        // If user was on other pages than dashboard and custom extract page, just refresh the page.
        window.location.reload();
      }
    }

    logoutRequest.onerror = function () {

    }
  }

  function getLoginElem (nickname, avatarImageURL) {
    var strVar = '';
    strVar += '<a id="sign-in" class="dropdown-toggle" data-toggle="dropdown" data-target="#" role="button">';
    strVar += ' <div id=\"login-profile\">';
    strVar += '   <img width=\"18\" height=\"18\" src=\"'+avatarImageURL+'\" style=\"border-radius: 50%; margin-top: -9px;\">';
    strVar += ' <\/div>';
    strVar += ' <div class="login-txt"> ' + nickname + ' <\/div>';
    strVar += '</a>';
    strVar += ' <ul class="dropdown-menu">';
    strVar += '   <li><a href="/developers/">Dashboard</a></li>';
    strVar += '   <li><a href="/data/metro-extracts/your-extracts/">Custom Extracts</a></li>';
    strVar += '   <li id="sign-out"><a href="#"> Logout</a></li>';
    strVar += ' </ul>';
    return strVar;
  }

  function getNotLoginElem () {
    var strVar='';
    // strVar += '<a id=\"login\" href=\"\/developers\/sign_in\">';
    strVar += '  <div id=\"login-profile\">';
    strVar += '    <div class=\"compass\">';
    strVar += '      <div class=\"center-dot\"><\/div>';
    strVar += '    <\/div>';
    strVar += '  <\/div>';
    strVar += '  <div class=\"login-txt\">sign in<\/div>';
    // strVar += '<\/a>';
    return strVar;
  }

  function getSignUpElem () {
    var strVar = '';
    strVar += '<span class="visible-xs-inline visible-sm-inline visible-md-inline visible-lg-inline btn btn-mapzen">';
    strVar += '  sign up';
    strVar += '<\/span>';<commit_msg>specified selector, changed custom extract menu name<commit_after>(function (root, factory) {
  // Universal Module Definition (UMD)
  // via https://github.com/umdjs/umd/blob/master/templates/returnExports.js
  if (typeof module === 'object' && module.exports) {
    // Node. Does not work with strict CommonJS, but
    // only CommonJS-like environments that support module.exports,
    // like Node.
    module.exports = factory();
  } else {
    // Browser globals (root is window)
    root.returnExports = factory();
  }
}(this, function () {
  'use strict'

  // Bail if there is no navbar present on this page
  if (!document.querySelector('nav.navbar')) return;

  var loginButton = document.querySelector('nav.navbar #sign-in');
  var signupButton = document.querySelector('nav.navbar #sign-up');
  var subPaths = getSubPaths();
  if (!loginButton) {
    putActiveTab();
    return;
  }

  checkUserState();

  function checkUserState () {

    // Send request to check the user is logged in or not
    var developerRequest = new XMLHttpRequest();
    developerRequest.open('GET', '/api/developer.json', true);

    developerRequest.onload = function() {
      if (developerRequest.status >= 200 && developerRequest.status < 400) {
        // Success!
        var data = JSON.parse(developerRequest.responseText);

        if (data.id) {
          loginButton.parentNode.innerHTML = getLoginElem(data.nickname, data.avatar);
          // After 'sign out element' in the dropdown was injected
          var signOutElem = document.querySelector('nav.navbar #sign-out');
          signOutElem.addEventListener('click', makeLogoutCall);
          hideSignUpButton();
          putActiveTab();
        } else {
          // When user is not logged in
          loginButton.innerHTML = getNotLoginElem();
          signupButton.innerHTML = getSignUpElem();
          putActiveTab();
        }
      } else {
        // We re1ched our target server, but it returned an error
        loginButton.innerHTML = getNotLoginElem();
        signupButton.innerHTML = getSignUpElem();
      }
    };


    developerRequest.onerror = function() {
      //
      loginButton.innerHTML = getNotLoginElem();
      signupButton.innerHTML = getSignUpElem();
    };
    developerRequest.send();
  }

  function hideSignUpButton () {
    signupButton.style.minWidth = '63px'; // to keep width of nav
    signupButton.style.padding = '0';
    signupButton.style.minHeight = '0';
    signupButton.parentNode.style.fontSize = '0';
  }

  function makeLogoutCall (e) {

    e.preventDefault();
    e.stopPropagation();
    var logoutRequest = new XMLHttpRequest();
    logoutRequest.open('POST', '/api/developer/sign_out', true);
    logoutRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    logoutRequest.send();


    // change Button UI, cancle the event when log out is successful

    logoutRequest.onload = function () {
      if (isThisDevPortalPage() || isThisCustomExtractPage()) {
        // If user was on dashboard or custom extract page, redirect the page to sign in page
        window.location = '/developers/sign_in/'
      } else {
        // If user was on other pages than dashboard and custom extract page, just refresh the page.
        window.location.reload();
      }
    }

    logoutRequest.onerror = function () {

    }
  }

  function getLoginElem (nickname, avatarImageURL) {
    var strVar = '';
    strVar += '<a id="sign-in" class="dropdown-toggle" data-toggle="dropdown" data-target="#" role="button">';
    strVar += ' <div id=\"login-profile\">';
    strVar += '   <img width=\"18\" height=\"18\" src=\"'+avatarImageURL+'\" style=\"border-radius: 50%; margin-top: -9px;\">';
    strVar += ' <\/div>';
    strVar += ' <div class="login-txt"> ' + nickname + ' <\/div>';
    strVar += '</a>';
    strVar += ' <ul class="dropdown-menu">';
    strVar += '   <li><a href="/developers/">Dashboard</a></li>';
    strVar += '   <li><a href="/data/metro-extracts/your-extracts/">Your Custom Extracts</a></li>';
    strVar += '   <li id="sign-out"><a href="#"> Logout</a></li>';
    strVar += ' </ul>';
    return strVar;
  }

  function getNotLoginElem () {
    var strVar='';
    // strVar += '<a id=\"login\" href=\"\/developers\/sign_in\">';
    strVar += '  <div id=\"login-profile\">';
    strVar += '    <div class=\"compass\">';
    strVar += '      <div class=\"center-dot\"><\/div>';
    strVar += '    <\/div>';
    strVar += '  <\/div>';
    strVar += '  <div class=\"login-txt\">sign in<\/div>';
    // strVar += '<\/a>';
    return strVar;
  }

  function getSignUpElem () {
    var strVar = '';
    strVar += '<span class="visible-xs-inline visible-sm-inline visible-md-inline visible-lg-inline btn btn-mapzen">';
    strVar += '  sign up';
    strVar += '<\/span>';
{'fraction_non_alphanumeric': 0.15908854437623557, 'fraction_numerical': 0.004161897825408386, 'mean_word_length': 2.7992094861660077, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1516255', 'n_tokens_mistral': 2925, 'n_tokens_neox': 2857, 'n_words': 693}