<commit_before>import Ember from 'ember';
import config from 'polyflix/config/environment';
import TmdbMovie from 'polyflix/models/tmdb-movie';

export default Ember.Controller.extend({
  query: '',
  actions: {
    search: function() {
      var movies = [];
      this.set('movies', movies);
      var query = this.get('query');
      var tmdbConfig = this.tmdbConfig;
      Ember.$.get(config.restURL + '/movies/search/' + query)
      .done(response => {
        var results = response.results;
        results.forEach(function(movieData) {
          movieData.tmdbConfig = tmdbConfig;
          var tmdbMovie = TmdbMovie.create(movieData);
          movies.pushObject(tmdbMovie);
        });
        this.set('movies', movies);
      });
    },
    getInfo: function(movie) {
      this.set('movie',movie);
      Ember.$("#movieInfoModal").modal("show");
    },
    addMovie: function(movie) {
      console.log('addMovie', movie);
    },
    closeModal: function() {
      console.log('closeModal');
      Ember.$("#movieInfoModal").modal("hide");
    }
  }
});<commit_msg>Refractor modal functions<commit_after>import Ember from 'ember';
import config from 'polyflix/config/environment';
import TmdbMovie from 'polyflix/models/tmdb-movie';

export default Ember.Controller.extend({
  query: '',
  displayModal: function(action) {
    Ember.$('#movieInfoModal').modal(action);
  },
  actions: {
    search: function() {
      var movies = [];
      this.set('movies', movies);
      var query = this.get('query');
      var tmdbConfig = this.tmdbConfig;
      Ember.$.get(config.restURL + '/movies/search/' + query)
      .done(response => {
        var results = response.results;
        results.forEach(function(movieData) {
          movieData.tmdbConfig = tmdbConfig;
          var tmdbMovie = TmdbMovie.create(movieData);
          movies.pushObject(tmdbMovie);
        });
        this.set('movies', movies);
      });
    },
    getInfo: function(movie) {
      this.set('movie',movie);
      this.displayModal('show');
    },
    addMovie: function(movie) {
      console.log('addMovie',movie);
    },
    closeModal: function() {
      console.log('closeModal');
      this.displayModal('hide');
    }
  }
});
{'fraction_non_alphanumeric': 0.1559550561797753, 'fraction_numerical': 0.0, 'mean_word_length': 2.805128205128205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '361175', 'n_tokens_mistral': 718, 'n_tokens_neox': 680, 'n_words': 118}