<commit_before>const Utils = require('../common/utils/index');

module.exports = function DownloadCtrl($scope) {
  const $grandParentScope = $scope.$parent.$parent;

  $scope.dataTypes = Utils.dataTypes;
  $scope.tabs = [
    {
      title: 'GeoJSON',
      format: 'json',
    },
    {
      title: 'GPX',
      format: 'gpx',
    },
    {
      title: 'KML',
      format: 'kml',
    },
  ];

  $scope.setExportFormat = function setExportFormat(format) {
    $scope.exportFormat = format;
  };

  $scope.openDownloadModal = function openDownloadModal() {
    $scope.download = function download() {
      const format = $scope.exportFormat;
      const data = $scope.dataTypes[format].output($grandParentScope.features);
      const filename = `Route1.${$scope.dataTypes[format].ext}`;
      const options = {
        type: `${$scope.dataTypes[format].mime};charset=utf-8`,
      };

      // http://stackoverflow.com/a/20194533
      const tempElem = window.document.createElement('a');
      tempElem.href = window.URL.createObjectURL(new Blob([data], options));
      tempElem.download = filename;

      document.body.appendChild(tempElem);
      tempElem.click();

      // tidy up
      document.body.removeChild(tempElem);
    };
  };
};<commit_msg>Fix broken download button, fixes #10.<commit_after>const Utils = require('../common/utils/index');

module.exports = function DownloadCtrl($scope) {
  const $grandParentScope = $scope.$parent.$parent;

  $scope.dataTypes = Utils.dataTypes;
  $scope.tabs = [
    {
      title: 'GeoJSON',
      format: 'json',
    },
    {
      title: 'GPX',
      format: 'gpx',
    },
    {
      title: 'KML',
      format: 'kml',
    },
  ];

  $scope.setExportFormat = function setExportFormat(format) {
    $scope.exportFormat = format;
  };

  $scope.download = function download() {
    const format = $scope.exportFormat;
    const data = $scope.dataTypes[format].output($grandParentScope.features);
    const filename = `Route1.${$scope.dataTypes[format].ext}`;
    const options = {
      type: `${$scope.dataTypes[format].mime};charset=utf-8`,
    };

    // http://stackoverflow.com/a/20194533
    const tempElem = window.document.createElement('a');
    tempElem.href = window.URL.createObjectURL(new Blob([data], options));
    tempElem.download = filename;

    document.body.appendChild(tempElem);
    tempElem.click();

    // tidy up
    document.body.removeChild(tempElem);
  };
};
{'fraction_non_alphanumeric': 0.15834697217675942, 'fraction_numerical': 0.00900163666121113, 'mean_word_length': 2.9950980392156863, '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': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3866932', 'n_tokens_mistral': 786, 'n_tokens_neox': 759, 'n_words': 128}