<commit_before>"use strict";
/*
 * ooiui/static/js/views/science/StreamDownloadFormView.js
 * View Definition for DownloadFormView
 *
 * Dependencies
 * Partials
 * - ooiui/static/js/partials/DownloadFOrm.html
 * Libs
 * - ooiui/static/lib/underscore/underscore.js
 * - ooiui/static/lib/backbone/backbone.js
 * - ooiui/static/js/ooi.js
 * Usage
 */


var StreamDownloadFormView = Backbone.View.extend({
  events: {
    'click #download-btn' : 'onDownload'
  },
  initialize: function() {
    this.render();
  },
  onDownload: function() {
    /*
     * Make a copy of the stream model and then set the start and end dates to
     * the form fields, then grab the URL and send the user to it.
     */
    var selection = this.$type_select.val();
    var localModel = this.model.clone();
    var startDate = new Date(this.$start_date.data('date')).toISOString();
    var endDate = new Date(this.$end_date.data('date')).toISOString();
    localModel.set('start', startDate);
    localModel.set('end', endDate);

    var url = localModel.getURL(selection);
    window.location.href = url;
    this.hide();
  },
  failure: function() {<commit_msg>fixes issue where downloading file will block navigation; download now properly opens in new tab and closes tab when finished.<commit_after>"use strict";
/*
 * ooiui/static/js/views/science/StreamDownloadFormView.js
 * View Definition for DownloadFormView
 *
 * Dependencies
 * Partials
 * - ooiui/static/js/partials/DownloadFOrm.html
 * Libs
 * - ooiui/static/lib/underscore/underscore.js
 * - ooiui/static/lib/backbone/backbone.js
 * - ooiui/static/js/ooi.js
 * Usage
 */


var StreamDownloadFormView = Backbone.View.extend({
  events: {
    'click #download-btn' : 'onDownload'
  },
  initialize: function() {
    this.render();
  },
  onDownload: function() {
    /*
     * Make a copy of the stream model and then set the start and end dates to
     * the form fields, then grab the URL and send the user to it.
     */
    var selection = this.$type_select.val();
    var localModel = this.model.clone();
    var startDate = new Date(this.$start_date.data('date')).toISOString();
    var endDate = new Date(this.$end_date.data('date')).toISOString();
    localModel.set('start', startDate);
    localModel.set('end', endDate);

    var url = localModel.getURL(selection);
    window.open(url, '_blank');
//    window.location.href = url;
    this.hide();
  },
  failure: function() {
{'fraction_non_alphanumeric': 0.13780337309749074, 'fraction_numerical': 0.0, 'mean_word_length': 3.3741007194244603, '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': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5040738', 'n_tokens_mistral': 784, 'n_tokens_neox': 773, 'n_words': 185}