<commit_before>/* global $ */

import Active from './Active'
import Control from './Control'
import JIT from './JIT'
import Mobile from './Mobile'
import Realtime from './Realtime'
import Selected from './Selected'
import Topic from './Topic'
import Visualize from './Visualize'
import { Search } from './GlobalUI'

const Listeners = {
  init: function () {
    var self = this
    $(document).on('keydown', function (e) {
      if (!(Active.Map || Active.Topic)) return

      switch (e.which) {
        case 13: // if enter key is pressed
          JIT.enterKeyHandler()
          e.preventDefault()
          break
        case 27: // if esc key is pressed
          JIT.escKeyHandler()
          break
        case 65: // if a or A is pressed
          if (e.ctrlKey) {
            Control.deselectAllNodes()
            Control.deselectAllEdges()

            e.preventDefault()
            Visualize.mGraph.graph.eachNode(function (n) {
              Control.selectNode(n, e)
            })

            Visualize.mGraph.plot()
          }
<commit_msg>arrow key panning - fixes #239<commit_after>/* global $ */

import Active from './Active'
import Control from './Control'
import JIT from './JIT'
import Mobile from './Mobile'
import Realtime from './Realtime'
import Selected from './Selected'
import Topic from './Topic'
import Visualize from './Visualize'
import { Search } from './GlobalUI'

const Listeners = {
  init: function () {
    var self = this
    $(document).on('keydown', function (e) {
      if (!(Active.Map || Active.Topic)) return

      switch (e.which) {
        case 13: // if enter key is pressed
          JIT.enterKeyHandler()
          e.preventDefault()
          break
        case 27: // if esc key is pressed
          JIT.escKeyHandler()
          break
        case 37: // if Left arrow key is pressed
          Visualize.mGraph.canvas.translate(-20, 0)
          break
        case 38: // if Up arrow key is pressed
          Visualize.mGraph.canvas.translate(0, -20)
          break
        case 39: // if Right arrow key is pressed
          Visualize.mGraph.canvas.translate(20, 0)
          break
        case 40: // if Down arrow key is pressed
          Visualize.mGraph.canvas.translate(0, 20)
          break
        case 65: // if a or A is pressed
          if (e.ctrlKey) {
            Control.deselectAllNodes()
            Control.deselectAllEdges()

            e.preventDefault()
            Visualize.mGraph.graph.eachNode(function (n) {
              Control.selectNode(n, e)
            })

            Visualize.mGraph.plot()
          }

{'fraction_non_alphanumeric': 0.11239414934565051, 'fraction_numerical': 0.013471901462663588, 'mean_word_length': 1.859185918591859, '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': '5305331', 'n_tokens_mistral': 747, 'n_tokens_neox': 712, 'n_words': 230}