<commit_before>
$(function() {

  _.templateSettings = {
    interpolate : /\{\{(.+?)\}\}/g
  };

  window.Photo = Backbone.Model.extend({
    initialize: function() {
      this.selected = false;
    },

    makePrimaryPhoto: function() {
      $.ajax({
        url: this.get("select_primary_photo_url"),
        success: function() {
          alert("Set primary photo!");
        },
        type: "PUT"
      });
    },

    select: function() {
      Photos.unselectAll();
      this.selected = true;
      this.view.select();
    },

    unselect: function() {
      this.selected == false;
      this.view.unselect();
    },

    isSelected: function() {
      return this.selected == true;
    },
  });

  window.PhotoList = Backbone.Collection.extend({
    model: Photo,

    unselectAll: function() {
      this.each(function(photo) {
        photo.unselect();
      });
    },

    getSelectedPhoto: function() {
      return this.find(function(photo) {
        return photo.isSelected();
      });
    }
  });
<commit_msg>Clicking the selected photo again will unselect it.<commit_after>
$(function() {

  _.templateSettings = {
    interpolate : /\{\{(.+?)\}\}/g
  };

  window.Photo = Backbone.Model.extend({
    initialize: function() {
      this.selected = false;
    },

    makePrimaryPhoto: function() {
      $.ajax({
        url: this.get("select_primary_photo_url"),
        success: function() {
          alert("Set primary photo!");
        },
        type: "PUT"
      });
    },

    select: function() {
      if (this.isSelected()) {
        this.unselect();
      } else {
        Photos.unselectAll();
        this.selected = true;
        this.view.select();
      }
    },

    unselect: function() {
      this.selected = false;
      this.view.unselect();
    },

    isSelected: function() {
      return this.selected == true;
    },
  });

  window.PhotoList = Backbone.Collection.extend({
    model: Photo,

    unselectAll: function() {
      this.each(function(photo) {
        photo.unselect();
      });
    },

    getSelectedPhoto: function() {
      return this.find(function(photo) {
        return photo.isSelected();
      });
    }
  });

{'fraction_non_alphanumeric': 0.16224862888482633, 'fraction_numerical': 0.0, 'mean_word_length': 2.0193103448275864, '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': '2630266', 'n_tokens_mistral': 671, 'n_tokens_neox': 649, 'n_words': 117}