<commit_before>'use strict';
angular.module('Trendicity')

.service('InstagramService', function($rootScope, $http, $interval, localStorageService, authService) {
  var self = this;

  // if running in a desktop browswer we will proxy to: https://api.instagram.com/v1 in ionic.project to avoid CORS issues
  var API_ENDPOINT = ionic.Platform.isWebView() ? 'https://api.instagram.com/v1' : '/instagram/api';

  console.log('API_ENDPOINT:' + API_ENDPOINT);

  // You are encouraged to setup your own client_id at: http://instagram.com/developer/clients/manage
  var CLIENT_ID = '75d27c9457cd4d1abbacf80a228f4a10';

  var AUTH_URL = 'https://instagram.com/oauth/authorize';
  var AUTH_REDIRECT_URL = 'http://localhost:8100/instagram.html';
  var LOGOUT_URL = 'https://instagram.com/accounts/logout';

  this.getEndpoint = function() {
      return API_ENDPOINT;
  };

  this.login = function() {
    var loginWindow = window.open(AUTH_URL + '?client_id=' +
      CLIENT_ID + '&scope=likes+comments&response_type=token&redirect_uri=' +
      AUTH_REDIRECT_URL, '_blank', 'width=400,height=250,location=no,clearsessioncache=yes,clearcache=yes'
    );

    var configUpdater = function(config) {
      config.params = config.params || {};
      config.params.access_token = self.getAccessToken();
      return config;
    }

    if (ionic.Platform.isWebView()) { // If running in a WebView (i.e. on a mobile device/simulator)
      loginWindow.addEventListener('loadstart', function (event) {
        if ((event.url).indexOf(AUTH_REDIRECT_URL) === 0) {
          var accessToken = (event.url).split('access_token=')[1];
          localStorageService.set('accessToken', accessToken);
          loginWindow.close();
          if (self.isLoggedIn()) {
            authService.loginConfirmed(null, configUpdater);
          }
        }
      });
    } else { // if running on a desktop browser, use this hack<commit_msg>resolved jshint errors in services/instagram.js for #57<commit_after>'use strict';
angular.module('Trendicity')

.service('InstagramService', function($rootScope, $http, $interval, localStorageService, authService) {
  var self = this;

  // if running in a desktop browswer we will proxy to: https://api.instagram.com/v1 in ionic.project to avoid CORS issues
  var API_ENDPOINT = ionic.Platform.isWebView() ? 'https://api.instagram.com/v1' : '/instagram/api';

  console.log('API_ENDPOINT:' + API_ENDPOINT);

  // You are encouraged to setup your own client_id at: http://instagram.com/developer/clients/manage
  var CLIENT_ID = '75d27c9457cd4d1abbacf80a228f4a10';

  var AUTH_URL = 'https://instagram.com/oauth/authorize';
  var AUTH_REDIRECT_URL = 'http://localhost:8100/instagram.html';
  var LOGOUT_URL = 'https://instagram.com/accounts/logout';

  this.getEndpoint = function() {
      return API_ENDPOINT;
  };

  this.login = function() {
    var loginWindow = window.open(AUTH_URL + '?client_id=' +
      CLIENT_ID + '&scope=likes+comments&response_type=token&redirect_uri=' +
      AUTH_REDIRECT_URL, '_blank', 'width=400,height=250,location=no,clearsessioncache=yes,clearcache=yes'
    );

    var configUpdater = function(config) {
      config.params = config.params || {};
      config.params.access_token = self.getAccessToken(); // jshint ignore:line
      return config;
    }

    if (ionic.Platform.isWebView()) { // If running in a WebView (i.e. on a mobile device/simulator)
      loginWindow.addEventListener('loadstart', function (event) {
        if ((event.url).indexOf(AUTH_REDIRECT_URL) === 0) {
          var accessToken = (event.url).split('access_token=')[1];
          localStorageService.set('accessToken', accessToken);
          loginWindow.close();
          if (self.isLoggedIn()) {
            authService.loginConfirmed(null, configUpdater);
          }
        }
      });
    } else { // if running on a desktop browser, use this hack
{'fraction_non_alphanumeric': 0.13542739443872295, 'fraction_numerical': 0.016992790937178166, 'mean_word_length': 3.625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3489973', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1225, 'n_words': 247}