<commit_before>'use strict';

/* This declares to JSHint that 'settings' and 'jQuery' are global variables: */
/*global settings:false */
/*global jQuery:false */


angular.module('offers').controller('AddOfferController', ['$scope', '$rootScope', '$http', '$timeout', '$state', '$stateParams', '$location', '$geolocation', 'leafletBoundsHelpers', 'OffersBy', 'Offers', 'Authentication',
  function($scope, $rootScope, $http, $timeout, $state, $stateParams, $location, $geolocation, leafletBoundsHelpers, OffersBy, Offers, Authentication) {

    // If user is not signed in then redirect to sign in form
    if (!Authentication.user) $location.path('signin');

    $scope.user = Authentication.user;

    $scope.isLoading = false;

    $scope.offer = false;

    $scope.position = $geolocation.getCurrentPosition({
      timeout: 60000 // 1min
    });

    // Leaflet
    angular.extend($scope, {
      center: {
        // Default to Europe
        lat: 48.6908333333,
        lng: 9.14055555556,
        zoom: 4
      },
      layers: {
        baselayers: {
          default: {
            name: 'Streets',
            type: 'xyz',
            url: '//{s}.tiles.mapbox.com/v4/{user}.{map}/{z}/{x}/{y}.png?access_token=' + settings.mapbox.access_token + ( settings.https ? '&secure=1' : ''),
            layerParams: {
              user: settings.mapbox.user,
              map: settings.mapbox.map[0]
            },
            layerOptions: {
              attribution: '<a href="http://www.openstreetmap.org/">OSM</a>',
              continuousWorld: true
            }
          }
        }
      },
      defaults: {
        scrollWheelZoom: false
      }
    });

    // Add Satellite layer to the map
    if(settings.mapbox.map[2]) {
      $scope.layers.baselayers.satellite = {
        name: 'Satellite',
        type: 'xyz',
        url: '//{s}.tiles.mapbox.com/v4/{user}.{map}/{z}/{x}/{y}.png?access_token=' + settings.mapbox.access_token + ( settings.https ? '&secure=1' : ''),
        layerParams: {
          user: settings.mapbox.user,
          map: settings.mapbox.map[2]
        },
        layerOptions: {
          attribution: '<a href="http://www.openstreetmap.org/">OSM</a>',
          continuousWorld: true
        }
      };
    }

    // Check if user already has previous offer
    $scope.findOffer = function() {

      $scope.isLoading = true;

      OffersBy.get({
        userId: Authentication.user._id
      }, function(offer){

        // Make sure $scope.$apply() updates results
        // @link http://jimhoskins.com/2012/12/17/angularjs-and-apply.html
        $timeout(function() {

          $scope.isLoading = false;

          // Offer with location, must be real thing!
          if(offer.location) {
            $scope.center.lat = parseFloat(offer.location[0]);
            $scope.center.lng = parseFloat(offer.location[1]);
            $scope.center.zoom = 16;
          }
          // Push some defaults to offer if we didn't get proper answer...
          else {
            offer.maxGuests = 1;
            offer.status = 'yes';

            // Center map to user's location
            $scope.position.then(function(position){
              if(position.coords.latitude && position.coords.longitude) {
                $scope.center.lat = parseFloat(position.coords.latitude);
                $scope.center.lng = parseFloat(position.coords.longitude);
                $scope.center.zoom = 13;
              }
            });
          }

          // Determine new status from URL, overrides previous status
          if($stateParams.status && jQuery.inArray( $stateParams.status, ['yes', 'maybe', 'no'] ) ) {
            offer.status = $stateParams.status;
          }

          $scope.offer = offer;

        });
      });<commit_msg>Remove crappy $geolocation from "add offer" map<commit_after>'use strict';

/* This declares to JSHint that 'settings' and 'jQuery' are global variables: */
/*global settings:false */
/*global jQuery:false */


angular.module('offers').controller('AddOfferController', ['$scope', '$rootScope', '$http', '$timeout', '$state', '$stateParams', '$location', 'leafletBoundsHelpers', 'OffersBy', 'Offers', 'Authentication',
  function($scope, $rootScope, $http, $timeout, $state, $stateParams, $location, leafletBoundsHelpers, OffersBy, Offers, Authentication) {

    // If user is not signed in then redirect to sign in form
    if (!Authentication.user) $location.path('signin');

    $scope.user = Authentication.user;

    $scope.isLoading = false;

    $scope.offer = false;

    // Leaflet
    angular.extend($scope, {
      center: {
        // Default to Europe
        lat: 48.6908333333,
        lng: 9.14055555556,
        zoom: 4
      },
      layers: {
        baselayers: {
          default: {
            name: 'Streets',
            type: 'xyz',
            url: '//{s}.tiles.mapbox.com/v4/{user}.{map}/{z}/{x}/{y}.png?access_token=' + settings.mapbox.access_token + ( settings.https ? '&secure=1' : ''),
            layerParams: {
              user: settings.mapbox.user,
              map: settings.mapbox.map[0]
            },
            layerOptions: {
              attribution: '<a href="http://www.openstreetmap.org/">OSM</a>',
              continuousWorld: true
            }
          }
        }
      },
      defaults: {
        scrollWheelZoom: false
      }
    });

    // Add Satellite layer to the map
    if(settings.mapbox.map[2]) {
      $scope.layers.baselayers.satellite = {
        name: 'Satellite',
        type: 'xyz',
        url: '//{s}.tiles.mapbox.com/v4/{user}.{map}/{z}/{x}/{y}.png?access_token=' + settings.mapbox.access_token + ( settings.https ? '&secure=1' : ''),
        layerParams: {
          user: settings.mapbox.user,
          map: settings.mapbox.map[2]
        },
        layerOptions: {
          attribution: '<a href="http://www.openstreetmap.org/">OSM</a>',
          continuousWorld: true
        }
      };
    }

    // Check if user already has previous offer
    $scope.findOffer = function() {

      $scope.isLoading = true;

      OffersBy.get({
        userId: Authentication.user._id
      }, function(offer){

        // Make sure $scope.$apply() updates results
        // @link http://jimhoskins.com/2012/12/17/angularjs-and-apply.html
        $timeout(function() {

          $scope.isLoading = false;

          // Offer with location, must be real thing!
          if(offer.location) {
            $scope.center.lat = parseFloat(offer.location[0]);
            $scope.center.lng = parseFloat(offer.location[1]);
            $scope.center.zoom = 16;
          }
          // Push some defaults to offer if we didn't get proper answer...
          else {
            offer.maxGuests = 1;
            offer.status = 'yes';
          }

          // Determine new status from URL, overrides previous status
          if($stateParams.status && jQuery.inArray( $stateParams.status, ['yes', 'maybe', 'no'] ) ) {
            offer.status = $stateParams.status;
          }

          $scope.offer = offer;

        });
      });
{'fraction_non_alphanumeric': 0.15013404825737264, 'fraction_numerical': 0.013828136023705376, 'mean_word_length': 2.0046629927935564, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '5759950', 'n_tokens_mistral': 2218, 'n_tokens_neox': 2083, 'n_words': 427}