<commit_before>angular.module('nOrg', ['ui.bootstrap'
])

  .controller('NOrgCtrl', function NOrgCtrl ($scope, $rootScope, $http, $log) {
    $http.get('app/nodes.json').success(function (node) {
      // Load the initial nodes JSON
      $scope.node = node;
    });

    $scope.setCursor = function (scope) {
      // Move the cursor to the given node
      $rootScope.cursor = scope || $scope;
    };


    $scope.keymap = {
      9: function () {          // tab
        if (! $scope.node.children.length) {
          $log.debug("Cannot expand/collapse nodes without children.");
        } else {
          $scope.cursor.collapsed = ! $scope.cursor.collapsed;
        }},

      38: function () {         // up arrow
        if (typeof $scope.cursor.siblings[
          $scope.cursor.$index - 1] == "undefined") {
          $log.debug("Cannot move cursor before the first child node.");
        } else {
          $scope.setCursor(
            $scope.cursor.siblings[$scope.cursor.$index - 1].scope);
        }},
      40: function () {         // down arrow
        if (typeof $scope.cursor.siblings[
          $scope.cursor.$index + 1] == "undefined") {
          $log.debug("Cannot move cursor after the last child node.");
        } else {
          $scope.setCursor(
            $scope.cursor.siblings[$scope.cursor.$index + 1].scope);
        }},
      39: function () {         // right arrow
        if (typeof $scope.cursor.node.children[0] == "undefined") {
          $log.debug("Cannot move cursor down into a node without children.");
        } else {
          if ($scope.cursor.collapsed) {
            $scope.cursor.collapsed = false;
          }
        $scope.setCursor($scope.cursor.node.children[0].scope);
        }},
      37: function () {         // left arrow
        if (typeof $scope.cursor.parent.parent == "undefined") {
          $log.debug("Cannot move cursor above the top.");
        } else {
        $scope.setCursor($scope.cursor.parent);
        }}
    };
    $scope.keymapAliases = {
      74: 40, 75: 38,  // j/k -> down/up
      87: 38, 83: 40, 65: 37, 68: 39  // w/s/a/d -> up/down/left/right
    };
    for (var from in $scope.keymapAliases) {
      $scope.keymap[from] = $scope.keymap[$scope.keymapAliases[from]];
    }
    $scope.handleKeydown = function ($event) {
      var handler = $scope.keymap[$event.keyCode];
      if (typeof handler != "undefined") {
        handler($event);
        $event.preventDefault();
      }
    };
  })

  .controller('NOrgNodeCtrl', function NOrgCtrl ($scope, $rootScope) {
    $scope.reserved_headers = {"Subject": true, "Message-ID": true};<commit_msg>Let tab do it's thing when not collapsing/expanding<commit_after>angular.module('nOrg', ['ui.bootstrap'
])

  .controller('NOrgCtrl', function NOrgCtrl ($scope, $rootScope, $http, $log) {
    $http.get('app/nodes.json').success(function (node) {
      // Load the initial nodes JSON
      $scope.node = node;
    });

    $scope.setCursor = function (scope) {
      // Move the cursor to the given node
      $rootScope.cursor = scope || $scope;
    };


    $scope.keymap = {
      9: function ($event) {          // tab
        if (! $scope.cursor.node.children.length) {
          $log.debug("Cannot expand/collapse nodes without children.");
        } else {
          $scope.cursor.collapsed = ! $scope.cursor.collapsed;
          $event.preventDefault();
        }},

      38: function () {         // up arrow
        if (typeof $scope.cursor.siblings[
          $scope.cursor.$index - 1] == "undefined") {
          $log.debug("Cannot move cursor before the first child node.");
        } else {
          $scope.setCursor(
            $scope.cursor.siblings[$scope.cursor.$index - 1].scope);
        }},
      40: function () {         // down arrow
        if (typeof $scope.cursor.siblings[
          $scope.cursor.$index + 1] == "undefined") {
          $log.debug("Cannot move cursor after the last child node.");
        } else {
          $scope.setCursor(
            $scope.cursor.siblings[$scope.cursor.$index + 1].scope);
        }},
      39: function () {         // right arrow
        if (typeof $scope.cursor.node.children[0] == "undefined") {
          $log.debug("Cannot move cursor down into a node without children.");
        } else {
          if ($scope.cursor.collapsed) {
            $scope.cursor.collapsed = false;
          }
        $scope.setCursor($scope.cursor.node.children[0].scope);
        }},
      37: function () {         // left arrow
        if (typeof $scope.cursor.parent.parent == "undefined") {
          $log.debug("Cannot move cursor above the top.");
        } else {
        $scope.setCursor($scope.cursor.parent);
        }}
    };
    $scope.keymapAliases = {
      74: 40, 75: 38,  // j/k -> down/up
      87: 38, 83: 40, 65: 37, 68: 39  // w/s/a/d -> up/down/left/right
    };
    for (var from in $scope.keymapAliases) {
      $scope.keymap[from] = $scope.keymap[$scope.keymapAliases[from]];
    }
    $scope.handleKeydown = function ($event) {
      var handler = $scope.keymap[$event.keyCode];
      if (typeof handler != "undefined") {
        handler($event);
      }
    };
  })

  .controller('NOrgNodeCtrl', function NOrgCtrl ($scope, $rootScope) {
    $scope.reserved_headers = {"Subject": true, "Message-ID": true};
{'fraction_non_alphanumeric': 0.15930866052977644, 'fraction_numerical': 0.014653390944955852, 'mean_word_length': 2.0353477765108323, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1626297', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1593, 'n_words': 355}