<commit_before>'use strict'

const searchAttribute = require('./core/searchAttribute.js')
const printChat = require('./core/printChat.js')

module.exports = function console (cy, selectedNode) {
  // help menu
  const helpMenu = `• help: for options
• meta + l: focus on console
• meta + z: restore node
• search for attributes`

  // loses the focus from the console when tapping
  cy.on('tap', 'node', selection => {
    consoleId.blur()
  })
  cy.on('tap', 'edge', selection => {
    consoleId.blur()
  })
  cy.on('tap', selection => {
    consoleId.blur()
  })

  const consoleId = document.getElementById('console-id')
  // console commands
  const commands = () => {
    const input = document.getElementById('console-id').value
    document.getElementById('console-id').value = ''
    switch (input) {
      case 'help' || 'options':
        printChat(helpMenu)
        break
      case '':
        break
      case 'clear':
        document.getElementById('info-nodes-id').textContent = ''
        break
      default:
        searchAttribute(cy, input)
    }
  }

  // keydown listeners
  document.addEventListener('keydown', event => {
    // focus on the consoleId
    if (event.metaKey === true && event.code === 'KeyL') {
      consoleId.focus()
    }
    // restore elements with meta + z
    // BUG only restores the last node<commit_msg>:art:<commit_after>'use strict'

const searchAttribute = require('./core/searchAttribute.js')
const printChat = require('./core/printChat.js')

module.exports = function console (cy, selectedNode) {
  // help menu
  const helpMenu = `• help: for options
• meta + l: focus on console
• meta + z: restore node
• search for attributes`

  // loses the focus from the console when tapping
  cy.on('tap', 'node', selection => {
    consoleId.blur()
  })
  cy.on('tap', 'edge', selection => {
    consoleId.blur()
  })
  cy.on('tap', selection => {
    consoleId.blur()
  })

  // console commands
  const consoleId = document.getElementById('console-id')
  const commands = () => {
    const input = document.getElementById('console-id').value
    document.getElementById('console-id').value = ''
    switch (input) {
      case 'help' || 'options':
        printChat(helpMenu)
        break
      case '':
        break
      case 'clear':
        document.getElementById('info-nodes-id').textContent = ''
        break
      default:
        searchAttribute(cy, input)
    }
  }

  // keydown listeners
  document.addEventListener('keydown', event => {
    // focus on the consoleId
    if (event.metaKey === true && event.code === 'KeyL') {
      consoleId.focus()
    }
    // restore elements with meta + z
    // BUG only restores the last node
{'fraction_non_alphanumeric': 0.14455151964418086, 'fraction_numerical': 0.0, 'mean_word_length': 2.7642956764295676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4177433', 'n_tokens_mistral': 794, 'n_tokens_neox': 771, 'n_words': 213}