<commit_before>'use strict';

/* This declares to JSHint that several variables are global: */
/*global settings:false */
/*global PruneClusterForLeaflet:false */
/*global PruneCluster:false */
/*global L:false */

angular.module('search').controller('SearchController', ['$scope', '$http', '$location', '$state', '$stateParams', '$timeout', '$log', 'Offers', 'leafletBoundsHelpers', 'Authentication', 'Languages', 'leafletData',
  function($scope, $http, $location, $state, $stateParams, $timeout, $log, Offers, leafletBoundsHelpers, Authentication, Languages, leafletData) {

    // Currently signed in user
    $scope.user = Authentication.user;

    // If user is not signed in then redirect back home
    if (!$scope.user) $location.path('signin');

    // Default to Europe for now
    var defaultLocation = {
      lat: 48.6908333333,
      lng: 9.14055555556,
      zoom: 6
    };

    $scope.layerStyle = 'street';
    $scope.sidebarOpen = false;
    $scope.languages = Languages.get('object');
    $scope.offer = false; // Offer to show
    $scope.notFound = false;
    $scope.currentSelection = {
      weight: 2,
      color: '#989898',
      fillColor: '#b1b1b1',
      fillOpacity: 0.5,
      latlngs: defaultLocation,
      radius: 500,
      type: 'circle',
      layer: 'selectedOffers',
      clickable: false
    };
    $scope.minimumZoom = 3;

    // Return constructed icon
    // @link http://leafletjs.com/reference.html#icon
    var icon = function(status) {
      status = (status === 'yes') ? 'yes' : 'maybe';
      return L.icon({
        iconUrl:    '/modules/core/img/map/marker-icon-' + status + '.svg',
        iconSize:   [20, 20], // size of the icon
        iconAnchor: [10, 10] // point of the icon which will correspond to marker's location
      });
    };

    /**
     * The Variables passed to leaflet directive at init
     */
    angular.extend($scope, {
      defaults: {
        attributionControl: false,
        keyboard: true,
        controls: {
          layers: {
            visible: true,
            position: 'bottomleft',
            collapsed: true
          }
        }
      },
      center: {},
      bounds: {},
      layers: {
        baselayers: {
          default: {
            name: 'Default',
            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,
              TRStyle: 'street'//Not native Leaflet, required by layer switch
            }
          },
          osm: {
            name: 'OpenStreetMap',
            type: 'xyz',
            url: '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
            layerOptions: {
              subdomains: ['a', 'b', 'c'],
              attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OSM</a>',
              continuousWorld: true,
              TRStyle: 'street'//Not native Leaflet, required by layer switch
            }
          },
          // Doesn't support https
          quest: {
            name: 'OpenMapQuest',
            type: 'xyz',
            url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png',
            layerOptions: {
              subdomains: ['1', '2', '3', '4'],
              attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OSM</a>',
              continuousWorld: true,
              TRStyle: 'street'//Not native Leaflet, required by layer switch
            }
          }
        },
        overlays: {
          selectedOffers: {
            name: 'Selected hosts',
            type: 'group',
            visible: false
          }
        }
      },
      paths: {
        selected: $scope.currentSelection
      },
      /**
       * Catch map events:
       * click, dblclick, mousedown, mouseup, mouseover, mouseout, mousemove, contextmenu, focus, blur,
       * preclick, load, unload, viewreset, movestart, move, moveend, dragstart, drag, dragend, zoomstart,
       * zoomend, zoomlevelschange, resize, autopanstart, layeradd, layerremove, baselayerchange, overlayadd,
       * overlayremove, locationfound, locationerror, popupopen, popupclose
       */
      events: {
        map: {
          enable: ['click','mousedown', 'moveend', 'load', 'baselayerchange'],
          logic: 'emit'
        }
      },
      lastbounds : {
        northEastLng: 0,
        northEastLat: 0,
        southWestLng: 0,
        southWestLat: 0
      }
    });

    /**
     * Add additional layers if they're configured
     */
    // Add Satellite
    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,
          TRStyle: 'satellite'//Not native Leaflet, required by layer switch
        }
      };
    }
    // Add experimental Hitchmap
    if(settings.mapbox.map[1]) {
      $scope.layers.baselayers.hitchmap = {
        name: 'Hitchmap',
        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[1]
        },
        layerOptions: {
          attribution: '<a href="http://www.openstreetmap.org/">OSM</a>',
          continuousWorld: true,
          TRStyle: 'street'//Not native Leaflet, required by layer switch
        }
      };
    }

    /*
     * Determine currently selected baselayer style
     * 'TRStyle' has to be set when defining layers.
     * Possible values are: street, satellite
     * Defaults to street
     */
    $scope.$on('leafletDirectiveMap.baselayerchange', function(event, layer) {<commit_msg>Add "Improve this map" link to OSM & Mapbox from the big map<commit_after>'use strict';

/* This declares to JSHint that several variables are global: */
/*global settings:false */
/*global PruneClusterForLeaflet:false */
/*global PruneCluster:false */
/*global L:false */

angular.module('search').controller('SearchController', ['$scope', '$http', '$location', '$state', '$stateParams', '$timeout', '$log', 'Offers', 'leafletBoundsHelpers', 'Authentication', 'Languages', 'leafletData',
  function($scope, $http, $location, $state, $stateParams, $timeout, $log, Offers, leafletBoundsHelpers, Authentication, Languages, leafletData) {

    // Currently signed in user
    $scope.user = Authentication.user;

    // If user is not signed in then redirect back home
    if (!$scope.user) $location.path('signin');

    // Default to Europe for now
    var defaultLocation = {
      lat: 48.6908333333,
      lng: 9.14055555556,
      zoom: 6
    };

    $scope.layerStyle = 'street';
    $scope.sidebarOpen = false;
    $scope.languages = Languages.get('object');
    $scope.offer = false; // Offer to show
    $scope.notFound = false;
    $scope.currentSelection = {
      weight: 2,
      color: '#989898',
      fillColor: '#b1b1b1',
      fillOpacity: 0.5,
      latlngs: defaultLocation,
      radius: 500,
      type: 'circle',
      layer: 'selectedOffers',
      clickable: false
    };
    $scope.minimumZoom = 3;

    // Return constructed icon
    // @link http://leafletjs.com/reference.html#icon
    var icon = function(status) {
      status = (status === 'yes') ? 'yes' : 'maybe';
      return L.icon({
        iconUrl:    '/modules/core/img/map/marker-icon-' + status + '.svg',
        iconSize:   [20, 20], // size of the icon
        iconAnchor: [10, 10] // point of the icon which will correspond to marker's location
      });
    };

    /**
     * The Variables passed to leaflet directive at init
     */
    angular.extend($scope, {
      defaults: {
        attributionControl: true,
        keyboard: true,
        controls: {
          layers: {
            visible: true,
            position: 'bottomleft',
            collapsed: true
          }
        }
      },
      center: {},
      bounds: {},
      layers: {
        baselayers: {
          default: {
            name: 'Default',
            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: '<strong><a href="https://www.mapbox.com/map-feedback/#' + settings.mapbox.user + '.' + settings.mapbox.map[0] + '/' + defaultLocation.lng + '/' + defaultLocation.lat + '/' + defaultLocation.zoom + '">Improve this map</a></strong>',
              continuousWorld: true,
              TRStyle: 'street'//Not native Leaflet, required by layer switch
            }
          },
          osm: {
            name: 'OpenStreetMap',
            type: 'xyz',
            url: '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
            layerOptions: {
              subdomains: ['a', 'b', 'c'],
              attribution: '<strong><a href="https://www.openstreetmap.org/login#map=' + defaultLocation.zoom + '/' + defaultLocation.lat + '/' + defaultLocation.lng + '">Improve this map</a></strong>',
              continuousWorld: true,
              TRStyle: 'street'//Not native Leaflet, required by layer switch
            }
          },
          // Doesn't support https
          quest: {
            name: 'OpenMapQuest',
            type: 'xyz',
            url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png',
            layerOptions: {
              subdomains: ['1', '2', '3', '4'],
              attribution:  '<strong><a href="https://www.openstreetmap.org/login#map=' + defaultLocation.zoom + '/' + defaultLocation.lat + '/' + defaultLocation.lng + '">Improve this map</a></strong>',
              continuousWorld: true,
              TRStyle: 'street'//Not native Leaflet, required by layer switch
            }
          }
        },
        overlays: {
          selectedOffers: {
            name: 'Selected hosts',
            type: 'group',
            visible: false
          }
        }
      },
      paths: {
        selected: $scope.currentSelection
      },
      /**
       * Catch map events:
       * click, dblclick, mousedown, mouseup, mouseover, mouseout, mousemove, contextmenu, focus, blur,
       * preclick, load, unload, viewreset, movestart, move, moveend, dragstart, drag, dragend, zoomstart,
       * zoomend, zoomlevelschange, resize, autopanstart, layeradd, layerremove, baselayerchange, overlayadd,
       * overlayremove, locationfound, locationerror, popupopen, popupclose
       */
      events: {
        map: {
          enable: ['click','mousedown', 'moveend', 'load', 'baselayerchange'],
          logic: 'emit'
        }
      },
      lastbounds : {
        northEastLng: 0,
        northEastLat: 0,
        southWestLng: 0,
        southWestLat: 0
      }
    });

    /**
     * Add additional layers if they're configured
     */
    // Add Satellite
    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: '<strong><a href="https://www.mapbox.com/map-feedback/#' + settings.mapbox.user + '.' + settings.mapbox.map[2] + '/' + defaultLocation.lng + '/' + defaultLocation.lat + '/' + defaultLocation.zoom + '">Improve this map</a></strong>',
          continuousWorld: true,
          TRStyle: 'satellite'//Not native Leaflet, required by layer switch
        }
      };
    }
    // Add experimental Hitchmap
    if(settings.mapbox.map[1]) {
      $scope.layers.baselayers.hitchmap = {
        name: 'Hitchmap',
        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[1]
        },
        layerOptions: {
          attribution: '<strong><a href="https://www.mapbox.com/map-feedback/#' + settings.mapbox.user + '.' + settings.mapbox.map[1] + '/' + defaultLocation.lng + '/' + defaultLocation.lat + '/' + defaultLocation.zoom + '">Improve this map</a></strong>',
          continuousWorld: true,
          TRStyle: 'street'//Not native Leaflet, required by layer switch
        }
      };
    }

    /*
     * Determine currently selected baselayer style
     * 'TRStyle' has to be set when defining layers.
     * Possible values are: street, satellite
     * Defaults to street
     */
    $scope.$on('leafletDirectiveMap.baselayerchange', function(event, layer) {
{'fraction_non_alphanumeric': 0.15217231493053002, 'fraction_numerical': 0.010659413364698963, 'mean_word_length': 2.0806159420289854, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 5, 'lorem ipsum': 0, 'www.': 10, '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': '4440035', 'n_tokens_mistral': 4274, 'n_tokens_neox': 4075, 'n_words': 889}