<commit_before>angular.module('ionic.weather', ['ionic', 'ionic.weather.services', 'ionic.weather.directives'])

.constant('WUNDERGROUND_API_KEY', '<KEY>')

.constant('FLICKR_API_KEY', '<KEY>')

.filter('int', function() {
  return function(v) {
    return parseInt(v) || '';
  };
})

.controller('WeatherCtrl', function($scope, $timeout, Weather, Geo, Flickr, Modal) {
  var _this = this;

  $scope.activeBgImageIndex = 0;

  $scope.showSettings = function() {
   // Load the modal from the given template URL
    Modal.fromTemplateUrl('settings.html', function(modal) {
      $scope.settingsModal = modal;
      $scope.settingsModal.show();
    }, {
      // The animation we want to use for the modal entrance
      animation: 'slide-in-up'
    });
  };

  $scope.getActiveBackgroundImage = function() {
    if($scope.activeBgImage) {
      var item = $scope.activeBgImage;
      var url = "http://farm"+ item.farm +".static.flickr.com/"+ item.server +"/"+ item.id +"_"+ item.secret +"_z.jpg";
      return {
        'background-image': 'url(' + url + ')'
      };
    }
  };

  this.getBackgroundImage = function(lat, lng) {
    Flickr.search('Madison, Wisconsin', lat, lng).then(function(resp) {
      var photos = resp.photos;
      if(photos.photo.length) {
        $scope.bgImages = photos.photo;
        _this.cycleBgImages();
      }
    }, function(error) {
      console.error('Unable to get Flickr images', error);
    });
  };

  this.getForecast = function(lat, lng) {
    Weather.getForecast(lat, lng).then(function(resp) {
      console.log('Forecast', resp);
      $scope.forecast = resp.forecast.simpleforecast;
    }, function(error) {
      alert('Unable to get forecast');
      console.error(error);<commit_msg>Single settings modal<commit_after>angular.module('ionic.weather', ['ionic', 'ionic.weather.services', 'ionic.weather.directives'])

.constant('WUNDERGROUND_API_KEY', '<KEY>')

.constant('FLICKR_API_KEY', '<KEY>')

.filter('int', function() {
  return function(v) {
    return parseInt(v) || '';
  };
})

.controller('WeatherCtrl', function($scope, $timeout, Weather, Geo, Flickr, Modal) {
  var _this = this;

  $scope.activeBgImageIndex = 0;

  $scope.showSettings = function() {
    if(!$scope.settingsModal) {
     // Load the modal from the given template URL
      Modal.fromTemplateUrl('settings.html', function(modal) {
        $scope.settingsModal = modal;
        $scope.settingsModal.show();
      }, {
        // The animation we want to use for the modal entrance
        animation: 'slide-in-up'
      });
    } else {
      $scope.settingsModal.show();
    }
  };

  $scope.getActiveBackgroundImage = function() {
    if($scope.activeBgImage) {
      var item = $scope.activeBgImage;
      var url = "http://farm"+ item.farm +".static.flickr.com/"+ item.server +"/"+ item.id +"_"+ item.secret +"_z.jpg";
      return {
        'background-image': 'url(' + url + ')'
      };
    }
  };

  this.getBackgroundImage = function(lat, lng) {
    Flickr.search('Madison, Wisconsin', lat, lng).then(function(resp) {
      var photos = resp.photos;
      if(photos.photo.length) {
        $scope.bgImages = photos.photo;
        _this.cycleBgImages();
      }
    }, function(error) {
      console.error('Unable to get Flickr images', error);
    });
  };

  this.getForecast = function(lat, lng) {
    Weather.getForecast(lat, lng).then(function(resp) {
      console.log('Forecast', resp);
      $scope.forecast = resp.forecast.simpleforecast;
    }, function(error) {
      alert('Unable to get forecast');
      console.error(error);
{'fraction_non_alphanumeric': 0.16685299049748462, 'fraction_numerical': 0.0005589714924538849, 'mean_word_length': 3.1090700344431688, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7078612', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1145, 'n_words': 220}