<commit_before>'use strict';

(function (angular) {
  angular
    .module('skinIndexPluginWidget')
    .controller('WidgetLocationCtrl', ['$scope', 'Buildfire', 'DataStore', 'TAG_NAMES', 'STATUS_CODE', 'ViewStack', 'Location', 'Modals',
      function ($scope, Buildfire, DataStore, TAG_NAMES, STATUS_CODE, ViewStack, Location, Modals) {
        var WidgetLocation = this;


        /*Init method call, it will bring all the pre saved data*/
        WidgetLocation.init = function () {
          WidgetLocation.success = function (result) {
            console.info('init success result:', result);
            if (result) {
              WidgetLocation.data = result.data;
              if (!WidgetLocation.data.widget)
                WidgetLocation.data.widget = {};
              if (WidgetLocation.data.widget.location)
                WidgetLocation.currentLocation = WidgetLocation.data.widget.location;
            }
          };
          WidgetLocation.error = function (err) {
            if (err && err.code !== STATUS_CODE.NOT_FOUND) {
              console.error('Error while getting data', err);
            }
          };
          DataStore.get(TAG_NAMES.UVO_INFO).then(WidgetLocation.success, WidgetLocation.error);
        };

        WidgetLocation.init();

        WidgetLocation.getWeatherData = function () {
          ViewStack.push({
            template: 'Weather'
          });
        };

        WidgetLocation.setLocation = function (data) {
          WidgetLocation.success = function (result) {
            if (result) {
              WidgetLocation.data = result.data;
              if (!WidgetLocation.data.widget)
                WidgetLocation.data.widget = {};
            }
          };
          WidgetLocation.error = function (err) {
            console.error('Error while saving data:', err);
          };
          WidgetLocation.data.widget = {
            location: data.location,
            location_coordinates: data.coordinates
          };
          WidgetLocation.currentLocation = WidgetLocation.data.widget.location;
          WidgetLocation.currentCoordinates = WidgetLocation.data.widget.location_coordinates;
          DataStore.save(WidgetLocation.data, TAG_NAMES.UVO_INFO).then(WidgetLocation.success, WidgetLocation.error);
          $scope.$digest();
        };

        WidgetLocation.getCurrentLocation = function () {
          console.log("WidgetLocation.getCurrentLocation called");

          Modals.showMoreOptionsModal({})
            .then(function (data) {
              var locationPromise = Location.getCurrentLocation();
              locationPromise.then(function (response) {
                var geocoder = new google.maps.Geocoder;
                var latitude=parseFloat(response.coords.latitude);
                    var longitude=parseFloat(response.coords.longitude);
                var latlng = {
                  lat: latitude,
                  lng: longitude
                };
                var latLngArray=[latitude,longitude]
                geocoder.geocode({'location': latlng}, function (results, status) {
                  if (status === google.maps.GeocoderStatus.OK) {
                    if (results[1]) {
                      console.log(results[1].formatted_address);
                      WidgetLocation.currentLocation = results[1].formatted_address;
                      WidgetLocation.setLocation({
                        location:  WidgetLocation.currentLocation,
                        location_coordinates : latLngArray
                      });
                      $scope.$digest();
                    } else {
                      console.log('No results found');
                    }
                  } else {
                    console.log('Geocoder failed due to: ' + status);
                  }
                });
<commit_msg>Redirected to next page when user chooses current location<commit_after>'use strict';

(function (angular) {
  angular
    .module('skinIndexPluginWidget')
    .controller('WidgetLocationCtrl', ['$scope', 'Buildfire', 'DataStore', 'TAG_NAMES', 'STATUS_CODE', 'ViewStack', 'Location', 'Modals',
      function ($scope, Buildfire, DataStore, TAG_NAMES, STATUS_CODE, ViewStack, Location, Modals) {
        var WidgetLocation = this;


        /*Init method call, it will bring all the pre saved data*/
        WidgetLocation.init = function () {
          WidgetLocation.success = function (result) {
            console.info('init success result:', result);
            if (result) {
              WidgetLocation.data = result.data;
              if (!WidgetLocation.data.widget)
                WidgetLocation.data.widget = {};
              if (WidgetLocation.data.widget.location)
                WidgetLocation.currentLocation = WidgetLocation.data.widget.location;
            }
          };
          WidgetLocation.error = function (err) {
            if (err && err.code !== STATUS_CODE.NOT_FOUND) {
              console.error('Error while getting data', err);
            }
          };
          DataStore.get(TAG_NAMES.UVO_INFO).then(WidgetLocation.success, WidgetLocation.error);
        };

        WidgetLocation.init();

        WidgetLocation.getWeatherData = function () {
          ViewStack.push({
            template: 'Weather'
          });
        };

        WidgetLocation.setLocation = function (data, redirectToNext) {
          WidgetLocation.success = function (result) {
            if (result) {
              WidgetLocation.data = result.data;
              if (!WidgetLocation.data.widget)
                WidgetLocation.data.widget = {};
              if (redirectToNext) {
                ViewStack.push({
                  template: 'Weather'
                });
              }
            }
          };
          WidgetLocation.error = function (err) {
            console.error('Error while saving data:', err);
          };
          WidgetLocation.data.widget = {
            location: data.location,
            location_coordinates: data.coordinates
          };
          WidgetLocation.currentLocation = WidgetLocation.data.widget.location;
          WidgetLocation.currentCoordinates = WidgetLocation.data.widget.location_coordinates;
          DataStore.save(WidgetLocation.data, TAG_NAMES.UVO_INFO).then(WidgetLocation.success, WidgetLocation.error);
          $scope.$digest();
        };

        WidgetLocation.getCurrentLocation = function () {
          console.log("WidgetLocation.getCurrentLocation called");

          Modals.showMoreOptionsModal({})
            .then(function (data) {
              var locationPromise = Location.getCurrentLocation();
              locationPromise.then(function (response) {
                var geocoder = new google.maps.Geocoder;
                var latitude = parseFloat(response.coords.latitude);
                var longitude = parseFloat(response.coords.longitude);
                var latlng = {
                  lat: latitude,
                  lng: longitude
                };
                var latLngArray = [latitude, longitude];
                geocoder.geocode({'location': latlng}, function (results, status) {
                  if (status === google.maps.GeocoderStatus.OK) {
                    if (results[1]) {
                      console.log(results[1].formatted_address);
                      WidgetLocation.currentLocation = results[1].formatted_address;
                      WidgetLocation.setLocation({
                        location: WidgetLocation.currentLocation,
                        location_coordinates: latLngArray
                      }, true);
                      $scope.$digest();
                    } else {
                      console.log('No results found');
                    }
                  } else {
                    console.log('Geocoder failed due to: ' + status);
                  }
                });

{'fraction_non_alphanumeric': 0.102803738317757, 'fraction_numerical': 0.0007577671129072998, 'mean_word_length': 1.7129153819801302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '4036132', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1865, 'n_words': 357}