<commit_before>/**
 * The AnalysisSubscribeDialogView module.
 *
 * @return AnalysisSubscribeDialogView class (extends Backbone.View).
 */
define([
  'backbone',
  'underscore',
  'handlebars',
  'text!templates/dialogs/analysis_subscribe.handlebars'
], function(Backbone, _, Handlebars, tpl) {
  'use strict';

  var AnalysisSubscribeDialogView = Backbone.View.extend({

    template: Handlebars.compile(tpl),

    /**
     * Map layer slugs with subscription url topics.
     */
    topics: {
      'forma': 'updates/forma'
    },

    events: {
      'click #subscribe': '_subscribeAlerts'
    },

    /**
     * Initialize the DialogView.
     *
     * @param  {Object} parent           DialogView public methods
     * @param  {Object} analysisResource The analysis resource.
     */
    initialize: function(parent, options) {
      this.parent = parent;
      this.analysisResource = options.analysisResource;
      this.layer = options.layer;
      this.$el.html(this.template());
    },

    _subscribeAlerts: function() {
      var email = this.$el.find('#areaEmail').val();
      var topic = this.topics[this.layer.slug];

      var data = {
        topic: topic,
        email: email
      };

      if (this.analysisResource.iso) {
        data.iso = this.analysisResource.iso;
      } else if (this.analysisResource.geojson) {
        data.geom = this.analysisResource.geojson;
      }

      $.ajax({
        url: '//gfw-apis.appspot.com/subscribe',
        type: 'POST',
        dataType: 'json',
        crossDomain: true,
        data: data,
        success: _.bind(this._successSubscription, this)
      })
    },
<commit_msg>hotfix subs<commit_after>/**
 * The AnalysisSubscribeDialogView module.
 *
 * @return AnalysisSubscribeDialogView class (extends Backbone.View).
 */
define([
  'backbone',
  'underscore',
  'handlebars',
  'text!templates/dialogs/analysis_subscribe.handlebars'
], function(Backbone, _, Handlebars, tpl) {
  'use strict';

  var AnalysisSubscribeDialogView = Backbone.View.extend({

    template: Handlebars.compile(tpl),

    /**
     * Map layer slugs with subscription url topics.
     */
    topics: {
      'forma': 'updates/forma'
    },

    events: {
      'click #subscribe': '_subscribeAlerts'
    },

    /**
     * Initialize the DialogView.
     *
     * @param  {Object} parent           DialogView public methods
     * @param  {Object} analysisResource The analysis resource.
     */
    initialize: function(parent, options) {
      this.parent = parent;
      this.analysisResource = options.analysisResource;
      this.layer = options.layer;
      this.$el.html(this.template());
    },

    _subscribeAlerts: function() {
      var email = this.$el.find('#areaEmail').val();
      var topic = this.topics[this.layer.slug];

      var data = {
        topic: topic,
        email: email
      };

      if (this.analysisResource.iso) {
        data.iso = this.analysisResource.iso;
      } else if (this.analysisResource.geojson) {
        data.geom = this.analysisResource.geojson;
      }

      $.ajax({
        type: 'POST',
        url: '//gfw-apis.appspot.com/subscribe',
        crossDomain: true,
        data: data,
        dataType: 'json',
        success: function(data, textStatus, jqXHR) {
          console.log('success!');
          console.log(data);
        },
        error: function(responseData, textStatus, errorThrown) {
          console.log(responseData);
        }
      });
    },

{'fraction_non_alphanumeric': 0.1310483870967742, 'fraction_numerical': 0.0, 'mean_word_length': 2.388292682926829, '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': '5396354', 'n_tokens_mistral': 1037, 'n_tokens_neox': 1017, 'n_words': 209}