<commit_before>window.addEventListener('DOMContentLoaded', function() {

  'use strict';

  var translate = navigator.mozL10n.get;
  var buttonFindMe = document.getElementById('button-reload');
  var apiMaps = 'https://maps.googleapis.com/maps/api/geocode/json?';
  var errorMsg = document.getElementById('error');
  var results = document.getElementById('results');
  var request = null;
  var latitude = null;
  var longitude = null;
  var distance = '5000';


  // We want to wait until the localisations library has loaded all the strings.
  // So we'll tell it to let us know once it's ready.
  navigator.mozL10n.once(start);


  // Start App
  function start() {
    geoFindMe();
    
    // Display Control msg
    results.className = 'hidden';
    errorMsg.className = 'hidden';
  };

  // Show error msg
  function showError(text) {
    errorMsg.textContent = text;
    results.className = 'hidden';
    errorMsg.className = '';
  }

  // Get geolocation
  function geoFindMe() {
    function success(position) {
      latitude  = position.coords.latitude;
      longitude = position.coords.longitude;

      // Init search
      search();
    };

    function error() {
      showError(translate('unable_location'));
    };

    // Show status to user
    results.textContent = translate('locating');
    results.className = 'searching';
    errorMsg.className = 'hidden';

    navigator.geolocation.getCurrentPosition(success, error);
  };


  // Listening reload button
  buttonFindMe.addEventListener('click', function(e) {
      geoFindMe();
  }, false);


  // Get photos by location on Instagram
  function search() {
    // Are we searching already? Then stop that search
    if(request && request.abort) {
      request.abort();
    }

    // Show status to user
    results.textContent = translate('searching');
    results.className = 'searching';
    errorMsg.className = 'hidden';

    // Creat url for request
    //var term = 'latlng=' + latitude + ',' + longitude;
    var term = 'latlng=-8.069443,-34.899722';
    var url = apiMaps + term;
    console.log(url);

    request = new XMLHttpRequest({ mozSystem: true });
    request.open('get', url, true);
    request.responseType = 'json';

    // Return for request
    request.addEventListener('error', onRequestError);
    request.addEventListener('load', onRequestLoad);

    request.send();
  };


  // Request error msg
  function onRequestError() {
    console.log(request.error);    
    showError(translate('searching_error'));
  };

  // Request and load complete
  function onRequestLoad() {
    var response = request.response;

    // Check response
    if(response === null) {
      showError(translate('searching_error'));
      return;
    }

    // Clear results content
    results.textContent = '';
    results.className = '';

    var city = response.results[0].address_components[3].long_name;
    var street = response.results[0].address_components[1].long_name;

    console.log(street + ', ' + city);

    if(city == 'Recife') {

    } else {
      showError(translate('city_error'));
    }
    
    // if(photos.length === 0) {
    //   results.textContent = translate('search_no_results');
    //   results.className = 'searching';
    //   errorMsg.className = 'hidden';
    // } else {
    //   var listPhotos = document.createElement('ul');
    //   results.appendChild(listPhotos);

    //   photos.forEach(function(item) {
    //     // We're using textContent because inserting content from external sources into your page using innerHTML can be dangerous.
    //     // https://developer.mozilla.org/Web/API/Element.innerHTML#Security_considerations
    //     var liPhoto = document.createElement('li');
    //     var header = document.createElement('header');
    //     var profileAvatar = document.createElement('img');
    //     var profileName = document.createElement('h2');
    //     var timeAgo = document.createElement('span');
    //     var wrapPhoto = document.createElement('figure');
    //     var photo = document.createElement('img');
    //     var photoCaption = document.createElement('figcaption');
    //     var photoMenu = document.createElement('menu');
    //     var liShare = document.createElement('li');
    //     var buttonSahre = document.createElement('button');

    //     // Set values
    //     liPhoto.className = 'photo';
    //     profileAvatar.src = item.user.profile_picture;
    //     profileAvatar.alt = item.user.username;
    //     profileName.textContent = item.user.full_name;
    //     timeAgo.className = 'time-ago';
    //     photo.src = item.images.low_resolution.url;
    //     if ( item.caption ) {
    //       photoCaption.textContent = item.caption.text;  
    //     }
    //     photo.alt = 'Photo by ' + item.user.username;        
    //     photoMenu.type = 'toolbar';
    //     buttonSahre.className = 'button-share';
    //     buttonSahre.value = item.link;
    //     buttonSahre.textContent = 'Share';

    //     // Creat photo template 
    //     header.appendChild(profileAvatar);
    //     header.appendChild(profileName);
    //     header.appendChild(timeAgo);
        
    //     wrapPhoto.appendChild(photo);
    //     wrapPhoto.appendChild(photoCaption);

    //     liShare.appendChild(buttonSahre);
    //     photoMenu.appendChild(liShare);
        
    //     liPhoto.appendChild(header);
    //     liPhoto.appendChild(wrapPhoto);
    //     liPhoto.appendChild(photoMenu);

    //     listPhotos.appendChild(liPhoto);

    //   });
    // }

    results.className = '';
  };
});<commit_msg>Get time in CDR ok<commit_after>window.addEventListener('DOMContentLoaded', function() {

  'use strict';

  var translate = navigator.mozL10n.get;
  var buttonFindMe = document.getElementById('button-reload');
  var apiMaps = 'https://maps.googleapis.com/maps/api/geocode/json?';
  var resourceIdCDR = 'f4ca6471-bb7b-4412-b248-d522948aa789'
  var apiCDR = 'http://dados.recife.pe.gov.br/api/action/datastore_search?resource_id=' + resourceIdCDR;
  var errorMsg = document.getElementById('error');
  var results = document.getElementById('results');
  var request = null;
  var latitude = null;
  var longitude = null;


  // We want to wait until the localisations library has loaded all the strings.
  // So we'll tell it to let us know once it's ready.
  navigator.mozL10n.once(start);


  // Start App
  function start() {
    geoFindMe();
    
    // Display Control msg
    results.className = 'hidden';
    errorMsg.className = 'hidden';
  };

  // Show error msg
  function showError(text) {
    errorMsg.textContent = text;
    results.className = 'hidden';
    errorMsg.className = '';
  }

  // Get geolocation
  function geoFindMe() {
    function success(position) {
      latitude  = position.coords.latitude;
      longitude = position.coords.longitude;

      // Init search
      searchStreet();
    };

    function error() {
      showError(translate('unable_location'));
    };

    // Show status to user
    results.textContent = translate('locating');
    results.className = 'searching';
    errorMsg.className = 'hidden';

    navigator.geolocation.getCurrentPosition(success, error);
  };


  // Listening reload button
  buttonFindMe.addEventListener('click', function(e) {
      geoFindMe();
  }, false);


  // Get photos by location on Instagram
  function searchStreet() {
    // Are we searching already? Then stop that search
    if(request && request.abort) {
      request.abort();
    }

    // Show status to user
    results.textContent = translate('searching');
    results.className = 'searching';
    errorMsg.className = 'hidden';

    // Creat url for request
    //var term = 'latlng=' + latitude + ',' + longitude;
    var term = 'latlng=-8.069443,-34.899722';
    var url = apiMaps + term;
    console.log(url);

    request = new XMLHttpRequest({ mozSystem: true });
    request.open('get', url, true);
    request.responseType = 'json';

    // Return for request
    request.addEventListener('error', onRequestStreetError);
    request.addEventListener('load', onRequestStreetLoad);

    request.send();
  };


  // Request error msg
  function onRequestStreetError() {
    console.log(request.error);    
    showError(translate('searching_error'));
  };

  // Request and load complete
  function onRequestStreetLoad() {
    var response = request.response;

    // Check response
    if(response === null) {
      showError(translate('searching_error'));
      return;
    }

    // Clear results content
    results.textContent = '';
    results.className = '';

    var city = response.results[0].address_components[3].long_name;
    var street = response.results[0].address_components[1].long_name;

    if(city == 'Recife') {
      var typeStreet = street.split(' ');
      typeStreet = typeStreet[0];

      switch(typeStreet) {
        case 'Rua':
          street = street.replace('Rua', 'R');
          searchTimeTrash(street);
          break;
        default:
          console.log(typeStreet);
          break;
      }
    } else {
      showError(translate('city_error'));
    }

    results.className = '';
  };

  // Get photos by location on Instagram
  function searchTimeTrash(street) {
    // Are we searching already? Then stop that search
    if(request && request.abort) {
      request.abort();
    }

    // Show status to user
    results.textContent = translate('searching');
    results.className = 'searching';
    errorMsg.className = 'hidden';

    // Creat url for request
    var term = '&limit=10&q=' + street;
    var url = apiCDR + term;

    request = new XMLHttpRequest({ mozSystem: true });
    request.open('get', url, true);
    request.responseType = 'json';

    // Return for request
    request.addEventListener('error', onRequestCDRError);
    request.addEventListener('load', onRequestCDRLoad);

    request.send();
  };

  // Request error msg
  function onRequestCDRError() {
    console.log(request.error);    
    showError(translate('searching_error'));
  };

  // Request and load complete
  function onRequestCDRLoad() {
    var response = request.response;

    // Check response
    if(response === null) {
      showError(translate('searching_error'));
      return;
    }

    // Clear results content
    results.textContent = '';
    results.className = '';

    var time = response.result.records[0].intervalo;
    console.log(time);
    
    results.className = '';
  };
});
{'fraction_non_alphanumeric': 0.13470711696241175, 'fraction_numerical': 0.007441327990841442, 'mean_word_length': 2.700317684433463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, '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': '7091516', 'n_tokens_mistral': 3150, 'n_tokens_neox': 2977, 'n_words': 656}