<commit_before>'use strict';

module.exports = function(app) {
  app.controller('WizardCtrl', [
    '$scope', 'leafletData', '$http', '$filter', 'downloadFile', '$translate',
    'jsonrpc', 'Upload', '$timeout',
    function($scope, leafletData, $http, $filter, downloadFile, $translate,
             jsonrpc, Upload, $timeout) {

      // jscs:disable maximumLineLength
      var onlineCheckUrl = 'https://weimarnetz.de/health?callback=JSON_CALLBACK';
      $scope.selectedLanguage = $translate.use();
      $scope.$watch('selectedLanguage', function(language) {
        $translate.use(language);
      }, true);

      $scope.files = undefined;
      $scope.$watch('files', function() {
        $scope.upload($scope.files);
      }, true);

      $scope.log = '';
      $scope.pastConfigurationRestore = false;
      $scope.hasConfiguration = false;
      $scope.showConfigRestore = function() {
        $scope.hasConfiguration = true;
      };

      $scope.skipAhead = function() {
        angular.element(document.querySelector('#loadconfig')).remove();
        $scope.pastConfigurationRestore = true;
      };

      $scope.upload = function(files) {
        if (!files) {
          return;
        }
        var reader = new FileReader();
        reader.onload = function() {
          var myWizard = JSON.parse(reader.result);
          $scope.wizard = myWizard;
          if ($scope.wizard.router.sshkeys) {
            $scope.state.sshkeys.enabled = true;
          }
        };
        if (files && files.length) {
          for (var i = 0; i < files.length; i++) {
            var file = files[i];
            if (!file.$error) {
              reader.readAsText(file);

            }
          }
        }
        angular.element(document.querySelector('#loadconfig')).remove();
        $scope.pastConfigurationRestore = true;
      };

      $scope.configRestore = function() {
        return $scope.pastConfigurationRestore;
      };

      $scope.uploadVpnFiles = function(file, field) {
        var reader = new FileReader();
        reader.onload = function() {
          switch (field) {
            case 'cert':
              $scope.wizard.internet.vpn.cert.value = reader.result;
              $scope.wizard.internet.vpn.cert.filename = file[0].name;
              break;
            case 'key':
              $scope.wizard.internet.vpn.key.value = reader.result;
              $scope.wizard.internet.vpn.key.filename = file[0].name;
              break;
            case 'takey':
              $scope.wizard.internet.vpn.takey.value = reader.result;
              $scope.wizard.internet.vpn.takey.filename = file[0].name;
              break;
            case 'conf':
              $scope.wizard.internet.vpn.conf.value = reader.result;
              $scope.wizard.internet.vpn.conf.filename = file[0].name;
              break;
            case 'meshcert':
              $scope.wizard.internet.meshvpn.cert.value = reader.result;
              $scope.wizard.internet.meshvpn.cert.filename = file[0].name;
              break;
            case 'meshkey':
              $scope.wizard.internet.meshvpn.key.value = reader.result;
              $scope.wizard.internet.meshvpn.key.filename = file[0].name;
              break;
            case 'meshtakey':
              $scope.wizard.internet.meshvpn.takey.value = reader.result;
              $scope.wizard.internet.meshvpn.takey.filename = file[0].name;
              break;
            case 'meshconf':
              $scope.wizard.internet.meshvpn.conf.value = reader.result;
              $scope.wizard.internet.meshvpn.conf.filename = file[0].name;
              break;
          }
        };
        if (file && file.length == 1) {
          if (!file[0].$error) {
            reader.readAsDataURL(file[0]);
          }
        }
      };

      $scope.toggleVpnList = function() {
        $scope.state.internet.showVpnList = !$scope.state.internet.showVpnList;
      };

      $scope.wizard = {
        router: {
          password: <PASSWORD>,
          passwordVerify: undefined,
          name: undefined,
          sshkeys: undefined
        },
        contact: {
          name: undefined,
          email: undefined,
          options: {
            showOnContactPage: true,<commit_msg>strip file type and base64 header from file content<commit_after>'use strict';

module.exports = function(app) {
  app.controller('WizardCtrl', [
    '$scope', 'leafletData', '$http', '$filter', 'downloadFile', '$translate',
    'jsonrpc', 'Upload', '$timeout',
    function($scope, leafletData, $http, $filter, downloadFile, $translate,
             jsonrpc, Upload, $timeout) {

      // jscs:disable maximumLineLength
      var onlineCheckUrl = 'https://weimarnetz.de/health?callback=JSON_CALLBACK';
      $scope.selectedLanguage = $translate.use();
      $scope.$watch('selectedLanguage', function(language) {
        $translate.use(language);
      }, true);

      $scope.files = undefined;
      $scope.$watch('files', function() {
        $scope.upload($scope.files);
      }, true);

      $scope.log = '';
      $scope.pastConfigurationRestore = false;
      $scope.hasConfiguration = false;
      $scope.showConfigRestore = function() {
        $scope.hasConfiguration = true;
      };

      $scope.skipAhead = function() {
        angular.element(document.querySelector('#loadconfig')).remove();
        $scope.pastConfigurationRestore = true;
      };

      $scope.upload = function(files) {
        if (!files) {
          return;
        }
        var reader = new FileReader();
        reader.onload = function() {
          var myWizard = JSON.parse(reader.result);
          $scope.wizard = myWizard;
          if ($scope.wizard.router.sshkeys) {
            $scope.state.sshkeys.enabled = true;
          }
        };
        if (files && files.length) {
          for (var i = 0; i < files.length; i++) {
            var file = files[i];
            if (!file.$error) {
              reader.readAsText(file);

            }
          }
        }
        angular.element(document.querySelector('#loadconfig')).remove();
        $scope.pastConfigurationRestore = true;
      };

      $scope.configRestore = function() {
        return $scope.pastConfigurationRestore;
      };

      $scope.uploadVpnFiles = function(file, field) {
        var reader = new FileReader();
        reader.onload = function() {
          var content = reader.result.split(',')[1]
          switch (field) {
            case 'cert':
              $scope.wizard.internet.vpn.cert.value = content;
              $scope.wizard.internet.vpn.cert.filename = file[0].name;
              break;
            case 'key':
              $scope.wizard.internet.vpn.key.value = content;
              $scope.wizard.internet.vpn.key.filename = file[0].name;
              break;
            case 'takey':
              $scope.wizard.internet.vpn.takey.value = content;
              $scope.wizard.internet.vpn.takey.filename = file[0].name;
              break;
            case 'conf':
              $scope.wizard.internet.vpn.conf.value = content;
              $scope.wizard.internet.vpn.conf.filename = file[0].name;
              break;
            case 'meshcert':
              $scope.wizard.internet.meshvpn.cert.value = content;
              $scope.wizard.internet.meshvpn.cert.filename = file[0].name;
              break;
            case 'meshkey':
              $scope.wizard.internet.meshvpn.key.value = content;
              $scope.wizard.internet.meshvpn.key.filename = file[0].name;
              break;
            case 'meshtakey':
              $scope.wizard.internet.meshvpn.takey.value = content;
              $scope.wizard.internet.meshvpn.takey.filename = file[0].name;
              break;
            case 'meshconf':
              $scope.wizard.internet.meshvpn.conf.value = content;
              $scope.wizard.internet.meshvpn.conf.filename = file[0].name;
              break;
          }
        };
        if (file && file.length == 1) {
          if (!file[0].$error) {
            reader.readAsDataURL(file[0]);
          }
        }
      };

      $scope.toggleVpnList = function() {
        $scope.state.internet.showVpnList = !$scope.state.internet.showVpnList;
      };

      $scope.wizard = {
        router: {
          password: <PASSWORD>,
          passwordVerify: <PASSWORD>,
          name: undefined,
          sshkeys: undefined
        },
        contact: {
          name: undefined,
          email: undefined,
          options: {
            showOnContactPage: true,
{'fraction_non_alphanumeric': 0.13527696793002916, 'fraction_numerical': 0.0031486880466472305, 'mean_word_length': 1.8182714426552744, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7193739', 'n_tokens_mistral': 2507, 'n_tokens_neox': 2477, 'n_words': 396}